public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Doubt regarding dg-directives
@ 2022-02-22 11:42 Krishna Narayanan
  2022-02-22 14:31 ` Jonathan Wakely
  0 siblings, 1 reply; 11+ messages in thread
From: Krishna Narayanan @ 2022-02-22 11:42 UTC (permalink / raw)
  To: gcc-help

Hello,
I had been working on a testcase,in which there had to be a warning on
a specific line. On giving the /* { dg warning "text" } */ to that
line ,the test outcome is FAIL(test for warnings) even though the
warning was expected.
Can you help me out with this,why did this happen?
Thanks,
Krishna Narayanan.

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

* Re: Doubt regarding dg-directives
  2022-02-22 11:42 Doubt regarding dg-directives Krishna Narayanan
@ 2022-02-22 14:31 ` Jonathan Wakely
  2022-02-22 14:32   ` Jonathan Wakely
  0 siblings, 1 reply; 11+ messages in thread
From: Jonathan Wakely @ 2022-02-22 14:31 UTC (permalink / raw)
  To: Krishna Narayanan; +Cc: gcc-help

On Tue, 22 Feb 2022 at 11:43, Krishna Narayanan via Gcc-help <
gcc-help@gcc.gnu.org> wrote:

> Hello,
> I had been working on a testcase,in which there had to be a warning on
> a specific line. On giving the /* { dg warning "text" } */ to that
>


That should be dg-warning, did you get it right in the test?


> line ,the test outcome is FAIL(test for warnings) even though the
> warning was expected.
> Can you help me out with this,why did this happen?
> Thanks,
> Krishna Narayanan.
>

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

* Re: Doubt regarding dg-directives
  2022-02-22 14:31 ` Jonathan Wakely
@ 2022-02-22 14:32   ` Jonathan Wakely
  2022-02-22 15:38     ` Krishna Narayanan
  0 siblings, 1 reply; 11+ messages in thread
From: Jonathan Wakely @ 2022-02-22 14:32 UTC (permalink / raw)
  To: Krishna Narayanan; +Cc: gcc-help

On Tue, 22 Feb 2022 at 14:31, Jonathan Wakely wrote:

>
>
> On Tue, 22 Feb 2022 at 11:43, Krishna Narayanan via Gcc-help <
> gcc-help@gcc.gnu.org> wrote:
>
>> Hello,
>> I had been working on a testcase,in which there had to be a warning on
>> a specific line. On giving the /* { dg warning "text" } */ to that
>>
>
>
> That should be dg-warning, did you get it right in the test?
>
>
>> line ,the test outcome is FAIL(test for warnings) even though the
>> warning was expected.
>>
>
And does the warning actually happen? dg-warning says a warning is
expected, so the test will fail if no warning happens.

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

* Re: Doubt regarding dg-directives
  2022-02-22 14:32   ` Jonathan Wakely
@ 2022-02-22 15:38     ` Krishna Narayanan
  2022-02-22 15:44       ` Segher Boessenkool
  2022-02-22 16:14       ` Jonathan Wakely
  0 siblings, 2 replies; 11+ messages in thread
From: Krishna Narayanan @ 2022-02-22 15:38 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: gcc-help

Yes, it does.
I used dg-warning and not dg warning (that was a sheer typing mistake).
The warning is about the uninitialized variable being used in the
testcase yet there is no warning on that line and the test results in
FAIL.
I used /* { dg-warning "uninitialized" } */ on that particular line.I
used the test in gcc.dg, with other directive /* { dg-options "-O2" }
*/ .
Can you help me where I went wrong?
Thanks,
Krishna Narayanan


On Tue, Feb 22, 2022 at 8:03 PM Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>
>
>
> On Tue, 22 Feb 2022 at 14:31, Jonathan Wakely wrote:
>>
>>
>>
>> On Tue, 22 Feb 2022 at 11:43, Krishna Narayanan via Gcc-help <gcc-help@gcc.gnu.org> wrote:
>>>
>>> Hello,
>>> I had been working on a testcase,in which there had to be a warning on
>>> a specific line. On giving the /* { dg warning "text" } */ to that
>>
>>
>>
>> That should be dg-warning, did you get it right in the test?
>>
>>>
>>> line ,the test outcome is FAIL(test for warnings) even though the
>>> warning was expected.
>
>
> And does the warning actually happen? dg-warning says a warning is expected, so the test will fail if no warning happens.
>
>

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

* Re: Doubt regarding dg-directives
  2022-02-22 15:38     ` Krishna Narayanan
@ 2022-02-22 15:44       ` Segher Boessenkool
  2022-02-22 18:30         ` Krishna Narayanan
  2022-02-22 16:14       ` Jonathan Wakely
  1 sibling, 1 reply; 11+ messages in thread
From: Segher Boessenkool @ 2022-02-22 15:44 UTC (permalink / raw)
  To: Krishna Narayanan; +Cc: Jonathan Wakely, gcc-help

On Tue, Feb 22, 2022 at 09:08:40PM +0530, Krishna Narayanan via Gcc-help wrote:
> Yes, it does.
> I used dg-warning and not dg warning (that was a sheer typing mistake).
> The warning is about the uninitialized variable being used in the
> testcase yet there is no warning on that line and the test results in
> FAIL.
> I used /* { dg-warning "uninitialized" } */ on that particular line.I
> used the test in gcc.dg, with other directive /* { dg-options "-O2" }
> */ .
> Can you help me where I went wrong?

Please send the verbatim testcase (and don't top-post please).  Guessing
is a fun game sometimes, but more often it is just frustrating.


Segher

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

* Re: Doubt regarding dg-directives
  2022-02-22 15:38     ` Krishna Narayanan
  2022-02-22 15:44       ` Segher Boessenkool
@ 2022-02-22 16:14       ` Jonathan Wakely
  2022-02-23  7:39         ` Krishna Narayanan
  1 sibling, 1 reply; 11+ messages in thread
From: Jonathan Wakely @ 2022-02-22 16:14 UTC (permalink / raw)
  To: Krishna Narayanan; +Cc: gcc-help

On Tue, 22 Feb 2022 at 15:38, Krishna Narayanan wrote:

> Yes, it does.
> I used dg-warning and not dg warning (that was a sheer typing mistake).
> The warning is about the uninitialized variable being used in the
> testcase yet there is no warning on that line and the test results in
> FAIL.
> I used /* { dg-warning "uninitialized" } */ on that particular line.I
> used the test in gcc.dg, with other directive /* { dg-options "-O2" }
> */ .
> Can you help me where I went wrong?
>

Don't you need -Wuninitialized in the dg-options as well?

Like Segher said, show us the test. Asking us to debug your test without
seeing it is going to be slow.

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

* Re: Doubt regarding dg-directives
  2022-02-22 15:44       ` Segher Boessenkool
@ 2022-02-22 18:30         ` Krishna Narayanan
  2022-02-23  0:32           ` Segher Boessenkool
  0 siblings, 1 reply; 11+ messages in thread
From: Krishna Narayanan @ 2022-02-22 18:30 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: Jonathan Wakely, gcc-help

On Tue, Feb 22, 2022 at 9:16 PM Segher Boessenkool
<segher@kernel.crashing.org> wrote:
>
> On Tue, Feb 22, 2022 at 09:08:40PM +0530, Krishna Narayanan via Gcc-help wrote:
> > Yes, it does.
> > I used dg-warning and not dg warning (that was a sheer typing mistake).
> > The warning is about the uninitialized variable being used in the
> > testcase yet there is no warning on that line and the test results in
> > FAIL.
> > I used /* { dg-warning "uninitialized" } */ on that particular line.I
> > used the test in gcc.dg, with other directive /* { dg-options "-O2" }
> > */ .
> > Can you help me where I went wrong?
>
> Please send the verbatim testcase (and don't top-post please).  Guessing
> is a fun game sometimes, but more often it is just frustrating.
/* { dg-do compile } */
/* { dg-options "-O2" } */
 int test(int y) {
    int z;
    int x;
    int a;
    for (x = 0; x < 10; x = x + 1, y = y + 1,a = a + 1)
    {
        if (y < 10) {
            z = z + 1 + a; /* { dg-warning "uninitialized" } */
        }
    }
    return z;
}
Here is the test case,I apologize for the inconvenience caused earlier
due to indirect context.
Thanks,
Krishna Narayanan.

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

* Re: Doubt regarding dg-directives
  2022-02-22 18:30         ` Krishna Narayanan
@ 2022-02-23  0:32           ` Segher Boessenkool
  0 siblings, 0 replies; 11+ messages in thread
From: Segher Boessenkool @ 2022-02-23  0:32 UTC (permalink / raw)
  To: Krishna Narayanan; +Cc: Jonathan Wakely, gcc-help

On Wed, Feb 23, 2022 at 12:00:47AM +0530, Krishna Narayanan wrote:
> On Tue, Feb 22, 2022 at 9:16 PM Segher Boessenkool
> <segher@kernel.crashing.org> wrote:
> >
> > On Tue, Feb 22, 2022 at 09:08:40PM +0530, Krishna Narayanan via Gcc-help wrote:
> > > Yes, it does.
> > > I used dg-warning and not dg warning (that was a sheer typing mistake).
> > > The warning is about the uninitialized variable being used in the
> > > testcase yet there is no warning on that line and the test results in
> > > FAIL.
> > > I used /* { dg-warning "uninitialized" } */ on that particular line.I
> > > used the test in gcc.dg, with other directive /* { dg-options "-O2" }
> > > */ .
> > > Can you help me where I went wrong?
> >
> > Please send the verbatim testcase (and don't top-post please).  Guessing
> > is a fun game sometimes, but more often it is just frustrating.
> /* { dg-do compile } */
> /* { dg-options "-O2" } */
>  int test(int y) {
>     int z;
>     int x;
>     int a;
>     for (x = 0; x < 10; x = x + 1, y = y + 1,a = a + 1)
>     {
>         if (y < 10) {
>             z = z + 1 + a; /* { dg-warning "uninitialized" } */
>         }
>     }
>     return z;
> }

Thanks.  As Jonathan said, you need to enable this warning in the
options, the testsuite does not enable more warnings than GCC does
itself.


Segher

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

* Re: Doubt regarding dg-directives
  2022-02-22 16:14       ` Jonathan Wakely
@ 2022-02-23  7:39         ` Krishna Narayanan
  2022-02-23  8:16           ` Jonathan Wakely
  0 siblings, 1 reply; 11+ messages in thread
From: Krishna Narayanan @ 2022-02-23  7:39 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: gcc-help, Segher Boessenkool

On Tue, Feb 22, 2022 at 9:44 PM Jonathan Wakely <jwakely.gcc@gmail.com>
wrote:

> On Tue, 22 Feb 2022 at 15:38, Krishna Narayanan wrote:
>
>> Yes, it does.
>> I used dg-warning and not dg warning (that was a sheer typing mistake).
>> The warning is about the uninitialized variable being used in the
>> testcase yet there is no warning on that line and the test results in
>> FAIL.
>> I used /* { dg-warning "uninitialized" } */ on that particular line.I
>> used the test in gcc.dg, with other directive /* { dg-options "-O2" }
>> */ .
>> Can you help me where I went wrong?
>>
>
> Don't you need -Wuninitialized in the dg-options as well?
>
 Yes I tried it with /* { dg-options "-O2 -Wuninitialized" } */ but still
>> it FAILs.I even tried using -Wmaybe-uninitialized still the outcome is
>> same(FAIL:test for warnings), On trying with /* { dg-bogus "uninitialized"
>> } */ on the particular line it FAILs saying (test for excess errors) and
>> (test for bogus messages) which means it was not expecting a warning but
>> warning arises due to which it FAILs. So why did the initial dg-warning not
>> pass the test ?                                               Thanks,
>>
>>
>>
>>          Krishna Narayanan.
>>
>
>
>

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

* Re: Doubt regarding dg-directives
  2022-02-23  7:39         ` Krishna Narayanan
@ 2022-02-23  8:16           ` Jonathan Wakely
  2022-02-23 13:47             ` Krishna Narayanan
  0 siblings, 1 reply; 11+ messages in thread
From: Jonathan Wakely @ 2022-02-23  8:16 UTC (permalink / raw)
  To: Krishna Narayanan; +Cc: gcc-help, Segher Boessenkool

On Wed, 23 Feb 2022 at 07:39, Krishna Narayanan <
krishnanarayanan132002@gmail.com> wrote:

>
>
> On Tue, Feb 22, 2022 at 9:44 PM Jonathan Wakely <jwakely.gcc@gmail.com>
> wrote:
>
>> On Tue, 22 Feb 2022 at 15:38, Krishna Narayanan wrote:
>>
>>> Yes, it does.
>>> I used dg-warning and not dg warning (that was a sheer typing mistake).
>>> The warning is about the uninitialized variable being used in the
>>> testcase yet there is no warning on that line and the test results in
>>> FAIL.
>>> I used /* { dg-warning "uninitialized" } */ on that particular line.I
>>> used the test in gcc.dg, with other directive /* { dg-options "-O2" }
>>> */ .
>>> Can you help me where I went wrong?
>>>
>>
>> Don't you need -Wuninitialized in the dg-options as well?
>>
>

> Yes I tried it with /* { dg-options "-O2 -Wuninitialized" } */ but still
it FAILs.

Yes, but it fails differently now. You need to read the output more
carefully. Look at the gcc.log file, which shows you the full output. When
you enable warnings there are TWO warnings printed. You are only testing
for one.

You can also compile the test by hand using the same options. What happens?
You get TWO warnings. You only tested for one. So it's going to FAIL.

The log file should show something like this:

PASS: test.c  (test for warnings, line 10)
FAIL: test.c (test for excess errors)
Excess errors:
test.c:6: warning: 'a' may be used uninitialized [-Wmaybe-uninitialized]

That means it matched the dg-warning on line 10, but there was also another
warning on line 6, which dejagnu thinks was unexpected (because you didn't
tell it to expect it or to ignore it). That makes the test fail.

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

* Re: Doubt regarding dg-directives
  2022-02-23  8:16           ` Jonathan Wakely
@ 2022-02-23 13:47             ` Krishna Narayanan
  0 siblings, 0 replies; 11+ messages in thread
From: Krishna Narayanan @ 2022-02-23 13:47 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: gcc-help, Segher Boessenkool

On Wed, Feb 23, 2022 at 1:46 PM Jonathan Wakely <jwakely.gcc@gmail.com>
wrote:

>
>
> On Wed, 23 Feb 2022 at 07:39, Krishna Narayanan <
> krishnanarayanan132002@gmail.com> wrote:
>
>>
>>
>> On Tue, Feb 22, 2022 at 9:44 PM Jonathan Wakely <jwakely.gcc@gmail.com>
>> wrote:
>>
>>> On Tue, 22 Feb 2022 at 15:38, Krishna Narayanan wrote:
>>>
>>>> Yes, it does.
>>>> I used dg-warning and not dg warning (that was a sheer typing mistake).
>>>> The warning is about the uninitialized variable being used in the
>>>> testcase yet there is no warning on that line and the test results in
>>>> FAIL.
>>>> I used /* { dg-warning "uninitialized" } */ on that particular line.I
>>>> used the test in gcc.dg, with other directive /* { dg-options "-O2" }
>>>> */ .
>>>> Can you help me where I went wrong?
>>>>
>>>
>>> Don't you need -Wuninitialized in the dg-options as well?
>>>
>>
>
> > Yes I tried it with /* { dg-options "-O2 -Wuninitialized" } */ but still
> it FAILs.
>
> Yes, but it fails differently now. You need to read the output more
> carefully. Look at the gcc.log file, which shows you the full output. When
> you enable warnings there are TWO warnings printed. You are only testing
> for one.
>
> You can also compile the test by hand using the same options. What
> happens? You get TWO warnings. You only tested for one. So it's going to
> FAIL.
>
> The log file should show something like this:
>
> PASS: test.c  (test for warnings, line 10)
> FAIL: test.c (test for excess errors)
> Excess errors:
> test.c:6: warning: 'a' may be used uninitialized [-Wmaybe-uninitialized]
>
> That means it matched the dg-warning on line 10, but there was also
> another warning on line 6, which dejagnu thinks was unexpected (because you
> didn't tell it to expect it or to ignore it). That makes the test fail.
>
>> Yes understood,all tests have been PASSed,hopefully I should submit a
>> patch(testcase) for the bug,just getting it regtested.
>>
> Thanks a lot,
>>
> Krishna Narayanan
>>
>

>
>

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

end of thread, other threads:[~2022-02-23 13:48 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-22 11:42 Doubt regarding dg-directives Krishna Narayanan
2022-02-22 14:31 ` Jonathan Wakely
2022-02-22 14:32   ` Jonathan Wakely
2022-02-22 15:38     ` Krishna Narayanan
2022-02-22 15:44       ` Segher Boessenkool
2022-02-22 18:30         ` Krishna Narayanan
2022-02-23  0:32           ` Segher Boessenkool
2022-02-22 16:14       ` Jonathan Wakely
2022-02-23  7:39         ` Krishna Narayanan
2022-02-23  8:16           ` Jonathan Wakely
2022-02-23 13:47             ` Krishna Narayanan

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