public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH c/c++] use explicit locations for some warnings in c-pragma.c
@ 2015-05-25 17:47 Manuel López-Ibáñez
  2015-05-25 19:48 ` Jason Merrill
  2015-05-25 20:17 ` Marek Polacek
  0 siblings, 2 replies; 16+ messages in thread
From: Manuel López-Ibáñez @ 2015-05-25 17:47 UTC (permalink / raw)
  To: Gcc Patch List, Joseph S. Myers, Jason Merrill

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

This changes from:

pragma-diag-3.c:2:9: warning: missing [error|warning|ignored] after
‘#pragma GCC diagnostic’ [-Wpragmas]
 #pragma GCC diagnostic /* { dg-warning "24:missing" "missing" { xfail
*-*-* } } */
         ^
pragma-diag-3.c:4:9: warning: expected
[error|warning|ignored|push|pop] after ‘#pragma GCC diagnostic’
[-Wpragmas]
 #pragma GCC diagnostic warn /* { dg-warning "24:expected" } */
         ^
pragma-diag-3.c:6:9: warning: unknown option after ‘#pragma GCC
diagnostic’ kind [-Wpragmas]
 #pragma GCC diagnostic ignored "-Wfoo" /* { dg-warning "32:unknown" } */
         ^

to:


pragma-diag-3.c:2:83: warning: missing
[error|warning|ignored|push|pop] after ‘#pragma GCC diagnostic’
[-Wpragmas]
pragma-diag-3.c:4:24: warning: expected
[error|warning|ignored|push|pop] after ‘#pragma GCC diagnostic’
[-Wpragmas]
 #pragma GCC diagnostic warn /* { dg-warning "24:expected" } */
                        ^
pragma-diag-3.c:6:32: warning: unknown option after ‘#pragma GCC
diagnostic’ kind [-Wpragmas]
 #pragma GCC diagnostic ignored "-Wfoo" /* { dg-warning "32:unknown" } */
                                ^

which is a clear improvement except for the fact that CPP_PRAGMA_EOL
tokens do not have a valid location. I think this is a bug and will
open a PR.

Of course, this opens the door to giving better locations for all
diagnostics in c-pragma.c, but I'll leave that for the future.

Bootstrapped and regression tested on x86_64-linux-gnu.

OK?

gcc/cp/ChangeLog:

2015-05-25  Manuel López-Ibáñez  <manu@gcc.gnu.org>

    * parser.c (pragma_lex): Add loc argument. Rearrange the code to
    make it more similar to the C version.

gcc/c-family/ChangeLog:

2015-05-25  Manuel López-Ibáñez  <manu@gcc.gnu.org>

    * c-pragma.c (handle_pragma_diagnostic): Use explicit location
    when warning.
    * c-pragma.h (pragma_lex): Add optional loc argument.

gcc/c/ChangeLog:

2015-05-25  Manuel López-Ibáñez  <manu@gcc.gnu.org>

    * c-parser.c (pragma_lex): Add loc argument.

gcc/testsuite/ChangeLog:

2015-05-25  Manuel López-Ibáñez  <manu@gcc.gnu.org>

    * gcc.dg/pragma-diag-3.c: New test.

[-- Attachment #2: c-pragma.diff --]
[-- Type: text/plain, Size: 5316 bytes --]

Index: gcc/c-family/c-pragma.c
===================================================================
--- gcc/c-family/c-pragma.c	(revision 223596)
+++ gcc/c-family/c-pragma.c	(working copy)
@@ -725,14 +725,20 @@ handle_pragma_diagnostic(cpp_reader *ARG
   unsigned int option_index;
   enum cpp_ttype token;
   diagnostic_t kind;
   tree x;
   struct cl_option_handlers handlers;
+  location_t loc;
 
-  token = pragma_lex (&x);
+  token = pragma_lex (&x, &loc);
   if (token != CPP_NAME)
-    GCC_BAD ("missing [error|warning|ignored] after %<#pragma GCC diagnostic%>");
+    {
+      warning_at (loc, OPT_Wpragmas,
+		  "missing [error|warning|ignored|push|pop] after %<#pragma GCC diagnostic%>");
+      return;
+    }
+
   kind_string = IDENTIFIER_POINTER (x);
   if (strcmp (kind_string, "error") == 0)
     kind = DK_ERROR;
   else if (strcmp (kind_string, "warning") == 0)
     kind = DK_WARNING;
@@ -747,15 +753,23 @@ handle_pragma_diagnostic(cpp_reader *ARG
     {
       diagnostic_pop_diagnostics (global_dc, input_location);
       return;
     }
   else
-    GCC_BAD ("expected [error|warning|ignored|push|pop] after %<#pragma GCC diagnostic%>");
+    {
+      warning_at (loc, OPT_Wpragmas,
+		  "expected [error|warning|ignored|push|pop] after %<#pragma GCC diagnostic%>");
+      return;
+    }
 
-  token = pragma_lex (&x);
+  token = pragma_lex (&x, &loc);
   if (token != CPP_STRING)
-    GCC_BAD ("missing option after %<#pragma GCC diagnostic%> kind");
+    {
+      warning_at (loc, OPT_Wpragmas,
+		  "missing option after %<#pragma GCC diagnostic%> kind");
+      return;
+    }
   option_string = TREE_STRING_POINTER (x);
   set_default_handlers (&handlers);
   for (option_index = 0; option_index < cl_options_count; option_index++)
     if (strcmp (cl_options[option_index].opt_text, option_string) == 0)
       {
@@ -763,11 +777,12 @@ handle_pragma_diagnostic(cpp_reader *ARG
 				input_location, c_family_lang_mask, &handlers,
 				&global_options, &global_options_set,
 				global_dc);
 	return;
       }
-  GCC_BAD ("unknown option after %<#pragma GCC diagnostic%> kind");
+  warning_at (loc, OPT_Wpragmas,
+	      "unknown option after %<#pragma GCC diagnostic%> kind");
 }
 
 /*  Parse #pragma GCC target (xxx) to set target specific options.  */
 static void
 handle_pragma_target(cpp_reader *ARG_UNUSED(dummy))
Index: gcc/c-family/c-pragma.h
===================================================================
--- gcc/c-family/c-pragma.h	(revision 223596)
+++ gcc/c-family/c-pragma.h	(working copy)
@@ -211,11 +211,11 @@ extern void c_invoke_pragma_handler (uns
 extern void maybe_apply_pragma_weak (tree);
 extern void maybe_apply_pending_pragma_weaks (void);
 extern tree maybe_apply_renaming_pragma (tree, tree);
 extern void add_to_renaming_pragma_list (tree, tree);
 
-extern enum cpp_ttype pragma_lex (tree *);
+extern enum cpp_ttype pragma_lex (tree *, location_t *loc = NULL);
 
 /* Flags for use with c_lex_with_flags.  The values here were picked
    so that 0 means to translate and join strings.  */
 #define C_LEX_STRING_NO_TRANSLATE 1 /* Do not lex strings into
 				       execution character set.  */
Index: gcc/c/c-parser.c
===================================================================
--- gcc/c/c-parser.c	(revision 223596)
+++ gcc/c/c-parser.c	(working copy)
@@ -9835,16 +9835,19 @@ c_parser_pragma (c_parser *parser, enum 
 }
 
 /* The interface the pragma parsers have to the lexer.  */
 
 enum cpp_ttype
-pragma_lex (tree *value)
+pragma_lex (tree *value, location_t *loc)
 {
   c_token *tok = c_parser_peek_token (the_parser);
   enum cpp_ttype ret = tok->type;
 
   *value = tok->value;
+  if (loc)
+    *loc = tok->location;
+
   if (ret == CPP_PRAGMA_EOL || ret == CPP_EOF)
     ret = CPP_EOF;
   else
     {
       if (ret == CPP_KEYWORD)
Index: gcc/testsuite/gcc.dg/pragma-diag-3.c
===================================================================
--- gcc/testsuite/gcc.dg/pragma-diag-3.c	(revision 0)
+++ gcc/testsuite/gcc.dg/pragma-diag-3.c	(revision 0)
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+#pragma GCC diagnostic /* { dg-warning "24:missing" "missing" { xfail *-*-* } } */
+
+#pragma GCC diagnostic warn /* { dg-warning "24:expected" } */
+
+#pragma GCC diagnostic ignored "-Wfoo" /* { dg-warning "32:unknown" } */
Index: gcc/cp/parser.c
===================================================================
--- gcc/cp/parser.c	(revision 223596)
+++ gcc/cp/parser.c	(working copy)
@@ -33175,29 +33175,28 @@ cp_parser_pragma (cp_parser *parser, enu
 }
 
 /* The interface the pragma parsers have to the lexer.  */
 
 enum cpp_ttype
-pragma_lex (tree *value)
+pragma_lex (tree *value, location_t *loc)
 {
-  cp_token *tok;
-  enum cpp_ttype ret;
+  cp_token *tok = cp_lexer_peek_token (the_parser->lexer);
+  enum cpp_ttype ret = tok->type;
 
-  tok = cp_lexer_peek_token (the_parser->lexer);
-
-  ret = tok->type;
   *value = tok->u.value;
+  if (loc)
+    *loc = tok->location;
 
   if (ret == CPP_PRAGMA_EOL || ret == CPP_EOF)
     ret = CPP_EOF;
   else if (ret == CPP_STRING)
     *value = cp_parser_string_literal (the_parser, false, false);
   else
     {
-      cp_lexer_consume_token (the_parser->lexer);
       if (ret == CPP_KEYWORD)
 	ret = CPP_NAME;
+      cp_lexer_consume_token (the_parser->lexer);
     }
 
   return ret;
 }
 

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

* Re: [PATCH c/c++] use explicit locations for some warnings in c-pragma.c
  2015-05-25 17:47 [PATCH c/c++] use explicit locations for some warnings in c-pragma.c Manuel López-Ibáñez
@ 2015-05-25 19:48 ` Jason Merrill
  2015-05-25 20:17 ` Marek Polacek
  1 sibling, 0 replies; 16+ messages in thread
From: Jason Merrill @ 2015-05-25 19:48 UTC (permalink / raw)
  To: Manuel López-Ibáñez, Gcc Patch List, Joseph S. Myers

OK.

Jason

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

* Re: [PATCH c/c++] use explicit locations for some warnings in c-pragma.c
  2015-05-25 17:47 [PATCH c/c++] use explicit locations for some warnings in c-pragma.c Manuel López-Ibáñez
  2015-05-25 19:48 ` Jason Merrill
@ 2015-05-25 20:17 ` Marek Polacek
  2015-05-25 20:55   ` Manuel López-Ibáñez
  1 sibling, 1 reply; 16+ messages in thread
From: Marek Polacek @ 2015-05-25 20:17 UTC (permalink / raw)
  To: Manuel López-Ibáñez
  Cc: Gcc Patch List, Joseph S. Myers, Jason Merrill

On Mon, May 25, 2015 at 06:06:01PM +0200, Manuel López-Ibáñez wrote:
>    if (token != CPP_NAME)
> -    GCC_BAD ("missing [error|warning|ignored] after %<#pragma GCC diagnostic%>");
> +    {
> +      warning_at (loc, OPT_Wpragmas,
> +		  "missing [error|warning|ignored|push|pop] after %<#pragma GCC diagnostic%>");

Line too long.

> -    GCC_BAD ("expected [error|warning|ignored|push|pop] after %<#pragma GCC diagnostic%>");
> +    {
> +      warning_at (loc, OPT_Wpragmas,
> +		  "expected [error|warning|ignored|push|pop] after %<#pragma GCC diagnostic%>");

Likewise.

Perhaps we should introduce GCC_BAD_LOC with a location_t argument and use it
here.

	Marek

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

* Re: [PATCH c/c++] use explicit locations for some warnings in c-pragma.c
  2015-05-25 20:17 ` Marek Polacek
@ 2015-05-25 20:55   ` Manuel López-Ibáñez
  2015-09-20 20:38     ` Christophe Lyon
  0 siblings, 1 reply; 16+ messages in thread
From: Manuel López-Ibáñez @ 2015-05-25 20:55 UTC (permalink / raw)
  To: Marek Polacek; +Cc: Gcc Patch List, Joseph S. Myers, Jason Merrill

On 25 May 2015 at 21:56, Marek Polacek <polacek@redhat.com> wrote:
> Perhaps we should introduce GCC_BAD_LOC with a location_t argument and use it
> here.

Why would we want to obfuscate code like that? I would propose to
actually remove GCC_BAD completely.

Manuel.

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

* Re: [PATCH c/c++] use explicit locations for some warnings in c-pragma.c
  2015-05-25 20:55   ` Manuel López-Ibáñez
@ 2015-09-20 20:38     ` Christophe Lyon
  2015-09-20 22:35       ` Manuel López-Ibáñez
  0 siblings, 1 reply; 16+ messages in thread
From: Christophe Lyon @ 2015-09-20 20:38 UTC (permalink / raw)
  To: Manuel López-Ibáñez
  Cc: Marek Polacek, Gcc Patch List, Joseph S. Myers, Jason Merrill

On 25 May 2015 at 22:16, Manuel López-Ibáñez <lopezibanez@gmail.com> wrote:
> On 25 May 2015 at 21:56, Marek Polacek <polacek@redhat.com> wrote:
>> Perhaps we should introduce GCC_BAD_LOC with a location_t argument and use it
>> here.
>
> Why would we want to obfuscate code like that? I would propose to
> actually remove GCC_BAD completely.
>
Hi
It looks like this patch has finally been committed on 2015-09-18
(r227923), right?

I can see the newly introduced test (gcc.dg/pragma-diag-5.c) failing:
/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/testsuite/gcc.dg/pragma-diag-5.c:2:83:
warning: missing [error|warning|ignored|push|pop] after '#pragma GCC
diagnostic' [-Wpragmas]
/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/testsuite/gcc.dg/pragma-diag-5.c:4:24:
warning: expected [error|warning|ignored|push|pop] after '#pragma GCC
diagnostic' [-Wpragmas]
/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/testsuite/gcc.dg/pragma-diag-5.c:6:32:
warning: unknown option after '#pragma GCC diagnostic' kind
[-Wpragmas]

XFAIL: gcc.dg/pragma-diag-5.c missing (test for warnings, line 2)
PASS: gcc.dg/pragma-diag-5.c  (test for warnings, line 4)
PASS: gcc.dg/pragma-diag-5.c  (test for warnings, line 6)
FAIL: gcc.dg/pragma-diag-5.c (test for excess errors)
Excess errors:
/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/testsuite/gcc.dg/pragma-diag-5.c:2:83:
warning: missing [error|warning|ignored|push|pop] after '#pragma GCC
diagnostic' [-Wpragmas]

I'm not sure why, since the 1st warning is xfail.

Christophe.

> Manuel.

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

* Re: [PATCH c/c++] use explicit locations for some warnings in c-pragma.c
  2015-09-20 20:38     ` Christophe Lyon
@ 2015-09-20 22:35       ` Manuel López-Ibáñez
  2015-09-21  0:24         ` Christophe Lyon
  2015-11-04  9:46         ` Mike Stump
  0 siblings, 2 replies; 16+ messages in thread
From: Manuel López-Ibáñez @ 2015-09-20 22:35 UTC (permalink / raw)
  To: Christophe Lyon
  Cc: Marek Polacek, Gcc Patch List, Joseph S. Myers, Jason Merrill

On 20 September 2015 at 22:32, Christophe Lyon
<christophe.lyon@linaro.org> wrote:
> On 25 May 2015 at 22:16, Manuel López-Ibáñez <lopezibanez@gmail.com> wrote:
>> On 25 May 2015 at 21:56, Marek Polacek <polacek@redhat.com> wrote:
>>> Perhaps we should introduce GCC_BAD_LOC with a location_t argument and use it
>>> here.
>>
>> Why would we want to obfuscate code like that? I would propose to
>> actually remove GCC_BAD completely.
>>
> Hi
> It looks like this patch has finally been committed on 2015-09-18
> (r227923), right?

Yes, I had almost forgotten about it.

> I'm not sure why, since the 1st warning is xfail.

Strange that I missed this, but I can see it now. (Well, not so
strange, contrib/compare_tests sometimes produces nonsense)

Could you try with this patch? It seems to work for me. I'll commit it
as obvious if it works for you too.

Index: gcc/testsuite/gcc.dg/pragma-diag-5.c
===================================================================
--- gcc/testsuite/gcc.dg/pragma-diag-5.c        (revision 227932)
+++ gcc/testsuite/gcc.dg/pragma-diag-5.c        (working copy)
@@ -1,6 +1,7 @@
 /* { dg-do compile } */
-#pragma GCC diagnostic /* { dg-warning "24:missing" "missing" { xfail
*-*-* } } */
+#pragma GCC diagnostic /* { dg-warning "missing" "missing" } */
+/* { dg-warning "24:missing" "missing" { xfail *-*-* }  2 } */

 #pragma GCC diagnostic warn /* { dg-warning "24:expected" } */

 #pragma GCC diagnostic ignored "-Wfoo" /* { dg-warning "32:unknown" } */

Cheers,

Manuel.

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

* Re: [PATCH c/c++] use explicit locations for some warnings in c-pragma.c
  2015-09-20 22:35       ` Manuel López-Ibáñez
@ 2015-09-21  0:24         ` Christophe Lyon
  2015-09-21  0:29           ` Manuel López-Ibáñez
  2015-11-04  9:46         ` Mike Stump
  1 sibling, 1 reply; 16+ messages in thread
From: Christophe Lyon @ 2015-09-21  0:24 UTC (permalink / raw)
  To: Manuel López-Ibáñez
  Cc: Marek Polacek, Gcc Patch List, Joseph S. Myers, Jason Merrill

On 20 September 2015 at 23:40, Manuel López-Ibáñez
<lopezibanez@gmail.com> wrote:
> On 20 September 2015 at 22:32, Christophe Lyon
> <christophe.lyon@linaro.org> wrote:
>> On 25 May 2015 at 22:16, Manuel López-Ibáñez <lopezibanez@gmail.com> wrote:
>>> On 25 May 2015 at 21:56, Marek Polacek <polacek@redhat.com> wrote:
>>>> Perhaps we should introduce GCC_BAD_LOC with a location_t argument and use it
>>>> here.
>>>
>>> Why would we want to obfuscate code like that? I would propose to
>>> actually remove GCC_BAD completely.
>>>
>> Hi
>> It looks like this patch has finally been committed on 2015-09-18
>> (r227923), right?
>
> Yes, I had almost forgotten about it.
>
>> I'm not sure why, since the 1st warning is xfail.
>
> Strange that I missed this, but I can see it now. (Well, not so
> strange, contrib/compare_tests sometimes produces nonsense)
>
> Could you try with this patch? It seems to work for me. I'll commit it
> as obvious if it works for you too.
>
> Index: gcc/testsuite/gcc.dg/pragma-diag-5.c
> ===================================================================
> --- gcc/testsuite/gcc.dg/pragma-diag-5.c        (revision 227932)
> +++ gcc/testsuite/gcc.dg/pragma-diag-5.c        (working copy)
> @@ -1,6 +1,7 @@
>  /* { dg-do compile } */
> -#pragma GCC diagnostic /* { dg-warning "24:missing" "missing" { xfail
> *-*-* } } */
> +#pragma GCC diagnostic /* { dg-warning "missing" "missing" } */
> +/* { dg-warning "24:missing" "missing" { xfail *-*-* }  2 } */

It works for me if I replace 24 by 62.

Christophe.

>
>  #pragma GCC diagnostic warn /* { dg-warning "24:expected" } */
>
>  #pragma GCC diagnostic ignored "-Wfoo" /* { dg-warning "32:unknown" } */
>
> Cheers,
>
> Manuel.

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

* Re: [PATCH c/c++] use explicit locations for some warnings in c-pragma.c
  2015-09-21  0:24         ` Christophe Lyon
@ 2015-09-21  0:29           ` Manuel López-Ibáñez
  2015-09-21  0:33             ` Christophe Lyon
  0 siblings, 1 reply; 16+ messages in thread
From: Manuel López-Ibáñez @ 2015-09-21  0:29 UTC (permalink / raw)
  To: Christophe Lyon
  Cc: Marek Polacek, Gcc Patch List, Joseph S. Myers, Jason Merrill

On 21 September 2015 at 02:22, Christophe Lyon
<christophe.lyon@linaro.org> wrote:
> It works for me if I replace 24 by 62.

Wierd. What is the actual output of the compiler?

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

* Re: [PATCH c/c++] use explicit locations for some warnings in c-pragma.c
  2015-09-21  0:29           ` Manuel López-Ibáñez
@ 2015-09-21  0:33             ` Christophe Lyon
  2015-09-21  1:46               ` Manuel López-Ibáñez
  0 siblings, 1 reply; 16+ messages in thread
From: Christophe Lyon @ 2015-09-21  0:33 UTC (permalink / raw)
  To: Manuel López-Ibáñez
  Cc: Marek Polacek, Gcc Patch List, Joseph S. Myers, Jason Merrill

On 21 September 2015 at 02:24, Manuel López-Ibáñez
<lopezibanez@gmail.com> wrote:
> On 21 September 2015 at 02:22, Christophe Lyon
> <christophe.lyon@linaro.org> wrote:
>> It works for me if I replace 24 by 62.
>
> Wierd. What is the actual output of the compiler?

Here is what I have in gcc.log:
/home/christophe.lyon/src/GCC/sources/gcc-fsf/trunk/gcc/testsuite/gcc.dg/pragma-diag-5.c:2:62:
warning: missing [error|warning|ignored|push|pop] after '#pragma GCC
diagnostic' [-Wpragmas]^M
/home/christophe.lyon/src/GCC/sources/gcc-fsf/trunk/gcc/testsuite/gcc.dg/pragma-diag-5.c:5:24:
warning: expected [error|warning|ignored|push|pop] after '#pragma GCC
diagnostic' [-Wpragmas]^M
/home/christophe.lyon/src/GCC/sources/gcc-fsf/trunk/gcc/testsuite/gcc.dg/pragma-diag-5.c:7:32:
warning: unknown option after '#pragma GCC diagnostic' kind
[-Wpragmas]^M

XPASS: gcc.dg/pragma-diag-5.c missing (test for warnings, line 2)
PASS: gcc.dg/pragma-diag-5.c  (test for warnings, line 5)
PASS: gcc.dg/pragma-diag-5.c  (test for warnings, line 7)
PASS: gcc.dg/pragma-diag-5.c (test for excess errors)

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

* Re: [PATCH c/c++] use explicit locations for some warnings in c-pragma.c
  2015-09-21  0:33             ` Christophe Lyon
@ 2015-09-21  1:46               ` Manuel López-Ibáñez
  2015-09-21  5:50                 ` Christophe Lyon
  0 siblings, 1 reply; 16+ messages in thread
From: Manuel López-Ibáñez @ 2015-09-21  1:46 UTC (permalink / raw)
  To: Christophe Lyon
  Cc: Marek Polacek, Gcc Patch List, Joseph S. Myers, Jason Merrill

On 21 September 2015 at 02:29, Christophe Lyon
<christophe.lyon@linaro.org> wrote:
> On 21 September 2015 at 02:24, Manuel López-Ibáñez
> <lopezibanez@gmail.com> wrote:
>> On 21 September 2015 at 02:22, Christophe Lyon
>> <christophe.lyon@linaro.org> wrote:
>>> It works for me if I replace 24 by 62.
>>
>> Wierd. What is the actual output of the compiler?
>
> Here is what I have in gcc.log:

Is this with my original patch or after your change? I would be
interested in seeing the output with the patch I sent.

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

* Re: [PATCH c/c++] use explicit locations for some warnings in c-pragma.c
  2015-09-21  1:46               ` Manuel López-Ibáñez
@ 2015-09-21  5:50                 ` Christophe Lyon
  2015-09-21 12:32                   ` Manuel López-Ibáñez
  0 siblings, 1 reply; 16+ messages in thread
From: Christophe Lyon @ 2015-09-21  5:50 UTC (permalink / raw)
  To: Manuel López-Ibáñez
  Cc: Marek Polacek, Gcc Patch List, Joseph S. Myers, Jason Merrill

On 21 September 2015 at 02:33, Manuel López-Ibáñez
<lopezibanez@gmail.com> wrote:
> On 21 September 2015 at 02:29, Christophe Lyon
> <christophe.lyon@linaro.org> wrote:
>> On 21 September 2015 at 02:24, Manuel López-Ibáñez
>> <lopezibanez@gmail.com> wrote:
>>> On 21 September 2015 at 02:22, Christophe Lyon
>>> <christophe.lyon@linaro.org> wrote:
>>>> It works for me if I replace 24 by 62.
>>>
>>> Wierd. What is the actual output of the compiler?
>>
>> Here is what I have in gcc.log:
>
> Is this with my original patch or after your change? I would be
> interested in seeing the output with the patch I sent.

It looks like I mis-applied your patch.
I cleaned up and re-applied it, and I can confirm it fixes the problem.

Thanks
Christophe

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

* Re: [PATCH c/c++] use explicit locations for some warnings in c-pragma.c
  2015-09-21  5:50                 ` Christophe Lyon
@ 2015-09-21 12:32                   ` Manuel López-Ibáñez
  0 siblings, 0 replies; 16+ messages in thread
From: Manuel López-Ibáñez @ 2015-09-21 12:32 UTC (permalink / raw)
  To: Christophe Lyon
  Cc: Marek Polacek, Gcc Patch List, Joseph S. Myers, Jason Merrill

On 21 September 2015 at 06:52, Christophe Lyon
<christophe.lyon@linaro.org> wrote:
> It looks like I mis-applied your patch.
> I cleaned up and re-applied it, and I can confirm it fixes the problem.

Committed as obvious as r227967.

Thanks,

Manuel.

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

* Re: [PATCH c/c++] use explicit locations for some warnings in c-pragma.c
  2015-09-20 22:35       ` Manuel López-Ibáñez
  2015-09-21  0:24         ` Christophe Lyon
@ 2015-11-04  9:46         ` Mike Stump
  2015-11-04 21:02           ` Manuel López-Ibáñez
  1 sibling, 1 reply; 16+ messages in thread
From: Mike Stump @ 2015-11-04  9:46 UTC (permalink / raw)
  To: Manuel López-Ibáñez
  Cc: Christophe Lyon, Marek Polacek, Gcc Patch List, Joseph S. Myers,
	Jason Merrill

On Sep 20, 2015, at 2:40 PM, Manuel López-Ibáñez <lopezibanez@gmail.com> wrote:
> On 20 September 2015 at 22:32, Christophe Lyon
> <christophe.lyon@linaro.org> wrote:
>> On 25 May 2015 at 22:16, Manuel López-Ibáñez <lopezibanez@gmail.com> wrote:
>>> On 25 May 2015 at 21:56, Marek Polacek <polacek@redhat.com> wrote:
>>>> Perhaps we should introduce GCC_BAD_LOC with a location_t argument and use it
>>>> here.
>>> 
>>> Why would we want to obfuscate code like that? I would propose to
>>> actually remove GCC_BAD completely.
>>> 
>> Hi
>> It looks like this patch has finally been committed on 2015-09-18
>> (r227923), right?
> 
> Yes, I had almost forgotten about it.
> 
>> I'm not sure why, since the 1st warning is xfail.
> 
> Strange that I missed this, but I can see it now. (Well, not so
> strange, contrib/compare_tests sometimes produces nonsense)
> 
> Could you try with this patch? It seems to work for me. I'll commit it
> as obvious if it works for you too.
> 
> Index: gcc/testsuite/gcc.dg/pragma-diag-5.c
> ===================================================================
> --- gcc/testsuite/gcc.dg/pragma-diag-5.c        (revision 227932)
> +++ gcc/testsuite/gcc.dg/pragma-diag-5.c        (working copy)
> @@ -1,6 +1,7 @@
> /* { dg-do compile } */
> -#pragma GCC diagnostic /* { dg-warning "24:missing" "missing" { xfail
> *-*-* } } */
> +#pragma GCC diagnostic /* { dg-warning "missing" "missing" } */
> +/* { dg-warning "24:missing" "missing" { xfail *-*-* }  2 } */
> 
> #pragma GCC diagnostic warn /* { dg-warning "24:expected" } */
> 
> #pragma GCC diagnostic ignored "-Wfoo" /* { dg-warning "32:unknown" } */

I see:

gcc/gcc/testsuite/gcc.dg/pragma-diag-5.c:2:64: warning: missing [error|warning|ignored|push|pop] after '#pragma GCC diagnostic' [-Wpragmas]
gcc/gcc/testsuite/gcc.dg/pragma-diag-5.c:5:24: warning: expected [error|warning|ignored|push|pop] after '#pragma GCC diagnostic' [-Wpragmas]
gcc/gcc/testsuite/gcc.dg/pragma-diag-5.c:7:32: warning: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]
output is:
gcc/gcc/testsuite/gcc.dg/pragma-diag-5.c:2:64: warning: missing [error|warning|ignored|push|pop] after '#pragma GCC diagnostic' [-Wpragmas]
gcc/gcc/testsuite/gcc.dg/pragma-diag-5.c:5:24: warning: expected [error|warning|ignored|push|pop] after '#pragma GCC diagnostic' [-Wpragmas]
gcc/gcc/testsuite/gcc.dg/pragma-diag-5.c:7:32: warning: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]

PASS: gcc.dg/pragma-diag-5.c missing (test for warnings, line 2)
XFAIL: gcc.dg/pragma-diag-5.c missing (test for warnings, line 2)
PASS: gcc.dg/pragma-diag-5.c  (test for warnings, line 5)
PASS: gcc.dg/pragma-diag-5.c  (test for warnings, line 7)
PASS: gcc.dg/pragma-diag-5.c (test for excess errors)

in the top of the tree.  This is bad as the same line appears in a PASS: and an XFAIL:.  Each test case should be unique.  Should it be updated to 64?

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

* Re: [PATCH c/c++] use explicit locations for some warnings in c-pragma.c
  2015-11-04  9:46         ` Mike Stump
@ 2015-11-04 21:02           ` Manuel López-Ibáñez
  2015-11-06 21:16             ` Mike Stump
  2015-11-06 21:18             ` Mike Stump
  0 siblings, 2 replies; 16+ messages in thread
From: Manuel López-Ibáñez @ 2015-11-04 21:02 UTC (permalink / raw)
  To: Mike Stump
  Cc: Christophe Lyon, Marek Polacek, Gcc Patch List, Joseph S. Myers,
	Jason Merrill

On 4 November 2015 at 09:45, Mike Stump <mrs@mrs.kithrup.com> wrote:
> in the top of the tree.  This is bad as the same line appears in a PASS: and an XFAIL:.  Each test case should be unique.  Should it be updated to 64?

I think it is sufficient to change it to:

/* { dg-warning "24:missing" "wrong column" { xfail *-*-* }  2 } */

This dg-warning is there to show that the column number is wrong and
tell whoever fixes this that there is already a test that only needs
updating. Changing 24 to 64 defeats the purpose of having it in the
first place.

Cheers,

Manuel.

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

* Re: [PATCH c/c++] use explicit locations for some warnings in c-pragma.c
  2015-11-04 21:02           ` Manuel López-Ibáñez
@ 2015-11-06 21:16             ` Mike Stump
  2015-11-06 21:18             ` Mike Stump
  1 sibling, 0 replies; 16+ messages in thread
From: Mike Stump @ 2015-11-06 21:16 UTC (permalink / raw)
  To: Manuel López-Ibáñez
  Cc: Christophe Lyon, Marek Polacek, Gcc Patch List, Joseph S. Myers,
	Jason Merrill


On Nov 4, 2015, at 1:02 PM, Manuel López-Ibáñez <lopezibanez@gmail.com> wrote:

> 24:missing

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

* Re: [PATCH c/c++] use explicit locations for some warnings in c-pragma.c
  2015-11-04 21:02           ` Manuel López-Ibáñez
  2015-11-06 21:16             ` Mike Stump
@ 2015-11-06 21:18             ` Mike Stump
  1 sibling, 0 replies; 16+ messages in thread
From: Mike Stump @ 2015-11-06 21:18 UTC (permalink / raw)
  To: Manuel López-Ibáñez
  Cc: Christophe Lyon, Marek Polacek, Gcc Patch List, Joseph S. Myers,
	Jason Merrill

On Nov 4, 2015, at 1:02 PM, Manuel López-Ibáñez <lopezibanez@gmail.com> wrote:
> On 4 November 2015 at 09:45, Mike Stump <mrs@mrs.kithrup.com> wrote:
>> in the top of the tree.  This is bad as the same line appears in a PASS: and an XFAIL:.  Each test case should be unique.  Should it be updated to 64?
> 
> I think it is sufficient to change it to:
> 
> /* { dg-warning "24:missing" "wrong column" { xfail *-*-* }  2 } */

I tested this out, works just fine.

2015-11-06  Mike Stump  <mikestump@comcast.net>

	* gcc.dg/pragma-diag-5.c: Make test cases unique.

Index: testsuite/gcc.dg/pragma-diag-5.c
===================================================================
--- testsuite/gcc.dg/pragma-diag-5.c	(revision 229885)
+++ testsuite/gcc.dg/pragma-diag-5.c	(working copy)
@@ -1,6 +1,6 @@
 /* { dg-do compile } */
 #pragma GCC diagnostic /* { dg-warning "missing" "missing" } */
-/* { dg-warning "24:missing" "missing" { xfail *-*-* }  2 } */
+/* { dg-warning "24:missing" "wrong column" { xfail *-*-* }  2 } */
 
 #pragma GCC diagnostic warn /* { dg-warning "24:expected" } */
 
Committed revision 229891.

Thanks for your help.

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

end of thread, other threads:[~2015-11-06 21:18 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-25 17:47 [PATCH c/c++] use explicit locations for some warnings in c-pragma.c Manuel López-Ibáñez
2015-05-25 19:48 ` Jason Merrill
2015-05-25 20:17 ` Marek Polacek
2015-05-25 20:55   ` Manuel López-Ibáñez
2015-09-20 20:38     ` Christophe Lyon
2015-09-20 22:35       ` Manuel López-Ibáñez
2015-09-21  0:24         ` Christophe Lyon
2015-09-21  0:29           ` Manuel López-Ibáñez
2015-09-21  0:33             ` Christophe Lyon
2015-09-21  1:46               ` Manuel López-Ibáñez
2015-09-21  5:50                 ` Christophe Lyon
2015-09-21 12:32                   ` Manuel López-Ibáñez
2015-11-04  9:46         ` Mike Stump
2015-11-04 21:02           ` Manuel López-Ibáñez
2015-11-06 21:16             ` Mike Stump
2015-11-06 21:18             ` Mike Stump

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