Dear Janis,

I am having problems implementing your proposal.

The following testcase should fail with current mainline for every
dg-bogus.  It actually passes perfectly :-(.  I have tried removing
the  dg-warning tests but then only the first dg-bogus fails, while
the other dg-bogus pass. The results are also unexpected if you remove
only one or two dg-warning.

Any idea of what is going on ?

Cheers,

Manuel.


/* { dg-do compile } */
/* { dg-options "-std=c99 -Woverflow" } */

#include <limits.h>

/* Test for duplicated warnings.  */
int
g (void)
{
 return - - - - -INT_MIN; /* { dg-warning "warning: integer overflow
in expression" } */
 /* { dg-bogus "integer overflow in expression.*integer overflow in
expression" "duplicate" { target *-*-* } 10 } */
}

int
g1 (void)
{
 return 2 - (0 * (INT_MAX + 1)); /* { dg-warning "warning: integer
overflow in expression" } */
 /* { dg-bogus "integer overflow in expression.*integer overflow in
expression" "duplicate" { target *-*-* } 17 } */
}

int
g2 (void)
{
 return ((INT_MAX + 1) * 0) - 2; /* { dg-warning "warning: integer
overflow in expression" } */
 /* { dg-bogus "integer overflow in expression.*integer overflow in
expression" "duplicate" { target *-*-* } 24 } */
}



On 01/12/06, Janis Johnson <[EMAIL PROTECTED]> wrote:
On Thu, Nov 30, 2006 at 07:25:47PM +0000, Manuel López-Ibáñez wrote:
> Hi,
>
> PR19978 reports that some overflow warnings are emitted multiple
> times. Like for example,
>
> test.c:6: warning: integer overflow in expression
> test.c:6: warning: integer overflow in expression
> test.c:6: warning: integer overflow in expression
>
> The current testsuite will match any number of those to a single {
> dg-warning }. I don't know whether this is a known limitation, a bug
> on the testsuite or it just needs some magic.

As discussed on IRC, processing of dg-warning and dg-error is done in
code that's part of the DejaGnu project, and it matches all regular
expressions on the line.

> How could I test that exactly one warning was emitted?

Here's a way to treat duplicate messages as errors; the first test case
fails because it has duplicate messages, the second passes.

Janis

/* { dg-do compile } */
#include <limits.h>
int
f (void)
{
  return INT_MAX + 1 - INT_MAX;   /* { dg-bogus "integer overflow in expression.*integer 
overflow in expression" "duplicate" } */
}


/* { dg-do compile } */
#include <limits.h>
int
f (void)
{
  ;   /* { dg-bogus "control reaches end.*control reaches end" "duplicate" } */
}

Reply via email to