build: compile with -Wno-duplicate-decl-specifier

Duplicated const specifiers are allowed by C99 and can easily
happen in macros. Also, systemd's interal code will use them.

Disable this warning, it doesn't seem useful.
This commit is contained in:
Thomas Haller 2016-03-09 11:17:36 +01:00
parent c885fd55e8
commit f7941ceba3
2 changed files with 27 additions and 1 deletions

View file

@ -50,6 +50,7 @@ if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
for option in -Wshadow -Wmissing-declarations -Wmissing-prototypes \
-Wdeclaration-after-statement -Wformat-security \
-Wfloat-equal -Wno-unused-parameter -Wno-sign-compare \
-Wno-duplicate-decl-specifier \
-Wstrict-prototypes \
-fno-strict-aliasing -Wno-unused-but-set-variable \
-Wundef -Wimplicit-function-declaration \

View file

@ -1221,7 +1221,31 @@ test_nm_utils_strbuf_append (void)
}
}
/*******************************************/
/*****************************************************************************/
static void
test_duplicate_decl_specifier (void)
{
/* have some static variables, so that the result is certainly not optimized out. */
static const int v_const[1] = { 1 };
static int v_result[1] = { };
const const int v2 = 3;
/* Test that we don't get a compiler warning about duplicate const specifier.
* C99 allows that and it can easily happen in macros. */
#define TEST_MAX(a, b) \
({ \
const typeof(a) _a = (a); \
const typeof(b) _b = (b); \
\
(_a > _b ? _a : _b); \
})
v_result[0] = TEST_MAX (v_const[0], nmtst_get_rand_int () % 5) + v2;
}
/*****************************************************************************/
NMTST_DEFINE ();
@ -1254,6 +1278,7 @@ main (int argc, char **argv)
g_test_add_func ("/general/nm_match_spec_interface_name", test_nm_match_spec_interface_name);
g_test_add_func ("/general/nm_match_spec_match_config", test_nm_match_spec_match_config);
g_test_add_func ("/general/duplicate_decl_specifier", test_duplicate_decl_specifier);
return g_test_run ();
}