diff options
author | Geoff Johnstone <geoff.johnstone@googlemail.com> | 2008-04-21 11:53:48 -0700 |
---|---|---|
committer | Josh Triplett <josh@freedesktop.org> | 2008-04-21 11:53:48 -0700 |
commit | 32dd96be4de207b09559d9b71c4cd6f7cb0cb4e2 (patch) | |
tree | b73d3dece1a2f38f3a6daf78ac4c4d51691322f2 /lib.c | |
parent | improve -Wcontext code and messages (diff) | |
download | sparse-32dd96be4de207b09559d9b71c4cd6f7cb0cb4e2.tar.gz sparse-32dd96be4de207b09559d9b71c4cd6f7cb0cb4e2.tar.bz2 sparse-32dd96be4de207b09559d9b71c4cd6f7cb0cb4e2.zip |
Add -Wno-declaration-after-statement
This adds -W[no-]declaration-after-statement, which makes warnings about
declarations after statements a command-line option. (The code to implement
the warning was already in there via a #define; the patch just exposes it
at runtime.) Rationale: C99 allows them, C89 doesn't.
Signed-off-by: Geoff Johnstone <geoff.johnstone@googlemail.com>
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -208,6 +208,7 @@ int Wtransparent_union = 1; int Wtypesign = 0; int Wundef = 0; int Wuninitialized = 1; +int Wdeclarationafterstatement = -1; int dbg_entry = 0; int dbg_dead = 0; @@ -372,6 +373,7 @@ static const struct warning { { "typesign", &Wtypesign }, { "undef", &Wundef }, { "uninitialized", &Wuninitialized }, + { "declaration-after-statement", &Wdeclarationafterstatement }, }; enum { @@ -456,6 +458,28 @@ static void handle_onoff_switch_finalize(const struct warning warnings[], int n) static void handle_switch_W_finalize(void) { handle_onoff_switch_finalize(warnings, sizeof(warnings) / sizeof(warnings[0])); + + /* default Wdeclarationafterstatement based on the C dialect */ + if (-1 == Wdeclarationafterstatement) + { + switch (standard) + { + case STANDARD_C89: + case STANDARD_C94: + Wdeclarationafterstatement = 1; + break; + + case STANDARD_C99: + case STANDARD_GNU89: + case STANDARD_GNU99: + Wdeclarationafterstatement = 0; + break; + + default: + assert (0); + } + + } } static void handle_switch_v_finalize(void) |