Implement -Wunknown-pragmas.
authorChristoph Mallon <christoph.mallon@gmx.de>
Fri, 14 Dec 2007 09:48:32 +0000 (09:48 +0000)
committerChristoph Mallon <christoph.mallon@gmx.de>
Fri, 14 Dec 2007 09:48:32 +0000 (09:48 +0000)
[r18738]

lexer.c
warning.c
warning.h

diff --git a/lexer.c b/lexer.c
index b00b8a2..84e6c24 100644 (file)
--- a/lexer.c
+++ b/lexer.c
@@ -11,6 +11,7 @@
 #include "type_t.h"
 #include "target_architecture.h"
 #include "parser.h"
+#include "warning.h"
 
 #include <assert.h>
 #include <errno.h>
@@ -1037,7 +1038,9 @@ static void parse_preprocessor_identifier(void)
                error_directive();
                break;
        case TP_pragma:
-               warningf(lexer_token.source_position, "encountered unknown #pragma");
+               if (warning.unknown_pragmas) {
+                       warningf(lexer_token.source_position, "encountered unknown #pragma");
+               }
                eat_until_newline();
                break;
        }
index 963941b..2689007 100644 (file)
--- a/warning.c
+++ b/warning.c
@@ -32,6 +32,7 @@ void set_warning_opt(const char *const opt)
        OPT("redundant-decls",               redundant_decls)
        OPT("strict-prototypes",             strict_prototypes)
        OPT("switch-default",                switch_default)
+       OPT("unknown-pragmas",               unknown_pragmas)
 #if 0
        OPTX("unused") {
                SET(unused_function)
@@ -62,5 +63,6 @@ warning_t warning = {
        .s_are_errors                  = false,
        .strict_prototypes             = true,
        .switch_default                = false,
+       .unknown_pragmas               = true,
        .unused_value                  = true
 };
index 327cb6d..0b145cc 100644 (file)
--- a/warning.h
+++ b/warning.h
@@ -65,7 +65,9 @@ typedef struct warning_t {
        bool traditional:1;                   /* Warn about certain constructs that behave differently in traditional and ISO C */
        bool undef:1;                         /* Warn if an undefined identifier is evaluated in an '#if' directive */
        bool uninitialized:1;                 /* Warn if an automatic variable is used without being initialized or if a variable may be clobbered by a 'setjmp' call. */
-       bool unknown_pragmas:1;               /* Warn when a #pragma directive is encountered which is not understood by GCC */
+#endif
+       bool unknown_pragmas:1;               /* Warn when a #pragma directive is encountered which is not understood */
+#if 0 // TODO
        bool unreachable_code:1;              /* Warn if the compiler detects that code will never be executed */
        bool unused_function:1;               /* Warn whenever a static function is declared but not defined or a non-inline static function is unused */
        bool unused_label:1;                  /* Warn whenever a label is declared but not used */