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