summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2013-10-23 11:13:35 +0200
committerMatthias Braun <matze@braunis.de>2013-10-23 11:13:35 +0200
commitb48f936d7d073eef665d7ba2bab5e22e99f08254 (patch)
tree3ae6288b282d2809c7aa6dd25a8862b7b43201cf
parent6ca882687680f2dd41bf0633a7c1394be395937c (diff)
streamline passing of warnings to external preprocessor
-rw-r--r--driver.c10
-rw-r--r--options.c7
-rw-r--r--warning.c2
-rw-r--r--warning.h2
4 files changed, 15 insertions, 6 deletions
diff --git a/driver.c b/driver.c
index d36de70..18d44b8 100644
--- a/driver.c
+++ b/driver.c
@@ -285,6 +285,16 @@ static bool run_external_preprocessor(compilation_unit_t *unit, FILE *out,
obstack_1grow(&cppflags_obst, ' ');
obstack_grow(&cppflags_obst, flags, len);
}
+ if (!is_warn_on(WARN_TRIGRAPHS))
+ driver_add_flag(&cppflags_obst, "-Wno-trigraphs");
+ if (is_warn_on(WARN_UNDEF))
+ driver_add_flag(&cppflags_obst, "-Wundef");
+ if (is_warn_on(WARN_MISSING_INCLUDE_DIRS))
+ driver_add_flag(&cppflags_obst, "-Wmissing-include-dirs");
+ if (is_warn_on(WARN_ENDIF_LABELS))
+ driver_add_flag(&cppflags_obst, "-Wendif-labels");
+ if (is_warn_on(WARN_COMMENT))
+ driver_add_flag(&cppflags_obst, "-Wcomment");
/* handle dependency generation */
if (construct_dep_target) {
diff --git a/options.c b/options.c
index 741c431..aa364e6 100644
--- a/options.c
+++ b/options.c
@@ -468,12 +468,7 @@ bool options_parse_diagnostics(options_state_t *s)
dialect.strict = true;
set_warning_opt("pedantic");
} else if (option[0] == 'W') {
- if (streq(option + 1, "no-trigraphs")
- || streq(option + 1, "undef")
- || streq(option + 1, "missing-include-dirs")
- || streq(option + 1, "endif-labels")) {
- driver_add_flag(&cppflags_obst, "%s", full_option);
- } else if (streq(option+1, "init-self")) {
+ if (streq(option+1, "init-self")) {
/* ignored (same as gcc does) */
} else if (streq(option+1, "format-y2k")
|| streq(option+1, "format-security")
diff --git a/warning.c b/warning.c
index 8366444..715fa3f 100644
--- a/warning.c
+++ b/warning.c
@@ -41,6 +41,7 @@ static warning_switch_t warning[] = {
[WARN_MISSING_VARIABLE_DECLARATIONS] = { WARN_STATE_NONE, "missing-variable-declarations" },
[WARN_MISSING_NORETURN] = { WARN_STATE_NONE, "missing-noreturn" },
[WARN_MISSING_PROTOTYPES] = { WARN_STATE_NONE, "missing-prototypes" },
+ [WARN_MISSING_INCLUDE_DIRS] = { WARN_STATE_NONE, "missing-include-dirs" },
[WARN_MULTICHAR] = { WARN_STATE_ON, "multichar" },
[WARN_NESTED_EXTERNS] = { WARN_STATE_NONE, "nested-externs" },
[WARN_NONNULL] = { WARN_STATE_ON, "nonnull" },
@@ -62,6 +63,7 @@ static warning_switch_t warning[] = {
[WARN_SWITCH_ENUM] = { WARN_STATE_NONE, "switch-enum" },
[WARN_SYSTEM] = { WARN_STATE_NONE, "system" },
[WARN_TRADITIONAL] = { WARN_STATE_NONE, "traditional" },
+ [WARN_TRIGRAPHS] = { WARN_STATE_NONE, "trigraphs" },
[WARN_UNDEF] = { WARN_STATE_NONE, "undef" },
[WARN_UNINITIALIZED] = { WARN_STATE_ON, "uninitialized" },
[WARN_UNKNOWN_PRAGMAS] = { WARN_STATE_ON, "unknown-pragmas" },
diff --git a/warning.h b/warning.h
index f4f536d..a3cde9a 100644
--- a/warning.h
+++ b/warning.h
@@ -41,6 +41,7 @@ typedef enum warning_t {
WARN_MISSING_VARIABLE_DECLARATIONS, /**< Warn if a global variable is defined without a previous declaration */
WARN_MISSING_NORETURN, /**< Warn about functions which might be candidates for attribute 'noreturn' */
WARN_MISSING_PROTOTYPES, /**< Warn if a global function is defined without a previous prototype declaration */
+ WARN_MISSING_INCLUDE_DIRS,
WARN_MULTICHAR, /**< Warn if a multicharacter constant ('FOOF') is used. */
WARN_NESTED_EXTERNS, /**< Warn if an 'extern' declaration is encountered within a function. */
WARN_NONNULL, /**< Warn about passing a null pointer for arguments marked nonnull. */
@@ -62,6 +63,7 @@ typedef enum warning_t {
WARN_SWITCH_ENUM, /**< Warn about 'switch' statements with an enum as index type and missing case labels or case labels outside the enum range TODO has an alias -Wswitch? */
WARN_SYSTEM, /**< Show warnings in system headers. */
WARN_TRADITIONAL, /**< Warn about certain constructs that behave differently in traditional and ISO C */
+ WARN_TRIGRAPHS,
WARN_UNDEF, /**< Warn if an undefined identifier is evaluated in an '#if' directive */
WARN_UNINITIALIZED, /**< Warn if an automatic variable is used without being initialized or if a variable may be clobbered by a 'setjmp' call. */
WARN_UNKNOWN_PRAGMAS, /**< Warn when a #pragma directive is encountered which is not understood */