[C/C++] Make use of CPP() for Wdate-time and other flags
diff mbox

Message ID CAESRpQBPSf3EoaA5pdjNDOXHzXHBa=YqV+a-X9Jt+O9yZO_p=A@mail.gmail.com
State New
Headers show

Commit Message

Manuel López-Ibáñez Aug. 22, 2014, 10:32 a.m. UTC
Using Common for Wdate-time when it is defined in c.opt does not
really make sense and breaks CPP(). I also took the opportunity to
move a duplicated testcase to c-c++-common.
(svn diff does not show the move).

Bootstrapped and regression tested on x86_64-linux-gnu.

OK?

gcc/c-family/ChangeLog:

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

    * c.opt (Wcomment): Use CPP, Var and LangEnabledBy.
    (Wmultichar): Likewise.
    (Wdate-time): Use C-family languages instead of Common. Use CPP
    and Var.
    * c-opts.c (c_common_handle_option): Do not handle the above
    options here.
    (sanitize_cpp_opts): Likewise.

gcc/testsuite/ChangeLog:

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

    * g++.dg/warn/wdate-time.C: Remove.
    * gcc.dg/wdate-time.c: Move from here...
    * c-c++-common/wdate-time.c: ... to here.

Comments

Joseph Myers Aug. 22, 2014, 3:48 p.m. UTC | #1
On Fri, 22 Aug 2014, Manuel López-Ibáñez wrote:

> Using Common for Wdate-time when it is defined in c.opt does not
> really make sense and breaks CPP(). I also took the opportunity to
> move a duplicated testcase to c-c++-common.
> (svn diff does not show the move).
> 
> Bootstrapped and regression tested on x86_64-linux-gnu.
> 
> OK?

OK.

Patch
diff mbox

Index: gcc/c-family/c.opt
===================================================================
--- gcc/c-family/c.opt	(revision 214220)
+++ gcc/c-family/c.opt	(working copy)
@@ -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++ Warning
+C ObjC C++ ObjC++ CPP(warn_comments) Var(cpp_warn_comment) 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
@@ -596,11 +596,11 @@  Warn about global functions without prot
 
 Wmudflap
 C ObjC C++ ObjC++ Ignore Warn(switch %qs is no longer supported)
 
 Wmultichar
-C ObjC C++ ObjC++ Warning
+C ObjC C++ ObjC++ CPP(warn_multichar) Var(cpp_warn_multichar) Warning
 Warn about use of multi-character character constants
 
 Wnarrowing
 C ObjC C++ ObjC++ Warning Var(warn_narrowing) Init(-1) LangEnabledBy(C++ ObjC++,Wall)
 Warn about narrowing conversions within { } that are ill-formed in C++11
@@ -700,11 +700,11 @@  Warn when a pointer is cast to an intege
 Wpragmas
 C ObjC C++ ObjC++ Var(warn_pragmas) Init(1) Warning
 Warn about misuses of pragmas
 
 Wdate-time
-Common Var(cpp_warn_date_time) Warning
+C ObjC C++ ObjC++ CPP(warn_date_time) Var(cpp_warn_date_time) 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
Index: gcc/c-family/c-opts.c
===================================================================
--- gcc/c-family/c-opts.c	(revision 214220)
+++ gcc/c-family/c-opts.c	(working copy)
@@ -366,22 +366,17 @@  c_common_handle_option (size_t scode, co
 
     case OPT_Wall:
       /* ??? Don't add new options here. Use LangEnabledBy in c.opt.  */
 
       cpp_opts->warn_trigraphs = value;
-      cpp_opts->warn_comments = value;
       cpp_opts->warn_num_sign_change = value;
       break;
 
     case OPT_Wbuiltin_macro_redefined:
       cpp_opts->warn_builtin_macro_redefined = value;
       break;
 
-    case OPT_Wcomment:
-      cpp_opts->warn_comments = value;
-      break;
-
     case OPT_Wc___compat:
       cpp_opts->warn_cxx_operator_names = value;
       break;
 
     case OPT_Wdeprecated:
@@ -405,16 +400,12 @@  c_common_handle_option (size_t scode, co
       break;
 
     case OPT_Wmissing_include_dirs:
       cpp_opts->warn_missing_include_dirs = value;
       break;
-
-    case OPT_Wmultichar:
-      cpp_opts->warn_multichar = value;
-      break;
-
     case OPT_Wnormalized_:
+      /* FIXME: Move all this to c.opt.  */
       if (kind == DK_ERROR)
 	{
 	  gcc_assert (!arg);
 	  inform (input_location, "-Werror=normalized=: set -Wnormalized=nfc");
 	  cpp_opts->warn_normalize = normalized_C;
@@ -1294,11 +1285,10 @@  sanitize_cpp_opts (void)
   else if (cpp_opts->deps.missing_files)
     error ("-MG may only be used with -M or -MM");
 
   cpp_opts->unsigned_char = !flag_signed_char;
   cpp_opts->stdc_0_in_system_headers = STDC_0_IN_SYSTEM_HEADERS;
-  cpp_opts->warn_date_time = cpp_warn_date_time;
   cpp_opts->cpp_warn_c90_c99_compat = warn_c90_c99_compat;
 
   /* Wlong-long is disabled by default. It is enabled by:
       [-Wpedantic | -Wtraditional] -std=[gnu|c]++98 ; or
       [-Wpedantic | -Wtraditional] -std=non-c99 ; or
Index: gcc/testsuite/gcc.dg/wdate-time.c
===================================================================
--- gcc/testsuite/gcc.dg/wdate-time.c	(revision 214220)
+++ gcc/testsuite/gcc.dg/wdate-time.c	(working copy)
@@ -1,6 +0,0 @@ 
-/* { dg-do compile } */
-/* { dg-options "-Wdate-time" } */
-
-const char time[] = __TIME__;  /* { dg-warning "might prevent reproducible builds" }  */
-const char date[] = __DATE__;  /* { dg-warning "might prevent reproducible builds" }  */
-const char timestamp[] = __TIMESTAMP__;  /* { dg-warning "might prevent reproducible builds" }  */
Index: gcc/testsuite/g++.dg/warn/wdate-time.C
===================================================================
--- gcc/testsuite/g++.dg/warn/wdate-time.C	(revision 214220)
+++ gcc/testsuite/g++.dg/warn/wdate-time.C	(working copy)
@@ -1,6 +0,0 @@ 
-/* { dg-do compile } */
-/* { dg-options "-Wdate-time" } */
-
-const char time[] = __TIME__;  /* { dg-warning "might prevent reproducible builds" }  */
-const char date[] = __DATE__;  /* { dg-warning "might prevent reproducible builds" }  */
-const char timestamp[] = __TIMESTAMP__;  /* { dg-warning "might prevent reproducible builds" }  */