This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: how to test multiple warnings?
- From: Janis Johnson <janis187 at us dot ibm dot com>
- To: Manuel López-Ibáñez <lopezibanez at gmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 30 Nov 2006 16:14:41 -0800
- Subject: Re: how to test multiple warnings?
- References: <6c33472e0611301125i62882d05n975d44da09c0939b@mail.gmail.com>
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" } */
}