Skip to content

Commit

Permalink
[C] Suppress maybe-uninitialized warnings in GCC.
Browse files Browse the repository at this point in the history
GCC is known to emit false positives when it cannot detect if a variable
is initialized.
  • Loading branch information
denizevrenci committed Mar 26, 2019
1 parent 6ffbd10 commit ad95f2b
Showing 1 changed file with 28 additions and 0 deletions.
Expand Up @@ -309,8 +309,15 @@ private static void generateGroupHeaderFunctions(
" {\n" +
" return NULL;\n" +
" }\n" +
"#if defined(__GNUG__) && !defined(__clang__)\n" +
"#pragma GCC diagnostic push\n" +
"#pragma GCC diagnostic ignored \"-Wmaybe-uninitialized\"\n" +
"#endif\n" +
" %5$s_set_blockLength(&codec->dimensions, (%2$s)%3$d);\n" +
" %5$s_set_numInGroup(&codec->dimensions, (%4$s)count);\n" +
"#if defined(__GNUG__) && !defined(__clang__)\n" +
"#pragma GCC diagnostic pop\n" +
"#endif\n" +
" codec->index = -1;\n" +
" codec->count = count;\n" +
" codec->block_length = %3$d;\n" +
Expand All @@ -337,7 +344,14 @@ private static void generateGroupHeaderFunctions(

"SBE_ONE_DEF uint64_t %3$s_sbe_position(const struct %3$s *const codec)\n" +
"{\n" +
"#if defined(__GNUG__) && !defined(__clang__)\n" +
"#pragma GCC diagnostic push\n" +
"#pragma GCC diagnostic ignored \"-Wmaybe-uninitialized\"\n" +
"#endif\n" +
" return *codec->position_ptr;\n" +
"#if defined(__GNUG__) && !defined(__clang__)\n" +
"#pragma GCC diagnostic pop\n" +
"#endif\n" +
"}\n\n" +

"SBE_ONE_DEF bool %3$s_set_sbe_position(struct %3$s *const codec, const uint64_t position)\n" +
Expand All @@ -358,14 +372,28 @@ private static void generateGroupHeaderFunctions(

"SBE_ONE_DEF bool %3$s_has_next(const struct %3$s *const codec)\n" +
"{\n" +
"#if defined(__GNUG__) && !defined(__clang__)\n" +
"#pragma GCC diagnostic push\n" +
"#pragma GCC diagnostic ignored \"-Wmaybe-uninitialized\"\n" +
"#endif\n" +
" return codec->index + 1 < codec->count;\n" +
"#if defined(__GNUG__) && !defined(__clang__)\n" +
"#pragma GCC diagnostic pop\n" +
"#endif\n" +
"}\n\n" +

"SBE_ONE_DEF struct %3$s *%3$s_next(struct %3$s *const codec)\n" +
"{\n" +
" codec->offset = *codec->position_ptr;\n" +
"#if defined(__GNUG__) && !defined(__clang__)\n" +
"#pragma GCC diagnostic push\n" +
"#pragma GCC diagnostic ignored \"-Wmaybe-uninitialized\"\n" +
"#endif\n" +
" if (SBE_BOUNDS_CHECK_EXPECT(((codec->offset + codec->block_length) " +
"> codec->buffer_length), false))\n" +
"#if defined(__GNUG__) && !defined(__clang__)\n" +
"#pragma GCC diagnostic pop\n" +
"#endif\n" +
" {\n" +
" errno = E108;\n" +
" return NULL;\n" +
Expand Down

0 comments on commit ad95f2b

Please sign in to comment.