gcc/ChangeLog:
authormanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 9 Sep 2014 22:17:54 +0000 (22:17 +0000)
committermanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 9 Sep 2014 22:17:54 +0000 (22:17 +0000)
2014-09-09  Manuel López-Ibáñez  <manu@gcc.gnu.org>

* opth-gen.awk: Generate mapping from cpp message reasons to the
options that enable them.
* doc/options.texi (CppReason): Document.

gcc/c-family/ChangeLog:

2014-09-09  Manuel López-Ibáñez  <manu@gcc.gnu.org>

* c.opt: Add CppReason to various flags.
(Wdate-time): Re-sort.
* c-common.c: Include c-common.h earlier.
(struct reason_option_codes_t): Delete.
(c_option_controlling_cpp_error): Prefix global type and struct
with cpp_.

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

gcc/ChangeLog
gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/c-family/c.opt
gcc/doc/options.texi
gcc/opth-gen.awk

index de1d1a9..f7a5401 100644 (file)
@@ -1,5 +1,11 @@
 2014-09-09  Manuel López-Ibáñez  <manu@gcc.gnu.org>
 
+       * opth-gen.awk: Generate mapping from cpp message reasons to the
+       options that enable them.
+       * doc/options.texi (CppReason): Document.
+
+2014-09-09  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+
        * doc/invoke.texi (Wnormalized=): Update.
 
 2014-09-09  Segher Boessenkool  <segher@kernel.crashing.org>
index 81e253d..a09ce72 100644 (file)
@@ -1,5 +1,14 @@
 2014-09-09  Manuel López-Ibáñez  <manu@gcc.gnu.org>
 
+       * c.opt: Add CppReason to various flags.
+       (Wdate-time): Re-sort.
+       * c-common.c: Include c-common.h earlier.
+       (struct reason_option_codes_t): Delete.
+       (c_option_controlling_cpp_error): Prefix global type and struct
+       with cpp_.
+
+2014-09-09  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+
        * c.opt (Wnormalized): New.
        (Wnormalized=): Use Enum and Reject Negative.
        * c-opts.c (c_common_handle_option): Do not handle Wnormalized here.
index baa8415..39be956 100644 (file)
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
+#include "c-common.h"
 #include "tm.h"
 #include "intl.h"
 #include "tree.h"
@@ -32,7 +33,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "trans-mem.h"
 #include "flags.h"
 #include "c-pragma.h"
-#include "c-common.h"
 #include "c-objc.h"
 #include "tm_p.h"
 #include "obstack.h"
@@ -9666,47 +9666,15 @@ c_parse_error (const char *gmsgid, enum cpp_ttype token_type,
 #undef catenate_messages
 }
 
-/* Mapping for cpp message reasons to the options that enable them.  */
-
-struct reason_option_codes_t
-{
-  const int reason;            /* cpplib message reason.  */
-  const int option_code;       /* gcc option that controls this message.  */
-};
-
-static const struct reason_option_codes_t option_codes[] = {
-  {CPP_W_BUILTIN_MACRO_REDEFINED,      OPT_Wbuiltin_macro_redefined},
-  {CPP_W_C90_C99_COMPAT,                OPT_Wc90_c99_compat},
-  {CPP_W_COMMENTS,                     OPT_Wcomment},
-  {CPP_W_CXX_OPERATOR_NAMES,           OPT_Wc___compat},
-  {CPP_W_DATE_TIME,                    OPT_Wdate_time},
-  {CPP_W_DEPRECATED,                   OPT_Wdeprecated},
-  {CPP_W_ENDIF_LABELS,                 OPT_Wendif_labels},
-  {CPP_W_INVALID_PCH,                  OPT_Winvalid_pch},
-  {CPP_W_LITERAL_SUFFIX,               OPT_Wliteral_suffix},
-  {CPP_W_LONG_LONG,                    OPT_Wlong_long},
-  {CPP_W_MISSING_INCLUDE_DIRS,          OPT_Wmissing_include_dirs},
-  {CPP_W_MULTICHAR,                    OPT_Wmultichar},
-  {CPP_W_NORMALIZE,                    OPT_Wnormalized_},
-  {CPP_W_PEDANTIC,                      OPT_Wpedantic},
-  {CPP_W_TRADITIONAL,                  OPT_Wtraditional},
-  {CPP_W_TRIGRAPHS,                    OPT_Wtrigraphs},
-  {CPP_W_UNDEF,                                OPT_Wundef},
-  {CPP_W_UNUSED_MACROS,                        OPT_Wunused_macros},
-  {CPP_W_VARIADIC_MACROS,              OPT_Wvariadic_macros},
-  {CPP_W_WARNING_DIRECTIVE,            OPT_Wcpp},
-  {CPP_W_NONE,                         0}
-};
-
 /* Return the gcc option code associated with the reason for a cpp
    message, or 0 if none.  */
 
 static int
 c_option_controlling_cpp_error (int reason)
 {
-  const struct reason_option_codes_t *entry;
+  const struct cpp_reason_option_codes_t *entry;
 
-  for (entry = option_codes; entry->reason != CPP_W_NONE; entry++)
+  for (entry = cpp_reason_option_codes; entry->reason != CPP_W_NONE; entry++)
     {
       if (entry->reason == reason)
        return entry->option_code;
index 11703b9..5e6182b 100644 (file)
@@ -292,11 +292,11 @@ C ObjC C++ ObjC++ Var(warn_bool_compare) Warning LangEnabledBy(C ObjC C++ ObjC++
 Warn about boolean expression compared with an integer value different from true/false
 
 Wbuiltin-macro-redefined
-C ObjC C++ ObjC++ CPP(warn_builtin_macro_redefined) Var(cpp_warn_builtin_macro_redefined) Init(1) Warning
+C ObjC C++ ObjC++ CPP(warn_builtin_macro_redefined) CppReason(CPP_W_BUILTIN_MACRO_REDEFINED) Var(cpp_warn_builtin_macro_redefined) Init(1) Warning
 Warn when a built-in preprocessor macro is undefined or redefined
 
 Wc90-c99-compat
-C ObjC CPP(cpp_warn_c90_c99_compat) Var(warn_c90_c99_compat) Init(-1) Warning
+C ObjC CPP(cpp_warn_c90_c99_compat) CppReason(CPP_W_C90_C99_COMPAT) Var(warn_c90_c99_compat) Init(-1) Warning
 Warn about features not present in ISO C90, but present in ISO C99
 
 Wc99-c11-compat
@@ -304,7 +304,7 @@ C ObjC Var(warn_c99_c11_compat) Init(-1) Warning
 Warn about features not present in ISO C99, but present in ISO C11
 
 Wc++-compat
-C ObjC Var(warn_cxx_compat) CPP(warn_cxx_operator_names) Init(0) Warning
+C ObjC Var(warn_cxx_compat) CPP(warn_cxx_operator_names) CppReason(CPP_W_CXX_OPERATOR_NAMES) Init(0) Warning
 Warn about C constructs that are not in the common subset of C and C++
 
 Wc++0x-compat
@@ -328,7 +328,7 @@ C ObjC C++ ObjC++ Var(warn_clobbered) Warning EnabledBy(Wextra)
 Warn about variables that might be changed by \"longjmp\" or \"vfork\"
 
 Wcomment
-C ObjC C++ ObjC++ CPP(warn_comments) Var(cpp_warn_comment) Init(0) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall)
+C ObjC C++ ObjC++ CPP(warn_comments) CppReason(CPP_W_COMMENTS) Var(cpp_warn_comment) Init(0) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall)
 Warn about possibly nested block comments, and C++ comments spanning more than one physical line
 
 Wcomments
@@ -347,10 +347,18 @@ Wconversion-null
 C++ ObjC++ Var(warn_conversion_null) Init(1) Warning
 Warn for converting NULL from/to a non-pointer type
 
+Wcpp
+C ObjC C++ ObjC++ CppReason(CPP_W_WARNING_DIRECTIVE)
+; Documented in common.opt
+
 Wctor-dtor-privacy
 C++ ObjC++ Var(warn_ctor_dtor_privacy) Warning
 Warn when all constructors and destructors are private
 
+Wdate-time
+C ObjC C++ ObjC++ CPP(warn_date_time) CppReason(CPP_W_DATE_TIME) Var(cpp_warn_date_time) Init(0) Warning
+Warn about __TIME__, __DATE__ and __TIMESTAMP__ usage
+
 Wdeclaration-after-statement
 C ObjC Var(warn_declaration_after_statement) Init(-1) Warning
 Warn when a declaration is found after a statement
@@ -368,7 +376,7 @@ LangEnabledBy(C++ ObjC++,Weffc++)
 ;
 
 Wdeprecated
-C C++ ObjC ObjC++ CPP(cpp_warn_deprecated) Var(warn_deprecated) Init(1) Warning
+C C++ ObjC ObjC++ CPP(cpp_warn_deprecated) CppReason(CPP_W_DEPRECATED) Var(warn_deprecated) Init(1) Warning
 Warn if a deprecated compiler feature, class, method, or field is used
 
 Wdesignated-init
@@ -392,7 +400,7 @@ C ObjC C++ ObjC++ Var(warn_empty_body) Warning EnabledBy(Wextra)
 Warn about an empty body in an if or else statement
 
 Wendif-labels
-C ObjC C++ ObjC++ CPP(warn_endif_labels) Var(cpp_warn_endif_labels) Init(1) Warning LangEnabledBy(C ObjC C++ ObjC++,Wpedantic)
+C ObjC C++ ObjC++ CPP(warn_endif_labels) CppReason(CPP_W_ENDIF_LABELS) Var(cpp_warn_endif_labels) Init(1) Warning LangEnabledBy(C ObjC C++ ObjC++,Wpedantic)
 Warn about stray tokens after #elif and #endif
 
 Wenum-compare
@@ -503,7 +511,7 @@ C++ ObjC++ Var(warn_invalid_offsetof) Init(1) Warning
 Warn about invalid uses of the \"offsetof\" macro
 
 Winvalid-pch
-C ObjC C++ ObjC++ CPP(warn_invalid_pch) Var(cpp_warn_invalid_pch) Init(0) Warning
+C ObjC C++ ObjC++ CPP(warn_invalid_pch) CppReason(CPP_W_INVALID_PCH) Var(cpp_warn_invalid_pch) Init(0) Warning
 Warn about PCH files that are found but not used
 
 Wjump-misses-init
@@ -511,7 +519,7 @@ C ObjC Var(warn_jump_misses_init) Warning LangEnabledby(C ObjC,Wc++-compat)
 Warn when a jump misses a variable initialization
 
 Wliteral-suffix
-C++ ObjC++ CPP(warn_literal_suffix) Var(cpp_warn_literal_suffix) Init(1) Warning
+C++ ObjC++ CPP(warn_literal_suffix) CppReason(CPP_W_LITERAL_SUFFIX) Var(cpp_warn_literal_suffix) Init(1) Warning
 Warn when a string or character literal is followed by a ud-suffix which does not begin with an underscore.
 
 Wlogical-op
@@ -523,7 +531,7 @@ C ObjC C++ ObjC++ Var(warn_logical_not_paren) Warning LangEnabledBy(C ObjC C++ O
 Warn when logical not is used on the left hand side operand of a comparison
 
 Wlong-long
-C ObjC C++ ObjC++ CPP(cpp_warn_long_long) Var(warn_long_long) Init(-1) Warning LangEnabledBy(C ObjC,Wc90-c99-compat)
+C ObjC C++ ObjC++ CPP(cpp_warn_long_long) CppReason(CPP_W_LONG_LONG) Var(warn_long_long) Init(-1) Warning LangEnabledBy(C ObjC,Wc90-c99-compat)
 Do not warn about using \"long long\" when -pedantic
 
 Wmain
@@ -583,7 +591,7 @@ C ObjC C++ ObjC++ Alias(Wsuggest-attribute=format)
 ;
 
 Wmissing-include-dirs
-C ObjC C++ ObjC++ CPP(warn_missing_include_dirs) Var(cpp_warn_missing_include_dirs) Init(0) Warning
+C ObjC C++ ObjC++ CPP(warn_missing_include_dirs) CppReason(CPP_W_MISSING_INCLUDE_DIRS) Var(cpp_warn_missing_include_dirs) Init(0) Warning
 Warn about user-specified include directories that do not exist
 
 Wmissing-parameter-type
@@ -598,7 +606,7 @@ Wmudflap
 C ObjC C++ ObjC++ Ignore Warn(switch %qs is no longer supported)
 
 Wmultichar
-C ObjC C++ ObjC++ CPP(warn_multichar) Var(cpp_warn_multichar) Init(0) Warning
+C ObjC C++ ObjC++ CPP(warn_multichar) CppReason(CPP_W_MULTICHAR) Var(cpp_warn_multichar) Init(0) Warning
 Warn about use of multi-character character constants
 
 Wnarrowing
@@ -638,7 +646,7 @@ C ObjC C++ ObjC++ Alias(Wnormalized=,nfc,none)
 ;
 
 Wnormalized=
-C ObjC C++ ObjC++ RejectNegative Joined Warning CPP(warn_normalize) Init(normalized_C) Var(cpp_warn_normalize) Enum(cpp_normalize_level)
+C ObjC C++ ObjC++ RejectNegative Joined Warning CPP(warn_normalize) CppReason(CPP_W_NORMALIZE) Init(normalized_C) Var(cpp_warn_normalize) Enum(cpp_normalize_level)
 -Wnormalized=<none|id|nfc|nfkc>        Warn about non-normalised Unicode strings
 
 ; Required for these enum values.
@@ -697,7 +705,7 @@ C ObjC C++ ObjC++ Var(warn_parentheses) Warning LangEnabledBy(C ObjC C++ ObjC++,
 Warn about possibly missing parentheses
 
 Wpedantic
-C ObjC C++ ObjC++ CPP(cpp_pedantic) Warning
+C ObjC C++ ObjC++ CPP(cpp_pedantic) CppReason(CPP_W_PEDANTIC) Warning
 ; Documented in common.opt
 
 Wpmf-conversions
@@ -724,10 +732,6 @@ Wpragmas
 C ObjC C++ ObjC++ Var(warn_pragmas) Init(1) Warning
 Warn about misuses of pragmas
 
-Wdate-time
-C ObjC C++ ObjC++ CPP(warn_date_time) Var(cpp_warn_date_time) Init(0) Warning
-Warn about __TIME__, __DATE__ and __TIMESTAMP__ usage
-
 Wproperty-assign-default
 ObjC ObjC++ Var(warn_property_assign_default) Init(1) Warning
 Warn if a property for an Objective-C object has no assign semantics specified
@@ -809,7 +813,7 @@ C ObjC C++ ObjC++ Warning
 ; Documented in common.opt
 
 Wtraditional
-C ObjC CPP(cpp_warn_traditional) Var(warn_traditional) Init(0) Warning
+C ObjC CPP(cpp_warn_traditional) CppReason(CPP_W_TRADITIONAL) Var(warn_traditional) Init(0) Warning
 Warn about features not present in traditional C
 
 Wtraditional-conversion
@@ -817,7 +821,7 @@ C ObjC Var(warn_traditional_conversion) Warning
 Warn of prototypes causing type conversions different from what would happen in the absence of prototype
 
 Wtrigraphs
-C ObjC C++ ObjC++ CPP(warn_trigraphs) Var(cpp_warn_trigraphs) Init(2) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall)
+C ObjC C++ ObjC++ CPP(warn_trigraphs) CppReason(CPP_W_TRIGRAPHS) Var(cpp_warn_trigraphs) Init(2) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall)
 Warn if trigraphs are encountered that might affect the meaning of the program
 
 Wundeclared-selector
@@ -825,7 +829,7 @@ ObjC ObjC++ Var(warn_undeclared_selector) Warning
 Warn about @selector()s without previously declared methods
 
 Wundef
-C ObjC C++ ObjC++ CPP(warn_undef) Var(cpp_warn_undef) Init(0) Warning
+C ObjC C++ ObjC++ CPP(warn_undef) CppReason(CPP_W_UNDEF) Var(cpp_warn_undef) Init(0) Warning
 Warn if an undefined macro is used in an #if directive
 
 Wuninitialized
@@ -853,7 +857,7 @@ C ObjC C++ ObjC++ Var(warn_unused_local_typedefs) Warning EnabledBy(Wunused)
 Warn when typedefs locally defined in a function are not used
 
 Wunused-macros
-C ObjC C++ ObjC++ Var(cpp_warn_unused_macros) Warning
+C ObjC C++ ObjC++ CppReason(CPP_W_UNUSED_MACROS) Var(cpp_warn_unused_macros) Warning
 Warn about macros defined in the main file that are not used
 
 Wunused-result
@@ -861,7 +865,7 @@ C ObjC C++ ObjC++ Var(warn_unused_result) Init(1) Warning
 Warn if a caller of a function, marked with attribute warn_unused_result, does not use its return value
 
 Wvariadic-macros
-C ObjC C++ ObjC++ CPP(warn_variadic_macros) Var(cpp_warn_variadic_macros) Init(0) Warning LangEnabledBy(C ObjC C++ ObjC++,Wpedantic)
+C ObjC C++ ObjC++ CPP(warn_variadic_macros) CppReason(CPP_W_VARIADIC_MACROS) Var(cpp_warn_variadic_macros) Init(0) Warning LangEnabledBy(C ObjC C++ ObjC++,Wpedantic)
 Warn about using variadic macros
 
 Wvariadic-macros
index df52cdb..bcffdf8 100644 (file)
@@ -488,4 +488,9 @@ The state of this option should be kept in sync with the preprocessor
 option @var{var}.  If this property is set, then properties @code{Var}
 and @code{Init} must be set as well.
 
+@item CppReason(@var{CPP_W_Enum})
+This warning option corresponds to @code{cpplib.h} warning reason code
+@var{CPP_W_Enum}.  This should only be used for warning options of the
+C-family front-ends.
+
 @end table
index 4e8f21f..cbc7ab5 100644 (file)
@@ -479,5 +479,32 @@ print "  OPT_SPECIAL_program_name,"
 print "  OPT_SPECIAL_input_file"
 print "};"
 print ""
+print "#ifdef GCC_C_COMMON_H"
+print "/* Mapping from cpp message reasons to the options that enable them.  */"
+print "#include <cpplib.h>"
+print "struct cpp_reason_option_codes_t"
+print "{"
+print "  const int reason;             /* cpplib message reason.  */"
+print "  const int option_code;        /* gcc option that controls this message.  */"
+print "};"
+print ""
+print "static const struct cpp_reason_option_codes_t cpp_reason_option_codes[] = {"
+for (i = 0; i < n_opts; i++) {
+    # With identical flags, pick only the last one.  The
+    # earlier loop ensured that it has all flags merged,
+    # and a nonempty help text if one of the texts was nonempty.
+    while( i + 1 != n_opts && opts[i] == opts[i + 1] ) {
+        i++;
+    }
+    cpp_reason = nth_arg(0, opt_args("CppReason", flags[i]));
+    if (cpp_reason != "") {
+        cpp_reason = cpp_reason ",";
+        printf("  {%-40s %s},\n", cpp_reason, opt_enum(opts[i]))
+    }
+}
+printf("  {%-40s 0},\n", "CPP_W_NONE,")
+print "};"
+print "#endif"
+print ""
 print "#endif /* OPTIONS_H */"
 }