OSDN Git Service

* diagnostic.h (diagnostic_override_option_index): New macro to
authorsimonb <simonb@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 7 Apr 2010 17:18:10 +0000 (17:18 +0000)
committerMasaki Muranaka <monaka@monami-software.com>
Sun, 23 May 2010 05:17:34 +0000 (14:17 +0900)
set a diagnostic's option_index.
* c-tree.h (c_cpp_error): Add warning reason argument.
* opts.c (_warning_as_error_callback): New.
(register_warning_as_error_callback): Store callback for
warnings enabled via enable_warning_as_error.
(enable_warning_as_error): Call callback, minor code tidy.
* opts.h (register_warning_as_error_callback): Declare.
* c-opts.c (warning_as_error_callback): New, set cpp_opts flag in
response to -Werror=.
(c_common_init_options): Register warning_as_error_callback in opts.c.
* common.opt: Add -Wno-cpp option.
* c-common.c (struct reason_option_codes_t): Map cpp warning
reason codes to gcc option indexes.
* (c_option_controlling_cpp_error): New function, lookup the gcc
option index for a cpp warning reason code.
* (c_cpp_error): Add warning reason argument, call
c_option_controlling_cpp_error for diagnostic_override_option_index.
* doc/invoke.texi: Document -Wno-cpp.

* cpp.c (cb_cpp_error): Add warning reason argument, set a value
for diagnostic_override_option_index if CPP_W_WARNING_DIRECTIVE.

* directives.c (do_diagnostic): Add warning reason argument,
call appropriate error reporting function for code.
(directive_diagnostics): Call specific warning functions with
warning reason where appropriate.
(do_error, do_warning, do_pragma_dependency): Add warning reason
argument to do_diagnostic calls.
* macro.c (_cpp_warn_if_unused_macro, enter_macro_context,
_cpp_create_definition): Call specific warning functions with
        warning reason where appropriate.
* Makefile.in: Add new diagnostic functions to gettext translations.
* include/cpplib.h (struct cpp_callbacks): Add warning reason code
to error callback.
(CPP_DL_WARNING, CPP_DL_WARNING_SYSHDR, CPP_DL_PEDWARN, CPP_DL_ERROR,
CPP_DL_ICE, CPP_DL_NOTE, CPP_DL_FATAL): Replace macros with enums.
(CPP_W_NONE, CPP_W_DEPRECATED, CPP_W_COMMENTS,
CPP_W_MISSING_INCLUDE_DIRS, CPP_W_TRIGRAPHS, CPP_W_MULTICHAR,
CPP_W_TRADITIONAL, CPP_W_LONG_LONG, CPP_W_ENDIF_LABELS,
CPP_W_NUM_SIGN_CHANGE, CPP_W_VARIADIC_MACROS,
CPP_W_BUILTIN_MACRO_REDEFINED, CPP_W_DOLLARS, CPP_W_UNDEF,
CPP_W_UNUSED_MACROS, CPP_W_CXX_OPERATOR_NAMES, CPP_W_NORMALIZE,
CPP_W_INVALID_PCH, CPP_W_WARNING_DIRECTIVE): New enums for cpp
warning reason codes.
(cpp_warning, cpp_pedwarning, cpp_warning_syshdr,
cpp_warning_with_line, cpp_pedwarning_with_line,
cpp_warning_with_line_syshdr): New specific error reporting functions.
* pch.c (cpp_valid_state): Call specific warning functions with
        warning reason where appropriate.
* errors.c (cpp_diagnostic, cpp_diagnostic_with_line): New central
diagnostic handlers.
(cpp_warning, cpp_pedwarning, cpp_warning_syshdr,
cpp_warning_with_line, cpp_pedwarning_with_line,
cpp_warning_with_line_syshdr): New specific error reporting functions.
* expr.c (cpp_classify_number, eval_token, num_unary_op): Call
specific warning functions with warning reason where appropriate.
* lex.c (_cpp_process_line_notes, _cpp_skip_block_comment,
warn_about_normalization, lex_identifier_intern, lex_identifier,
_cpp_lex_direct): Ditto.
* charset.c (_cpp_valid_ucn, convert_hex, convert_escape,
narrow_str_to_charconst): Ditto.

* gcc.dg/cpp/warn-undef-2.c: New.
* gcc.dg/cpp/warn-traditional-2.c: New.
* gcc.dg/cpp/warn-comments-2.c: New.
* gcc.dg/cpp/warning-directive-1.c: New.
* gcc.dg/cpp/warn-long-long.c: New.
* gcc.dg/cpp/warn-traditional.c: New.
* gcc.dg/cpp/warn-variadic-2.c: New.
* gcc.dg/cpp/warn-undef.c: New.
* gcc.dg/cpp/warn-normalized-1.c: New.
* gcc.dg/cpp/warning-directive-2.c: New.
* gcc.dg/cpp/warn-long-long-2.c: New.
* gcc.dg/cpp/warn-variadic.c: New.
* gcc.dg/cpp/warn-normalized-2.c: New.
* gcc.dg/cpp/warning-directive-3.c: New.
* gcc.dg/cpp/warn-deprecated-2.c: New.
* gcc.dg/cpp/warn-trigraphs-1.c: New.
* gcc.dg/cpp/warn-multichar-2.c: New.
* gcc.dg/cpp/warn-normalized-3.c: New.
* gcc.dg/cpp/warning-directive-4.c: New.
* gcc.dg/cpp/warn-unused-macros.c: New.
* gcc.dg/cpp/warn-trigraphs-2.c: New.
* gcc.dg/cpp/warn-cxx-compat-2.c: New.
* gcc.dg/cpp/warn-cxx-compat.c: New.
* gcc.dg/cpp/warn-redefined.c: New.
* gcc.dg/cpp/warn-trigraphs-3.c: New.
* gcc.dg/cpp/warn-unused-macros-2.c: New.
* gcc.dg/cpp/warn-deprecated.c: New.
* gcc.dg/cpp/warn-trigraphs-4.c: New.
* gcc.dg/cpp/warn-redefined-2.c: New.
* gcc.dg/cpp/warn-comments.c: New.
* gcc.dg/cpp/warn-multichar.c: New.
* g++.dg/cpp/warning-directive-1.C: New.
* g++.dg/cpp/warning-directive-2.C: New.
* g++.dg/cpp/warning-directive-3.C: New.
* g++.dg/cpp/warning-directive-4.C: New.
* gfortran.dg/warning-directive-1.F90: New.
* gfortran.dg/warning-directive-3.F90: New.
* gfortran.dg/warning-directive-2.F90: New.
* gfortran.dg/warning-directive-4.F90: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158079 138bc75d-0d04-0410-961f-82ee72b054a4

28 files changed:
gcc/ChangeLog
gcc/fortran/ChangeLog
gcc/opts.c
gcc/opts.h
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp/warning-directive-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp/warning-directive-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp/warning-directive-3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp/warning-directive-4.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp/warn-comments-2.c
gcc/testsuite/gcc.dg/cpp/warn-cxx-compat-2.c
gcc/testsuite/gcc.dg/cpp/warn-deprecated-2.c
gcc/testsuite/gcc.dg/cpp/warn-long-long-2.c
gcc/testsuite/gcc.dg/cpp/warn-multichar-2.c
gcc/testsuite/gcc.dg/cpp/warn-normalized-3.c
gcc/testsuite/gcc.dg/cpp/warn-redefined-2.c
gcc/testsuite/gcc.dg/cpp/warn-traditional-2.c
gcc/testsuite/gcc.dg/cpp/warn-trigraphs-3.c
gcc/testsuite/gcc.dg/cpp/warn-trigraphs-4.c
gcc/testsuite/gcc.dg/cpp/warn-undef-2.c
gcc/testsuite/gcc.dg/cpp/warn-unused-macros-2.c
gcc/testsuite/gcc.dg/cpp/warn-variadic-2.c
gcc/testsuite/gcc.dg/cpp/warning-directive-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp/warning-directive-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp/warning-directive-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp/warning-directive-4.c [new file with mode: 0644]
gcc/testsuite/gfortran.dg/warning-directive-2.F90
libcpp/ChangeLog

index 2900046..69882e4 100644 (file)
@@ -1,3 +1,25 @@
+2010-04-07  Simon Baldwin  <simonb@google.com>
+
+       * diagnostic.h (diagnostic_override_option_index): New macro to
+       set a diagnostic's option_index.
+       * c-tree.h (c_cpp_error): Add warning reason argument.
+       * opts.c (_warning_as_error_callback): New.
+       (register_warning_as_error_callback): Store callback for
+       warnings enabled via enable_warning_as_error.
+       (enable_warning_as_error): Call callback, minor code tidy.
+       * opts.h (register_warning_as_error_callback): Declare.
+       * c-opts.c (warning_as_error_callback): New, set cpp_opts flag in
+       response to -Werror=.
+       (c_common_init_options): Register warning_as_error_callback in opts.c.
+       * common.opt: Add -Wno-cpp option.
+       * c-common.c (struct reason_option_codes_t): Map cpp warning
+       reason codes to gcc option indexes.
+       * (c_option_controlling_cpp_error): New function, lookup the gcc
+       option index for a cpp warning reason code.
+       * (c_cpp_error): Add warning reason argument, call
+       c_option_controlling_cpp_error for diagnostic_override_option_index.
+       * doc/invoke.texi: Document -Wno-cpp.
+
 2010-04-07  Richard Guenther  <rguenther@suse.de>
 
        * ipa-reference.c (mark_load): Use get_base_address.
index 2b1aa30..6502b89 100644 (file)
@@ -1,3 +1,8 @@
+2010-04-07  Simon Baldwin  <simonb@google.com>
+
+       * cpp.c (cb_cpp_error): Add warning reason argument, set a value
+       for diagnostic_override_option_index if CPP_W_WARNING_DIRECTIVE.
+
 2010-04-07  Richard Guenther  <rguenther@suse.de>
 
        * options.c (gfc_init_options): Do not set.
index d5a9fb3..bd8d6ad 100644 (file)
@@ -2448,6 +2448,20 @@ register_warning_as_error_callback (void (*callback) (int))
   warning_as_error_callback = callback;
 }
 
+
+/* Callback function, called when -Werror= enables a warning.  */
+
+static void (*warning_as_error_callback) (int) = NULL;
+
+/* Register a callback for enable_warning_as_error calls.  */
+
+void
+register_warning_as_error_callback (void (*callback) (int))
+{
+  gcc_assert (warning_as_error_callback == NULL || callback == NULL);
+  warning_as_error_callback = callback;
+}
+
 /* Enable a warning option as an error.  This is used by -Werror= and
    also by legacy Werror-implicit-function-declaration.  */
 
@@ -2475,8 +2489,8 @@ enable_warning_as_error (const char *arg, int value, unsigned int lang_mask)
          const struct cl_option * const option = cl_options + option_index;
 
          /* -Werror=foo implies -Wfoo.  */
-         if (option->var_type == CLVC_BOOLEAN)
-           handle_option (option_index, value, arg, lang_mask, (int)kind);
+         if (option->var_type == CLVC_BOOLEAN && option->flag_var)
+           *(int *) option->flag_var = 1;
 
          if (warning_as_error_callback)
            warning_as_error_callback (option_index);
index af3c6e2..54f57d1 100644 (file)
@@ -103,9 +103,8 @@ extern void prune_options (int *argcp, char ***argvp);
 extern void decode_options (unsigned int argc, const char **argv);
 extern int option_enabled (int opt_idx);
 extern bool get_option_state (int, struct cl_option_state *);
-extern void set_option (int opt_index, int value, const char *arg, int);
-bool handle_option (int opt_index, int value, const char *arg,
-                   unsigned int lang_mask, int kind);
+extern void set_option (const struct cl_option *, int, const char *);
+
 extern void register_warning_as_error_callback (void (*callback) (int));
 extern void enable_warning_as_error (const char *arg, int value,
                                     unsigned int lang_mask);
index efec5a8..35505d3 100644 (file)
@@ -1,6 +1,47 @@
-2010-04-07  Iain Sandoe <iains@gcc.gnu.org>
+2010-04-07  Simon Baldwin  <simonb@google.com>
+
+       * gcc.dg/cpp/warn-undef-2.c: New.
+       * gcc.dg/cpp/warn-traditional-2.c: New.
+       * gcc.dg/cpp/warn-comments-2.c: New.
+       * gcc.dg/cpp/warning-directive-1.c: New.
+       * gcc.dg/cpp/warn-long-long.c: New.
+       * gcc.dg/cpp/warn-traditional.c: New.
+       * gcc.dg/cpp/warn-variadic-2.c: New.
+       * gcc.dg/cpp/warn-undef.c: New.
+       * gcc.dg/cpp/warn-normalized-1.c: New.
+       * gcc.dg/cpp/warning-directive-2.c: New.
+       * gcc.dg/cpp/warn-long-long-2.c: New.
+       * gcc.dg/cpp/warn-variadic.c: New.
+       * gcc.dg/cpp/warn-normalized-2.c: New.
+       * gcc.dg/cpp/warning-directive-3.c: New.
+       * gcc.dg/cpp/warn-deprecated-2.c: New.
+       * gcc.dg/cpp/warn-trigraphs-1.c: New.
+       * gcc.dg/cpp/warn-multichar-2.c: New.
+       * gcc.dg/cpp/warn-normalized-3.c: New.
+       * gcc.dg/cpp/warning-directive-4.c: New.
+       * gcc.dg/cpp/warn-unused-macros.c: New.
+       * gcc.dg/cpp/warn-trigraphs-2.c: New.
+       * gcc.dg/cpp/warn-cxx-compat-2.c: New.
+       * gcc.dg/cpp/warn-cxx-compat.c: New.
+       * gcc.dg/cpp/warn-redefined.c: New.
+       * gcc.dg/cpp/warn-trigraphs-3.c: New.
+       * gcc.dg/cpp/warn-unused-macros-2.c: New.
+       * gcc.dg/cpp/warn-deprecated.c: New.
+       * gcc.dg/cpp/warn-trigraphs-4.c: New.
+       * gcc.dg/cpp/warn-redefined-2.c: New.
+       * gcc.dg/cpp/warn-comments.c: New.
+       * gcc.dg/cpp/warn-multichar.c: New.
+       * g++.dg/cpp/warning-directive-1.C: New.
+       * g++.dg/cpp/warning-directive-2.C: New.
+       * g++.dg/cpp/warning-directive-3.C: New.
+       * g++.dg/cpp/warning-directive-4.C: New.
+       * gfortran.dg/warning-directive-1.F90: New.
+       * gfortran.dg/warning-directive-3.F90: New.
+       * gfortran.dg/warning-directive-2.F90: New.
+       * gfortran.dg/warning-directive-4.F90: New.
 
-       PR objc++/23716
+2010-04-07  Iain Sandoe <iains@gcc.gnu.org>
+PR objc++/23716
        * obj-c++.dg/comp-types-10.mm: Remove XFAIL.
 
 2010-04-07  Jason Merrill  <jason@redhat.com>
diff --git a/gcc/testsuite/g++.dg/cpp/warning-directive-1.C b/gcc/testsuite/g++.dg/cpp/warning-directive-1.C
new file mode 100644 (file)
index 0000000..1ce18c6
--- /dev/null
@@ -0,0 +1,4 @@
+// { dg-do preprocess }
+// { dg-options "-fdiagnostics-show-option" }
+
+#warning "Printed"  // { dg-warning "\"Printed\" .-Wcpp." }
diff --git a/gcc/testsuite/g++.dg/cpp/warning-directive-2.C b/gcc/testsuite/g++.dg/cpp/warning-directive-2.C
new file mode 100644 (file)
index 0000000..abd6427
--- /dev/null
@@ -0,0 +1,4 @@
+// { dg-do preprocess }
+// { dg-options "-fdiagnostics-show-option -Werror=cpp" }
+
+#warning "Printed"  // { dg-error "\"Printed\" .-Wcpp." }
diff --git a/gcc/testsuite/g++.dg/cpp/warning-directive-3.C b/gcc/testsuite/g++.dg/cpp/warning-directive-3.C
new file mode 100644 (file)
index 0000000..8ed66c6
--- /dev/null
@@ -0,0 +1,4 @@
+// { dg-do preprocess }
+// { dg-options "-fdiagnostics-show-option -Werror -Wno-error=cpp" }
+
+#warning "Printed"  // { dg-warning "\"Printed\" .-Wcpp." }
diff --git a/gcc/testsuite/g++.dg/cpp/warning-directive-4.C b/gcc/testsuite/g++.dg/cpp/warning-directive-4.C
new file mode 100644 (file)
index 0000000..a5db1b4
--- /dev/null
@@ -0,0 +1,4 @@
+// { dg-do preprocess }
+// { dg-options "-fdiagnostics-show-option -Wno-cpp" }
+
+#warning "Not printed"  // { dg-bogus "." }
index 17cc9f1..5a17f2b 100644 (file)
@@ -1,7 +1,7 @@
 // { dg-do preprocess }
 // { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=comments" }
-/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
-/* /* */  // { dg-error "\"\.\*\" within comment .-Werror=comments." }
+
+/* /* */  // { dg-error "\"\.\*\" within comment .-Wcomments." }
 
 // \
-          // { dg-error "multi-line comment .-Werror=comments." "multi-line" { target *-*-* } 6 }
+          // { dg-error "multi-line comment .-Wcomments." "multi-line" { target *-*-* } 6 }
index 69c4cfa..6bf7d55 100644 (file)
@@ -1,4 +1,4 @@
 // { dg-do preprocess }
 // { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=c++-compat" }
-/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
-#define not !  // { dg-error "identifier \"not\" is a special operator name in C\\+\\+ .-Werror=c\\+\\+-compat." }
+
+#define not !  // { dg-error "identifier \"not\" is a special operator name in C\\+\\+ .-Wc\\+\\+-compat." }
index 8bd608a..b9cfffb 100644 (file)
@@ -1,7 +1,7 @@
 // { dg-do preprocess }
 // { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=deprecated" }
-/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
-#assert x(x)  // { dg-error "#assert is a deprecated GCC extension .-Werror=deprecated." }
 
-#if #x(x)     // { dg-error "assertions are a deprecated extension .-Werror=deprecated." }
+#assert x(x)  // { dg-error "#assert is a deprecated GCC extension .-Wdeprecated." }
+
+#if #x(x)     // { dg-error "assertions are a deprecated extension .-Wdeprecated." }
 #endif
index 7b074a3..11eb5fb 100644 (file)
@@ -1,6 +1,6 @@
 // { dg-do preprocess }
 // { dg-options "-std=gnu99 -fdiagnostics-show-option -Wtraditional -Werror=long-long" }
-/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
-#if 0LL  // { dg-error "traditional C rejects the \"LL\" suffix .-Werror=long-long." }
-         // { dg-error "use of C99 long long integer constant .-Werror=long-long." "use long long" { target *-*-* } 4 }
+
+#if 0LL  // { dg-error "traditional C rejects the \"LL\" suffix .-Wlong-long." }
+         // { dg-error "use of C99 long long integer constant .-Wlong-long." "use long long" { target *-*-* } 4 }
 #endif
index f9fd4f6..31d33bb 100644 (file)
@@ -1,5 +1,5 @@
 // { dg-do preprocess }
 // { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=multichar" }
-/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
-#if 'abc'  // { dg-error "multi-character character constant .-Werror=multichar." }
+
+#if 'abc'  // { dg-error "multi-character character constant .-Wmultichar." }
 #endif
index 24eaea0..380c670 100644 (file)
@@ -1,5 +1,5 @@
 // { dg-do preprocess }
 // { dg-options "-std=gnu99 -fdiagnostics-show-option -fextended-identifiers -Werror=normalized=" }
-/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
+
         // { dg-prune-output ".*-Werror=normalized=: Set -Wnormalized=nfc.*" }
-\u0F43  // { dg-error "`.U00000f43' is not in NFC .-Werror=normalized=." }
+\u0F43  // { dg-error "`.U00000f43' is not in NFC .-Wnormalized=." }
index e6b209c..83cc3df 100644 (file)
@@ -1,12 +1,12 @@
 // { dg-do preprocess }
 // { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=builtin-macro-redefined" }
-/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
+
 #ifndef __TIME__
 #error "__TIME__ builtin is not defined"
 // { dg-bogus "__TIME__ builtin is not defined" "no-time" { target *-*-* } 5 }
 #endif
 
-#define __TIME__ "X"  // { dg-error "\"__TIME__\" redefined .-Werror=builtin-macro-redefined." }
+#define __TIME__ "X"  // { dg-error "\"__TIME__\" redefined .-Wbuiltin-macro-redefined." }
 
 #define __TIME__ "Y"  // { dg-bogus "-Wbuiltin-macro-redefined" }
                       // { dg-warning "\"__TIME__\" redefined" "not-builtin-1" { target *-*-* } 11 }
index 05477af..cb5f690 100644 (file)
@@ -1,23 +1,23 @@
 // { dg-do compile }
 // { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=traditional -Wno-deprecated -Wno-long-long" }
-/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
-#assert x(x)         // { dg-error "suggest hiding #assert from traditional C with an indented # .-Werror=traditional." }
 
- #define X X         // { dg-error "traditional C ignores #define with the # indented .-Werror=traditional." }
+#assert x(x)         // { dg-error "suggest hiding #assert from traditional C with an indented # .-Wtraditional." }
+
+ #define X X         // { dg-error "traditional C ignores #define with the # indented .-Wtraditional." }
 
 #if 0
-#elif 1              // { dg-error "suggest not using #elif in traditional C .-Werror=traditional." }
+#elif 1              // { dg-error "suggest not using #elif in traditional C .-Wtraditional." }
 #endif
 
 #define f(X) X
-int f;               // { dg-error "function-like macro \"f\" must be used with arguments in traditional C .-Werror=traditional." }
+int f;               // { dg-error "function-like macro \"f\" must be used with arguments in traditional C .-Wtraditional." }
 
-#if 0U               // { dg-error "traditional C rejects the \"U\" suffix .-Werror=traditional." }
+#if 0U               // { dg-error "traditional C rejects the \"U\" suffix .-Wtraditional." }
 #endif
 
-#if +1               // { dg-error " traditional C rejects the unary plus operator .-Werror=traditional." }
+#if +1               // { dg-error " traditional C rejects the unary plus operator .-Wtraditional." }
 #endif
 
-char *x = "\x0";     // { dg-error "the meaning of '.x' is different in traditional C .-Werror=traditional." }
-char *y = "\a";      // { dg-error "the meaning of '.a' is different in traditional C .-Werror=traditional." }
-char *z = "\u0F43";  // { dg-error "the meaning of '.u' is different in traditional C .-Werror=traditional." }
+char *x = "\x0";     // { dg-error "the meaning of '.x' is different in traditional C .-Wtraditional." }
+char *y = "\a";      // { dg-error "the meaning of '.a' is different in traditional C .-Wtraditional." }
+char *z = "\u0F43";  // { dg-error "the meaning of '.u' is different in traditional C .-Wtraditional." }
index e7537c8..a993e2a 100644 (file)
@@ -1,4 +1,4 @@
 // { dg-do preprocess }
 // { dg-options "-std=gnu99 -fdiagnostics-show-option -trigraphs -Werror=trigraphs" }
-/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
-??=  // { dg-error "trigraph \\?\\?= converted to # .-Werror=trigraphs." }
+
+??=  // { dg-error "trigraph \\?\\?= converted to # .-Wtrigraphs." }
index d8333d4..240ae0f 100644 (file)
@@ -1,4 +1,4 @@
 // { dg-do preprocess }
 // { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=trigraphs" }
-/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
-??=  // { dg-error "trigraph \\?\\?= ignored, use -trigraphs to enable .-Werror=trigraphs." }
+
+??=  // { dg-error "trigraph \\?\\?= ignored, use -trigraphs to enable .-Wtrigraphs." }
index 15fdde9..4eb80e0 100644 (file)
@@ -1,5 +1,5 @@
 // { dg-do preprocess }
 // { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=undef" }
-/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
-#if x  // { dg-error "\"x\" is not defined .-Werror=undef." }
+
+#if x  // { dg-error "\"x\" is not defined .-Wundef." }
 #endif
index d7fe145..58eeebf 100644 (file)
@@ -1,4 +1,4 @@
 // { dg-do preprocess }
 // { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=unused-macros" }
-/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
-#define X X  // { dg-error "macro \"X\" is not used .-Werror=unused-macros." }
+
+#define X X  // { dg-error "macro \"X\" is not used .-Wunused-macros." }
index 1a266cd..f43d96a 100644 (file)
@@ -1,6 +1,6 @@
 /* { dg-do preprocess } */
 /* { dg-options "-ansi -fdiagnostics-show-option -pedantic -Werror=variadic-macros" } */
-/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
-#define F(...) X   /* { dg-error "anonymous variadic macros were introduced in C99 .-Werror=variadic-macros." } */
 
-#define G(X...) X  /* { dg-error "ISO C does not permit named variadic macros .-Werror=variadic-macros." } */
+#define F(...) X   /* { dg-error "anonymous variadic macros were introduced in C99 .-Wvariadic-macros." } */
+
+#define G(X...) X  /* { dg-error "ISO C does not permit named variadic macros .-Wvariadic-macros." } */
diff --git a/gcc/testsuite/gcc.dg/cpp/warning-directive-1.c b/gcc/testsuite/gcc.dg/cpp/warning-directive-1.c
new file mode 100644 (file)
index 0000000..cb4bd32
--- /dev/null
@@ -0,0 +1,4 @@
+// { dg-do preprocess }
+// { dg-options "-std=gnu99 -fdiagnostics-show-option" }
+
+#warning "Printed"  // { dg-warning "\"Printed\" .-Wcpp." }
diff --git a/gcc/testsuite/gcc.dg/cpp/warning-directive-2.c b/gcc/testsuite/gcc.dg/cpp/warning-directive-2.c
new file mode 100644 (file)
index 0000000..0889803
--- /dev/null
@@ -0,0 +1,4 @@
+// { dg-do preprocess }
+// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=cpp" }
+
+#warning "Printed"  // { dg-error "\"Printed\" .-Wcpp." }
diff --git a/gcc/testsuite/gcc.dg/cpp/warning-directive-3.c b/gcc/testsuite/gcc.dg/cpp/warning-directive-3.c
new file mode 100644 (file)
index 0000000..48c97f3
--- /dev/null
@@ -0,0 +1,4 @@
+// { dg-do preprocess }
+// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror -Wno-error=cpp" }
+
+#warning "Printed"  // { dg-warning "\"Printed\" .-Wcpp." }
diff --git a/gcc/testsuite/gcc.dg/cpp/warning-directive-4.c b/gcc/testsuite/gcc.dg/cpp/warning-directive-4.c
new file mode 100644 (file)
index 0000000..2eb1017
--- /dev/null
@@ -0,0 +1,4 @@
+// { dg-do preprocess }
+// { dg-options "-std=gnu99 -fdiagnostics-show-option -Wno-cpp" }
+
+#warning "Not printed"  // { dg-bogus "." }
index fa9460a..75b78bf 100644 (file)
@@ -1,5 +1,5 @@
 ! { dg-do preprocess }
 ! { dg-options "-std=f95 -fdiagnostics-show-option -Werror=cpp" }
-! { dg-warning "some warnings being treated as errors" "" {target "*-*-*"} 0 } 
+
 #warning "Printed"
-! { dg-error "\"Printed\" .-Werror=cpp." "" { target *-*-* } 4 }
+! { dg-error "\"Printed\" .-Wcpp." "" { target *-*-* } 4 }
index b55d255..7762099 100644 (file)
@@ -1,3 +1,45 @@
+2010-04-07  Simon Baldwin  <simonb@google.com>
+
+       * directives.c (do_diagnostic): Add warning reason argument,
+       call appropriate error reporting function for code.
+       (directive_diagnostics): Call specific warning functions with
+       warning reason where appropriate.
+       (do_error, do_warning, do_pragma_dependency): Add warning reason
+       argument to do_diagnostic calls.
+       * macro.c (_cpp_warn_if_unused_macro, enter_macro_context,
+       _cpp_create_definition): Call specific warning functions with
+       warning reason where appropriate.
+       * Makefile.in: Add new diagnostic functions to gettext translations.
+       * include/cpplib.h (struct cpp_callbacks): Add warning reason code
+       to error callback.
+       (CPP_DL_WARNING, CPP_DL_WARNING_SYSHDR, CPP_DL_PEDWARN, CPP_DL_ERROR,
+       CPP_DL_ICE, CPP_DL_NOTE, CPP_DL_FATAL): Replace macros with enums.
+       (CPP_W_NONE, CPP_W_DEPRECATED, CPP_W_COMMENTS,
+       CPP_W_MISSING_INCLUDE_DIRS, CPP_W_TRIGRAPHS, CPP_W_MULTICHAR,
+       CPP_W_TRADITIONAL, CPP_W_LONG_LONG, CPP_W_ENDIF_LABELS,
+       CPP_W_NUM_SIGN_CHANGE, CPP_W_VARIADIC_MACROS,
+       CPP_W_BUILTIN_MACRO_REDEFINED, CPP_W_DOLLARS, CPP_W_UNDEF,
+       CPP_W_UNUSED_MACROS, CPP_W_CXX_OPERATOR_NAMES, CPP_W_NORMALIZE,
+       CPP_W_INVALID_PCH, CPP_W_WARNING_DIRECTIVE): New enums for cpp
+       warning reason codes.
+       (cpp_warning, cpp_pedwarning, cpp_warning_syshdr,
+       cpp_warning_with_line, cpp_pedwarning_with_line,
+       cpp_warning_with_line_syshdr): New specific error reporting functions.
+       * pch.c (cpp_valid_state): Call specific warning functions with
+       warning reason where appropriate.
+       * errors.c (cpp_diagnostic, cpp_diagnostic_with_line): New central
+       diagnostic handlers.
+       (cpp_warning, cpp_pedwarning, cpp_warning_syshdr,
+       cpp_warning_with_line, cpp_pedwarning_with_line,
+       cpp_warning_with_line_syshdr): New specific error reporting functions.
+       * expr.c (cpp_classify_number, eval_token, num_unary_op): Call
+       specific warning functions with warning reason where appropriate.
+       * lex.c (_cpp_process_line_notes, _cpp_skip_block_comment,
+       warn_about_normalization, lex_identifier_intern, lex_identifier,
+       _cpp_lex_direct): Ditto.
+       * charset.c (_cpp_valid_ucn, convert_hex, convert_escape,
+       narrow_str_to_charconst): Ditto.
+
 2010-04-06  Jakub Jelinek  <jakub@redhat.com>
 
        PR preprocessor/43642