public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: -Wvariadic-macros does not print warning
       [not found] <CAJXstsDGN7XDYBjFvgCsV-nAceMZNMB+2snrEcfH0jcNNLev5g@mail.gmail.com>
@ 2014-04-23 18:01 ` Prathamesh Kulkarni
  2014-04-23 18:06   ` Prathamesh Kulkarni
  0 siblings, 1 reply; 8+ messages in thread
From: Prathamesh Kulkarni @ 2014-04-23 18:01 UTC (permalink / raw)
  To: manu, Joseph S. Myers; +Cc: gcc-patches

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: -Wvariadic-macros does not print warning
  2014-04-23 18:01 ` -Wvariadic-macros does not print warning Prathamesh Kulkarni
@ 2014-04-23 18:06   ` Prathamesh Kulkarni
  2014-04-29  8:46     ` Manuel López-Ibáñez
  0 siblings, 1 reply; 8+ messages in thread
From: Prathamesh Kulkarni @ 2014-04-23 18:06 UTC (permalink / raw)
  To: manu, Joseph S. Myers; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1531 bytes --]

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

[-- Attachment #2: variadic-macros.patch --]
[-- Type: text/x-patch, Size: 2238 bytes --]

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: -Wvariadic-macros does not print warning
  2014-04-23 18:06   ` Prathamesh Kulkarni
@ 2014-04-29  8:46     ` Manuel López-Ibáñez
  2014-04-29 12:42       ` Prathamesh Kulkarni
  0 siblings, 1 reply; 8+ messages in thread
From: Manuel López-Ibáñez @ 2014-04-29  8:46 UTC (permalink / raw)
  To: Prathamesh Kulkarni; +Cc: Joseph S. Myers, Gcc Patch List

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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: -Wvariadic-macros does not print warning
  2014-04-29  8:46     ` Manuel López-Ibáñez
@ 2014-04-29 12:42       ` Prathamesh Kulkarni
  2014-04-29 13:21         ` Manuel López-Ibáñez
  0 siblings, 1 reply; 8+ messages in thread
From: Prathamesh Kulkarni @ 2014-04-29 12:42 UTC (permalink / raw)
  To: Manuel López-Ibáñez; +Cc: Joseph S. Myers, Gcc Patch List

[-- Attachment #1: Type: text/plain, Size: 2074 bytes --]

On Tue, Apr 29, 2014 at 2:07 PM, Manuel López-Ibáñez
<lopezibanez@gmail.com> wrote:
> 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).
>
Thanks, I modified the patch to remove Wpedantic check and added a new
test-case.
For changes to libcpp, do I need to run the entire test-suite or only runinng
libcpp tests (RUNTESTFLAGS=cpp.exp) is fine ?
I ran libcpp tests, and there appeared to be no failures.

[libcpp]
* macro.c (parse_params): Remove check for Wpedantic for variadic macros.

[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.

[gcc/testsuite/gcc.dg/cpp]
* Wvariadic-5.c: New test-case.

Thanks and Regards,
Prathamesh

> Cheers,
>
> Manuel.

[-- Attachment #2: variadic-macros.patch --]
[-- Type: text/x-patch, Size: 3353 bytes --]

Index: libcpp/macro.c
===================================================================
--- libcpp/macro.c	(revision 209800)
+++ libcpp/macro.c	(working copy)
@@ -2794,14 +2794,12 @@ parse_params (cpp_reader *pfile, cpp_mac
 				   pfile->spec_nodes.n__VA_ARGS__);
 	      pfile->state.va_args_ok = 1;
 	      if (! CPP_OPTION (pfile, c99)
-		  && CPP_OPTION (pfile, cpp_pedantic)
 		  && CPP_OPTION (pfile, warn_variadic_macros))
 		cpp_pedwarning
                   (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 209800)
+++ 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 209800)
+++ gcc/c-family/c.opt	(working copy)
@@ -509,6 +509,9 @@ Warn about missing fields in struct init
 Wsizeof-pointer-memaccess
 C ObjC C++ ObjC++ Var(warn_sizeof_pointer_memaccess) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall)
 
+Wsizeof-array-argument
+C Var(warn_sizeof_array_argument) Warning LangEnabledBy(C,Wall)
+
 Wsuggest-attribute=format
 C ObjC C++ ObjC++ Var(warn_suggest_attribute_format) Warning
 Warn about functions which might be candidates for format attributes
@@ -785,7 +788,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
Index: gcc/testsuite/gcc.dg/cpp/Wvariadic-5.c
===================================================================
--- gcc/testsuite/gcc.dg/cpp/Wvariadic-5.c	(revision 0)
+++ gcc/testsuite/gcc.dg/cpp/Wvariadic-5.c	(working copy)
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1990 -Wvariadic-macros" } */
+
+#define f(x,...)	/* { dg-warning "variadic" } */
+#define g(x,y...)	/* { dg-warning "variadic" } */
+int not_empty;

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: -Wvariadic-macros does not print warning
  2014-04-29 12:42       ` Prathamesh Kulkarni
@ 2014-04-29 13:21         ` Manuel López-Ibáñez
  2014-04-29 14:14           ` Prathamesh Kulkarni
  0 siblings, 1 reply; 8+ messages in thread
From: Manuel López-Ibáñez @ 2014-04-29 13:21 UTC (permalink / raw)
  To: Prathamesh Kulkarni; +Cc: Joseph S. Myers, Gcc Patch List

This hunk in your patch doesn't seem related:

@@ -509,6 +509,9 @@ Warn about missing fields in struct init
 Wsizeof-pointer-memaccess
 C ObjC C++ ObjC++ Var(warn_sizeof_pointer_memaccess) Warning
LangEnabledBy(C ObjC C++ ObjC++,Wall)

+Wsizeof-array-argument
+C Var(warn_sizeof_array_argument) Warning LangEnabledBy(C,Wall)
+
 Wsuggest-attribute=format
 C ObjC C++ ObjC++ Var(warn_suggest_attribute_format) Warning
 Warn about functions which might be candidates for format attributes

Also, it would be good to update doc/invoke.texi, the current
description is a bit confusing. It says it is enabled by default when
it actually isn't (nor after your patch). I propose something like:


Index: gcc/doc/invoke.texi
===================================================================
--- gcc/doc/invoke.texi (revision 208669)
+++ gcc/doc/invoke.texi (working copy)
@@ -4997,9 +4997,10 @@
 @item -Wvariadic-macros
 @opindex Wvariadic-macros
 @opindex Wno-variadic-macros
-Warn if variadic macros are used in pedantic ISO C90 mode, or the GNU
-alternate syntax when in pedantic ISO C99 mode.  This is default.
-To inhibit the warning messages, use @option{-Wno-variadic-macros}.
+Warn if variadic macros are used in ISO C90 mode, or if the GNU
+alternate syntax is used in ISO C99 mode.  This is enabled by either
+@option{-Wpedantic} or @option{-Wtraditional}.  To inhibit the warning
+messages, use @option{-Wno-variadic-macros}.

 @item -Wvarargs
 @opindex Wvarargs

On 29 April 2014 14:41, Prathamesh Kulkarni <bilbotheelffriend@gmail.com> wrote:
> On Tue, Apr 29, 2014 at 2:07 PM, Manuel López-Ibáñez
> <lopezibanez@gmail.com> wrote:
>> 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).
>>
> Thanks, I modified the patch to remove Wpedantic check and added a new
> test-case.
> For changes to libcpp, do I need to run the entire test-suite or only runinng
> libcpp tests (RUNTESTFLAGS=cpp.exp) is fine ?
> I ran libcpp tests, and there appeared to be no failures.
>
> [libcpp]
> * macro.c (parse_params): Remove check for Wpedantic for variadic macros.
>
> [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.
>
> [gcc/testsuite/gcc.dg/cpp]
> * Wvariadic-5.c: New test-case.
>
> Thanks and Regards,
> Prathamesh
>
>> Cheers,
>>
>> Manuel.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: -Wvariadic-macros does not print warning
  2014-04-29 13:21         ` Manuel López-Ibáñez
@ 2014-04-29 14:14           ` Prathamesh Kulkarni
  2014-04-29 14:29             ` Prathamesh Kulkarni
  0 siblings, 1 reply; 8+ messages in thread
From: Prathamesh Kulkarni @ 2014-04-29 14:14 UTC (permalink / raw)
  To: Manuel López-Ibáñez; +Cc: Joseph S. Myers, Gcc Patch List

[-- Attachment #1: Type: text/plain, Size: 4543 bytes --]

On Tue, Apr 29, 2014 at 6:49 PM, Manuel López-Ibáñez
<lopezibanez@gmail.com> wrote:
> This hunk in your patch doesn't seem related:
Oops, Sorry. Removed that, and re-tested.
>
> @@ -509,6 +509,9 @@ Warn about missing fields in struct init
>  Wsizeof-pointer-memaccess
>  C ObjC C++ ObjC++ Var(warn_sizeof_pointer_memaccess) Warning
> LangEnabledBy(C ObjC C++ ObjC++,Wall)
>
> +Wsizeof-array-argument
> +C Var(warn_sizeof_array_argument) Warning LangEnabledBy(C,Wall)
> +
>  Wsuggest-attribute=format
>  C ObjC C++ ObjC++ Var(warn_suggest_attribute_format) Warning
>  Warn about functions which might be candidates for format attributes
>
> Also, it would be good to update doc/invoke.texi, the current
> description is a bit confusing. It says it is enabled by default when
> it actually isn't (nor after your patch). I propose something like:
>
>
> Index: gcc/doc/invoke.texi
> ===================================================================
> --- gcc/doc/invoke.texi (revision 208669)
> +++ gcc/doc/invoke.texi (working copy)
> @@ -4997,9 +4997,10 @@
>  @item -Wvariadic-macros
>  @opindex Wvariadic-macros
>  @opindex Wno-variadic-macros
> -Warn if variadic macros are used in pedantic ISO C90 mode, or the GNU
> -alternate syntax when in pedantic ISO C99 mode.  This is default.
> -To inhibit the warning messages, use @option{-Wno-variadic-macros}.
> +Warn if variadic macros are used in ISO C90 mode, or if the GNU
> +alternate syntax is used in ISO C99 mode.  This is enabled by either
> +@option{-Wpedantic} or @option{-Wtraditional}.  To inhibit the warning
> +messages, use @option{-Wno-variadic-macros}.
>
>  @item -Wvarargs
>  @opindex Wvarargs
Thanks. I added this to the patch.
>
> On 29 April 2014 14:41, Prathamesh Kulkarni <bilbotheelffriend@gmail.com> wrote:

Is this version OK ?

[libcpp]
* macro.c (parse_params): Remove check for Wpedantic for variadic macros.

[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.

[gcc/testsuite/gcc.dg/cpp]
* Wvariadic-5.c: New test-case.

[gcc/doc]
* invoke.text: Change documentation for Wvariadic-macros option.

Thanks and Regards,
Prathamesh

>> On Tue, Apr 29, 2014 at 2:07 PM, Manuel López-Ibáñez
>> <lopezibanez@gmail.com> wrote:
>>> 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).
>>>
>> Thanks, I modified the patch to remove Wpedantic check and added a new
>> test-case.
>> For changes to libcpp, do I need to run the entire test-suite or only runinng
>> libcpp tests (RUNTESTFLAGS=cpp.exp) is fine ?
>> I ran libcpp tests, and there appeared to be no failures.
>>
>> [libcpp]
>> * macro.c (parse_params): Remove check for Wpedantic for variadic macros.
>>
>> [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.
>>
>> [gcc/testsuite/gcc.dg/cpp]
>> * Wvariadic-5.c: New test-case.
>>
>> Thanks and Regards,
>> Prathamesh
>>
>>> Cheers,
>>>
>>> Manuel.

[-- Attachment #2: variadic-macros.patch --]
[-- Type: text/x-patch, Size: 3733 bytes --]

Index: libcpp/macro.c
===================================================================
--- libcpp/macro.c	(revision 209800)
+++ libcpp/macro.c	(working copy)
@@ -2794,14 +2794,12 @@ parse_params (cpp_reader *pfile, cpp_mac
 				   pfile->spec_nodes.n__VA_ARGS__);
 	      pfile->state.va_args_ok = 1;
 	      if (! CPP_OPTION (pfile, c99)
-		  && CPP_OPTION (pfile, cpp_pedantic)
 		  && CPP_OPTION (pfile, warn_variadic_macros))
 		cpp_pedwarning
                   (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 209800)
+++ 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 209800)
+++ 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
Index: gcc/doc/invoke.texi
===================================================================
--- gcc/doc/invoke.texi	(revision 209800)
+++ gcc/doc/invoke.texi	(working copy)
@@ -4997,9 +4997,10 @@ modes.  To inhibit the warning messages,
 @item -Wvariadic-macros
 @opindex Wvariadic-macros
 @opindex Wno-variadic-macros
-Warn if variadic macros are used in pedantic ISO C90 mode, or the GNU
-alternate syntax when in pedantic ISO C99 mode.  This is default.
-To inhibit the warning messages, use @option{-Wno-variadic-macros}.
+Warn if variadic macros are used in ISO C90 mode, or if the GNU
+alternate syntax is used in ISO C99 mode.  This is enabled by either
+@option{-Wpedantic} or @option{-Wtraditional}.  To inhibit the warning
+messages, use @option{-Wno-variadic-macros}.
 
 @item -Wvarargs
 @opindex Wvarargs
Index: gcc/testsuite/gcc.dg/cpp/Wvariadic-5.c
===================================================================
--- gcc/testsuite/gcc.dg/cpp/Wvariadic-5.c	(revision 0)
+++ gcc/testsuite/gcc.dg/cpp/Wvariadic-5.c	(working copy)
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1990 -Wvariadic-macros" } */
+
+#define f(x,...)	/* { dg-warning "variadic" } */
+#define g(x,y...)	/* { dg-warning "variadic" } */
+int not_empty;

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: -Wvariadic-macros does not print warning
  2014-04-29 14:14           ` Prathamesh Kulkarni
@ 2014-04-29 14:29             ` Prathamesh Kulkarni
  2014-05-09 19:33               ` Jeff Law
  0 siblings, 1 reply; 8+ messages in thread
From: Prathamesh Kulkarni @ 2014-04-29 14:29 UTC (permalink / raw)
  To: Manuel López-Ibáñez; +Cc: Joseph S. Myers, Gcc Patch List

[-- Attachment #1: Type: text/plain, Size: 5348 bytes --]

On Tue, Apr 29, 2014 at 7:37 PM, Prathamesh Kulkarni
<bilbotheelffriend@gmail.com> wrote:
> On Tue, Apr 29, 2014 at 6:49 PM, Manuel López-Ibáñez
> <lopezibanez@gmail.com> wrote:
>> This hunk in your patch doesn't seem related:
> Oops, Sorry. Removed that, and re-tested.
>>
>> @@ -509,6 +509,9 @@ Warn about missing fields in struct init
>>  Wsizeof-pointer-memaccess
>>  C ObjC C++ ObjC++ Var(warn_sizeof_pointer_memaccess) Warning
>> LangEnabledBy(C ObjC C++ ObjC++,Wall)
>>
>> +Wsizeof-array-argument
>> +C Var(warn_sizeof_array_argument) Warning LangEnabledBy(C,Wall)
>> +
>>  Wsuggest-attribute=format
>>  C ObjC C++ ObjC++ Var(warn_suggest_attribute_format) Warning
>>  Warn about functions which might be candidates for format attributes
>>
>> Also, it would be good to update doc/invoke.texi, the current
>> description is a bit confusing. It says it is enabled by default when
>> it actually isn't (nor after your patch). I propose something like:
>>
>>
>> Index: gcc/doc/invoke.texi
>> ===================================================================
>> --- gcc/doc/invoke.texi (revision 208669)
>> +++ gcc/doc/invoke.texi (working copy)
>> @@ -4997,9 +4997,10 @@
>>  @item -Wvariadic-macros
>>  @opindex Wvariadic-macros
>>  @opindex Wno-variadic-macros
>> -Warn if variadic macros are used in pedantic ISO C90 mode, or the GNU
>> -alternate syntax when in pedantic ISO C99 mode.  This is default.
>> -To inhibit the warning messages, use @option{-Wno-variadic-macros}.
>> +Warn if variadic macros are used in ISO C90 mode, or if the GNU
>> +alternate syntax is used in ISO C99 mode.  This is enabled by either
>> +@option{-Wpedantic} or @option{-Wtraditional}.  To inhibit the warning
>> +messages, use @option{-Wno-variadic-macros}.
>>
>>  @item -Wvarargs
>>  @opindex Wvarargs
> Thanks. I added this to the patch.
>>
>> On 29 April 2014 14:41, Prathamesh Kulkarni <bilbotheelffriend@gmail.com> wrote:
>
> Is this version OK ?
>
> [libcpp]
> * macro.c (parse_params): Remove check for Wpedantic for variadic macros.
>
> [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.
>
> [gcc/testsuite/gcc.dg/cpp]
> * Wvariadic-5.c: New test-case.
>
> [gcc/doc]
> * invoke.text: Change documentation for Wvariadic-macros option.
Sorry for the spelling mistake. Re-posting the changelog.

[libcpp]
* macro.c (parse_params): Remove check for Wpedantic for variadic macros.

[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.

[gcc/testsuite/gcc.dg/cpp]
* Wvariadic-5.c: New test-case.

[gcc/doc]
* invoke.texi (-Wvariadic-macros): Change documentation for
-Wvariadic-macros option.

Thanks and Regards,
Prathamesh

>
> Thanks and Regards,
> Prathamesh
>
>>> On Tue, Apr 29, 2014 at 2:07 PM, Manuel López-Ibáñez
>>> <lopezibanez@gmail.com> wrote:
>>>> 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).
>>>>
>>> Thanks, I modified the patch to remove Wpedantic check and added a new
>>> test-case.
>>> For changes to libcpp, do I need to run the entire test-suite or only runinng
>>> libcpp tests (RUNTESTFLAGS=cpp.exp) is fine ?
>>> I ran libcpp tests, and there appeared to be no failures.
>>>
>>> [libcpp]
>>> * macro.c (parse_params): Remove check for Wpedantic for variadic macros.
>>>
>>> [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.
>>>
>>> [gcc/testsuite/gcc.dg/cpp]
>>> * Wvariadic-5.c: New test-case.
>>>
>>> Thanks and Regards,
>>> Prathamesh
>>>
>>>> Cheers,
>>>>
>>>> Manuel.

[-- Attachment #2: variadic-macros.patch --]
[-- Type: text/x-patch, Size: 3733 bytes --]

Index: libcpp/macro.c
===================================================================
--- libcpp/macro.c	(revision 209800)
+++ libcpp/macro.c	(working copy)
@@ -2794,14 +2794,12 @@ parse_params (cpp_reader *pfile, cpp_mac
 				   pfile->spec_nodes.n__VA_ARGS__);
 	      pfile->state.va_args_ok = 1;
 	      if (! CPP_OPTION (pfile, c99)
-		  && CPP_OPTION (pfile, cpp_pedantic)
 		  && CPP_OPTION (pfile, warn_variadic_macros))
 		cpp_pedwarning
                   (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 209800)
+++ 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 209800)
+++ 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
Index: gcc/doc/invoke.texi
===================================================================
--- gcc/doc/invoke.texi	(revision 209800)
+++ gcc/doc/invoke.texi	(working copy)
@@ -4997,9 +4997,10 @@ modes.  To inhibit the warning messages,
 @item -Wvariadic-macros
 @opindex Wvariadic-macros
 @opindex Wno-variadic-macros
-Warn if variadic macros are used in pedantic ISO C90 mode, or the GNU
-alternate syntax when in pedantic ISO C99 mode.  This is default.
-To inhibit the warning messages, use @option{-Wno-variadic-macros}.
+Warn if variadic macros are used in ISO C90 mode, or if the GNU
+alternate syntax is used in ISO C99 mode.  This is enabled by either
+@option{-Wpedantic} or @option{-Wtraditional}.  To inhibit the warning
+messages, use @option{-Wno-variadic-macros}.
 
 @item -Wvarargs
 @opindex Wvarargs
Index: gcc/testsuite/gcc.dg/cpp/Wvariadic-5.c
===================================================================
--- gcc/testsuite/gcc.dg/cpp/Wvariadic-5.c	(revision 0)
+++ gcc/testsuite/gcc.dg/cpp/Wvariadic-5.c	(working copy)
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1990 -Wvariadic-macros" } */
+
+#define f(x,...)	/* { dg-warning "variadic" } */
+#define g(x,y...)	/* { dg-warning "variadic" } */
+int not_empty;

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: -Wvariadic-macros does not print warning
  2014-04-29 14:29             ` Prathamesh Kulkarni
@ 2014-05-09 19:33               ` Jeff Law
  0 siblings, 0 replies; 8+ messages in thread
From: Jeff Law @ 2014-05-09 19:33 UTC (permalink / raw)
  To: Prathamesh Kulkarni, Manuel López-Ibáñez
  Cc: Joseph S. Myers, Gcc Patch List

On 04/29/14 08:14, Prathamesh Kulkarni wrote:
> On Tue, Apr 29, 2014 at 7:37 PM, Prathamesh Kulkarni
> <bilbotheelffriend@gmail.com> wrote:
>> On Tue, Apr 29, 2014 at 6:49 PM, Manuel López-Ibáñez
>> <lopezibanez@gmail.com> wrote:
>>> This hunk in your patch doesn't seem related:
>> Oops, Sorry. Removed that, and re-tested.
>>>
>>> @@ -509,6 +509,9 @@ Warn about missing fields in struct init
>>>   Wsizeof-pointer-memaccess
>>>   C ObjC C++ ObjC++ Var(warn_sizeof_pointer_memaccess) Warning
>>> LangEnabledBy(C ObjC C++ ObjC++,Wall)
>>>
>>> +Wsizeof-array-argument
>>> +C Var(warn_sizeof_array_argument) Warning LangEnabledBy(C,Wall)
>>> +
>>>   Wsuggest-attribute=format
>>>   C ObjC C++ ObjC++ Var(warn_suggest_attribute_format) Warning
>>>   Warn about functions which might be candidates for format attributes
>>>
>>> Also, it would be good to update doc/invoke.texi, the current
>>> description is a bit confusing. It says it is enabled by default when
>>> it actually isn't (nor after your patch). I propose something like:
>>>
>>>
>>> Index: gcc/doc/invoke.texi
>>> ===================================================================
>>> --- gcc/doc/invoke.texi (revision 208669)
>>> +++ gcc/doc/invoke.texi (working copy)
>>> @@ -4997,9 +4997,10 @@
>>>   @item -Wvariadic-macros
>>>   @opindex Wvariadic-macros
>>>   @opindex Wno-variadic-macros
>>> -Warn if variadic macros are used in pedantic ISO C90 mode, or the GNU
>>> -alternate syntax when in pedantic ISO C99 mode.  This is default.
>>> -To inhibit the warning messages, use @option{-Wno-variadic-macros}.
>>> +Warn if variadic macros are used in ISO C90 mode, or if the GNU
>>> +alternate syntax is used in ISO C99 mode.  This is enabled by either
>>> +@option{-Wpedantic} or @option{-Wtraditional}.  To inhibit the warning
>>> +messages, use @option{-Wno-variadic-macros}.
>>>
>>>   @item -Wvarargs
>>>   @opindex Wvarargs
>> Thanks. I added this to the patch.
>>>
>>> On 29 April 2014 14:41, Prathamesh Kulkarni <bilbotheelffriend@gmail.com> wrote:
>>
>> Is this version OK ?
>>
>> [libcpp]
>> * macro.c (parse_params): Remove check for Wpedantic for variadic macros.
>>
>> [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.
>>
>> [gcc/testsuite/gcc.dg/cpp]
>> * Wvariadic-5.c: New test-case.
>>
>> [gcc/doc]
>> * invoke.text: Change documentation for Wvariadic-macros option.
> Sorry for the spelling mistake. Re-posting the changelog.
>
> [libcpp]
> * macro.c (parse_params): Remove check for Wpedantic for variadic macros.
>
> [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.
>
> [gcc/testsuite/gcc.dg/cpp]
> * Wvariadic-5.c: New test-case.
>
> [gcc/doc]
> * invoke.texi (-Wvariadic-macros): Change documentation for
> -Wvariadic-macros option.
This is fine.  When you commit the change, make sure that your ChangeLog 
entry follows the same formatting as the others.

Thanks,
Jeff

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-05-09 19:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAJXstsDGN7XDYBjFvgCsV-nAceMZNMB+2snrEcfH0jcNNLev5g@mail.gmail.com>
2014-04-23 18:01 ` -Wvariadic-macros does not print warning Prathamesh Kulkarni
2014-04-23 18:06   ` Prathamesh Kulkarni
2014-04-29  8:46     ` Manuel López-Ibáñez
2014-04-29 12:42       ` Prathamesh Kulkarni
2014-04-29 13:21         ` Manuel López-Ibáñez
2014-04-29 14:14           ` Prathamesh Kulkarni
2014-04-29 14:29             ` Prathamesh Kulkarni
2014-05-09 19:33               ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).