diff mbox

-Wvariadic-macros does not print warning

Message ID CAJXstsBhcsVfnN2dOmW0EWdnub-DQSfTs76FnDOm6mrs5VgPhg@mail.gmail.com
State New
Headers show

Commit Message

Prathamesh Kulkarni April 23, 2014, 6:03 p.m. UTC
I didn't attach the patch, I am extremely sorry for the noise.
I am re-posting the mail.
This is a follow up mail to http://gcc.gnu.org/ml/gcc-help/2014-04/msg00096.html
I have attached patch that prints the warning when passed -Wvariadic-macros
(I mostly followed it along lines of -Wlong-long).
OK for trunk ?

[libcpp]
* macro.c (parse_params): Remove condition CPP_OPTION (pfile, cpp_pedantic).

[gcc/c-family]
* c.opt (-Wvariadic-macros): Init(-1) instead of Init(1).
* c-opts.c (c_common_handle_option): Add case OPT_Wvariadic_macros.
               (sanitize_cpp_opts): Check condition for pedantic or
warn_traditional.

Thanks and Regards,
Prathamesh

On Wed, Apr 23, 2014 at 11:30 PM, Prathamesh Kulkarni
<bilbotheelffriend@gmail.com> wrote:
> forgot to add gcc-patches@gcc.gnu.org. Sorry for the double-post.
>
> On Wed, Apr 23, 2014 at 11:28 PM, Prathamesh Kulkarni
> <bilbotheelffriend@gmail.com> wrote:
>> This is a follow up mail to http://gcc.gnu.org/ml/gcc-help/2014-04/msg00096.html
>> I have attached patch that prints the warning when passed -Wvariadic-macros
>> (I mostly followed it along lines of -Wlong-long).
>> OK for trunk ?
>>
>> [libcpp]
>> * macro.c (parse_params): Remove condition CPP_OPTION (pfile, cpp_pedantic).
>>
>> [gcc/c-family]
>> * c.opt (-Wvariadic-macros): Init(-1) instead of Init(1).
>> * c-opts.c (c_common_handle_option): Add case OPT_Wvariadic_macros.
>>                (sanitize_cpp_opts): Check condition for pedantic or
>> warn_traditional.
>>
>> Thanks and Regards,
>> Prathamesh

Comments

Manuel López-Ibáñez April 29, 2014, 8:37 a.m. UTC | #1
On 23 April 2014 20:03, Prathamesh Kulkarni <bilbotheelffriend@gmail.com> wrote:
> I didn't attach the patch, I am extremely sorry for the noise.
> I am re-posting the mail.
> This is a follow up mail to http://gcc.gnu.org/ml/gcc-help/2014-04/msg00096.html
> I have attached patch that prints the warning when passed -Wvariadic-macros
> (I mostly followed it along lines of -Wlong-long).
> OK for trunk ?

Hi Prathamesh,

Thanks for CCing me! I cannot approve patches, but it looks almost
perfect to me. Did you run the regression testsuite and compare the
results before/after your patch? I would expect at least one testcase
testing this warning that would be affected by the change. If not, it
would be nice to add testcases for this. Also, there is another place
that tests for both Wpedantic and Wvariadic-macros just above the one
that you modify. I think you should update all of them to just test
for Wvariadic-macros.

Once you do that, I hope Joseph will approve it quickly, it seems an
obvious fix to me for consistency with Wlong-long and to allow people
to use this warning without enabling Wpedantic (also, it will enable
the warning with Wtraditional as intended, which is currently broken).

Cheers,

Manuel.
diff mbox

Patch

Index: libcpp/macro.c
===================================================================
--- libcpp/macro.c	(revision 209470)
+++ libcpp/macro.c	(working copy)
@@ -2800,8 +2800,7 @@  parse_params (cpp_reader *pfile, cpp_mac
                   (pfile, CPP_W_VARIADIC_MACROS,
 		   "anonymous variadic macros were introduced in C99");
 	    }
-	  else if (CPP_OPTION (pfile, cpp_pedantic)
-		   && CPP_OPTION (pfile, warn_variadic_macros))
+	  else if (CPP_OPTION (pfile, warn_variadic_macros))
 	    cpp_pedwarning (pfile, CPP_W_VARIADIC_MACROS,
 		            "ISO C does not permit named variadic macros");
 
Index: gcc/c-family/c-opts.c
===================================================================
--- gcc/c-family/c-opts.c	(revision 209470)
+++ gcc/c-family/c-opts.c	(working copy)
@@ -396,6 +396,10 @@  c_common_handle_option (size_t scode, co
       cpp_opts->cpp_warn_long_long = value;
       break;
 
+    case OPT_Wvariadic_macros:
+      cpp_opts->warn_variadic_macros = value;
+      break;
+
     case OPT_Wmissing_include_dirs:
       cpp_opts->warn_missing_include_dirs = value;
       break;
@@ -1227,8 +1231,9 @@  sanitize_cpp_opts (void)
 
   /* Similarly with -Wno-variadic-macros.  No check for c99 here, since
      this also turns off warnings about GCCs extension.  */
-  cpp_opts->warn_variadic_macros
-    = cpp_warn_variadic_macros && (pedantic || warn_traditional);
+  if (cpp_warn_variadic_macros == -1)
+    cpp_warn_variadic_macros = pedantic || warn_traditional;
+  cpp_opts->warn_variadic_macros = cpp_warn_variadic_macros;
 
   /* If we're generating preprocessor output, emit current directory
      if explicitly requested or if debugging information is enabled.
Index: gcc/c-family/c.opt
===================================================================
--- gcc/c-family/c.opt	(revision 209470)
+++ gcc/c-family/c.opt	(working copy)
@@ -785,7 +785,7 @@  C ObjC C++ ObjC++ Var(warn_unused_result
 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++ Var(cpp_warn_variadic_macros) Init(1) Warning
+C ObjC C++ ObjC++ Var(cpp_warn_variadic_macros) Init(-1) Warning
 Warn about using variadic macros
 
 Wvarargs