How to write testcase with two warnings on one line?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to write testcase with two warnings on one line?

Feng Wang
Hi,

I want to write a testcase. The compiler gives two separated warnings on one
statement. How to write this with Dejagnu?

I tried:
 { dg-warning "Warning1" "Warning2" }
and
{ dg-warning "Warning1" 8}
{ dg-warning "Warning2" 8}
8 is the line number of the statment.
But alwarys get excess errors.

The testcase is used to test one patch for gfortran. Sorry have no more
concrete program for this question.


Best Regards,
Feng Wang

--
Creative Compiler Research Group,
National University of Defense Technology, China.


               
___________________________________________________________
??????G????No.1??6???,???????
http://cn.mail.yahoo.com/?id=77072
Reply | Threaded
Open this post in threaded view
|

Re: How to write testcase with two warnings on one line?

Tobias Schlüter
Quoting Feng Wang <[hidden email]>:

> Hi,
>
> I want to write a testcase. The compiler gives two separated warnings on one
> statement. How to write this with Dejagnu?

I don't think this is possible if both warnings are issued for the same location
(which is probably not something we want).  If the loci are different, it is
possible to split the line between the warnings and then proceed as usual, say:
  do_first_thing & ! { dg-warning "a" }
   & do_second_thing ! { dg-warning "b" }

IIRC there are testcases that do just that.

HTH,
- Tobi

Reply | Threaded
Open this post in threaded view
|

回复: Re: How to write testcase with two warnings on one line?

Feng Wang

--- [hidden email]???:

> Quoting Feng Wang <[hidden email]>:
>
> > Hi,
> >
> > I want to write a testcase. The compiler gives two separated warnings on
> one
> > statement. How to write this with Dejagnu?
>
>  If the loci are different, it is
> possible to split the line between the warnings and then proceed as usual,
> say:
>   do_first_thing & ! { dg-warning "a" }
>    & do_second_thing ! { dg-warning "b" }
>

This is ok. Thanks, Tobi.


Best Regards,
Feng Wang

--
Creative Compiler Research Group,
National University of Defense Technology, China.


       

       
               
___________________________________________________________
??????G?????????????,???????????????
http://cn.mail.yahoo.com/?id=77071

Reply | Threaded
Open this post in threaded view
|

Re: How to write testcase with two warnings on one line?

Joseph Myers
In reply to this post by Feng Wang
On Tue, 21 Jun 2005, Feng Wang wrote:

> Hi,
>
> I want to write a testcase. The compiler gives two separated warnings on one
> statement. How to write this with Dejagnu?
>
> I tried:
>  { dg-warning "Warning1" "Warning2" }
> and
> { dg-warning "Warning1" 8}
> { dg-warning "Warning2" 8}
> 8 is the line number of the statment.

The correct way of writing warning tests with a line number is

{ dg-warning "warning" } (on original line, no number needed)
{ dg-warning "warning 2" "description" { target *-*-* } 8 } (for each
other warning)

The description is needed and needs to be nonempty and distinct for the
second and subsequent warnings on a given line, because it is used to form
the distinct test assertion names which appear after PASS or FAIL in the
.sum files - having multiple tests with the same name causes ambiguity for
regression testers.

Listing the warnings separately like this is preferable to using a regular
expression which matches both warnings because this way you detect if just
one of the warnings disappears.

--
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
    [hidden email] (personal mail)
    [hidden email] (CodeSourcery mail)
    [hidden email] (Bugzilla assignments and CCs)
Reply | Threaded
Open this post in threaded view
|

Re: How to write testcase with two warnings on one line?

Feng Wang

--- "Joseph S. Myers" <[hidden email]>???:

> On Tue, 21 Jun 2005, Feng Wang wrote:
>
> > Hi,
> >
> > I want to write a testcase. The compiler gives two separated warnings on
> one
> > statement. How to write this with Dejagnu?
> >
> > I tried:
> >  { dg-warning "Warning1" "Warning2" }
> > and
> > { dg-warning "Warning1" 8}
> > { dg-warning "Warning2" 8}
> > 8 is the line number of the statment.
>
> The correct way of writing warning tests with a line number is
>
> { dg-warning "warning" } (on original line, no number needed)
> { dg-warning "warning 2" "description" { target *-*-* } 8 } (for each
> other warning)
>
> The description is needed and needs to be nonempty and distinct for the
> second and subsequent warnings on a given line, because it is used to form
> the distinct test assertion names which appear after PASS or FAIL in the
> .sum files - having multiple tests with the same name causes ambiguity for
> regression testers.
>
This is ok. Thanks. And add one point, { target *-*-* } is also needed even we
test on all target. If we give the line number, the target is needed. This is
not mentioned in http://gcc.gnu.org/wiki/HowToPrepareATestcase . Maybe the page
need updating.


Best Regards,
Feng Wang

--
Creative Compiler Research Group,
National University of Defense Technology, China.


       

       
               
___________________________________________________________
??????G?????????????,???????????????
http://cn.mail.yahoo.com/?id=77071