blob: 2634d276641313dd3007524261a768606bb1ce9f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
/* { dg-do compile } */
/* { dg-options "-Wtautological-compare -fdiagnostics-show-caret" } */
#define FOO foo
void
fn1 (int foo)
{
if (foo == foo); /* { dg-warning "self-comparison always evaluates to true" } */
/* { dg-begin-multiline-output "" }
if (foo == foo);
^~
{ dg-end-multiline-output "" { target c } } */
/* { dg-begin-multiline-output "" }
if (foo == foo);
~~~ ^~ ~~~
{ dg-end-multiline-output "" { target c++ } } */
}
void
fn2 (int foo)
{
if (FOO == FOO); /* { dg-warning "self-comparison always evaluates to true" } */
/* { dg-begin-multiline-output "" }
if (FOO == FOO);
^~
{ dg-end-multiline-output "" } */
}
void
fn3 (int foo)
{
if ((foo & 16) == 10); /* { dg-warning "bitwise comparison always evaluates to false" } */
/* { dg-begin-multiline-output "" }
if ((foo & 16) == 10);
^~
{ dg-end-multiline-output "" { target c } } */
/* { dg-begin-multiline-output "" }
if ((foo & 16) == 10);
~~~~~~~~~~ ^~ ~~
{ dg-end-multiline-output "" { target c++ } } */
}
|