Re: auto generate cpp_reason to gcc OPT_W table

2014-09-09 Thread Joseph S. Myers
On Fri, 5 Sep 2014, Manuel L?pez-Ib??ez wrote:

> This adds a new option property CppReason which maps to a warning
> reason code in cpplib.h. This allows us to auto-generate
> cpp_reason_option_codes[], which maps from CPP warning codes to GCC
> ones, thus making a bit harder to forget to update this table (which
> evidently has happened a lot in the past).
> 
> Unfortunately, to use cpp warning codes we need to include cpplib.h in
> options.h and this would conflict with other parts of the compiler,
> thus I protect the table with #ifdef GCC_C_COMMON_H, and make sure in
> c-common.c that cpplib.h is not included before c-common.h.
> 
> This patch applies on top of the previous patch about Wnormalized= but
> it is mostly independent of it.
> 
> Bootstrapped and regression tested on x86_64-linux-gnu
> 
> OK?

OK.

-- 
Joseph S. Myers
jos...@codesourcery.com

auto generate cpp_reason to gcc OPT_W table

2014-09-05 Thread Manuel López-Ibáñez
This adds a new option property CppReason which maps to a warning
reason code in cpplib.h. This allows us to auto-generate
cpp_reason_option_codes[], which maps from CPP warning codes to GCC
ones, thus making a bit harder to forget to update this table (which
evidently has happened a lot in the past).

Unfortunately, to use cpp warning codes we need to include cpplib.h in
options.h and this would conflict with other parts of the compiler,
thus I protect the table with #ifdef GCC_C_COMMON_H, and make sure in
c-common.c that cpplib.h is not included before c-common.h.

This patch applies on top of the previous patch about Wnormalized= but
it is mostly independent of it.

Bootstrapped and regression tested on x86_64-linux-gnu

OK?

gcc/ChangeLog:

2014-09-05  Manuel López-Ibáñez  

* 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-05  Manuel López-Ibáñez  

* 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_.
Index: gcc/doc/options.texi
===
--- gcc/doc/options.texi(revision 214904)
+++ gcc/doc/options.texi(working copy)
@@ -486,6 +486,11 @@ to determine if a precompiled header fil
 @item CPP(@var{var})
 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: gcc/c-family/c.opt
===
--- gcc/c-family/c.opt  (revision 214904)
+++ gcc/c-family/c.opt  (working copy)
@@ -290,23 +290,23 @@ Warn about casting functions to incompat
 Wbool-compare
 C ObjC C++ ObjC++ Var(warn_bool_compare) Warning LangEnabledBy(C ObjC C++ 
ObjC++,Wall)
 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
 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
 C++ ObjC++ Var(warn_cxx0x_compat) Warning LangEnabledBy(C++ ObjC++,Wall)
 Deprecated in favor of -Wc++11-compat
@@ -326,11 +326,11 @@ Warn about subscripts whose type is \"ch
 Wclobbered
 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
 C ObjC C++ ObjC++ Warning Alias(Wcomment)
 Synonym for -Wcomment
@@ -345,14 +345,22 @@ Warn for implicit type conversions that
 
 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
 
 Wdelete-incomplete
@@ -366,11 +374,11 @@ Warn about deleting polymorphic objects
 Wdelete-non