diff mbox

[c/c++] use explicit locations for some warnings in c-pragma.c

Message ID CAESRpQCe5=ih8-kw-kMg7v+rxLHbfdr3VtGAfbyyPFJ=Fez+aQ@mail.gmail.com
State New
Headers show

Commit Message

Manuel López-Ibáñez Sept. 20, 2015, 9:40 p.m. UTC
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.

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

Cheers,

Manuel.

Comments

Christophe Lyon Sept. 21, 2015, 12:22 a.m. UTC | #1
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.
Manuel López-Ibáñez Sept. 21, 2015, 12:24 a.m. UTC | #2
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?
Christophe Lyon Sept. 21, 2015, 12:29 a.m. UTC | #3
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)
Manuel López-Ibáñez Sept. 21, 2015, 12:33 a.m. UTC | #4
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.
Christophe Lyon Sept. 21, 2015, 4:52 a.m. UTC | #5
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
Manuel López-Ibáñez Sept. 21, 2015, 12:27 p.m. UTC | #6
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.
Mike Stump Nov. 4, 2015, 9:45 a.m. UTC | #7
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?
Manuel López-Ibáñez Nov. 4, 2015, 9:02 p.m. UTC | #8
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.
Mike Stump Nov. 6, 2015, 9:15 p.m. UTC | #9
On Nov 4, 2015, at 1:02 PM, Manuel López-Ibáñez <lopezibanez@gmail.com> wrote:

> 24:missing
diff mbox

Patch

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" } */