In gcc/testsuite/: 2011-03-04 Nicola Pero <nicola.pero@meta-innovation.com>
[official-gcc.git] / gcc / testsuite / gcc.dg / Walways-true-1.c
blob4aa5d39abbd0657cdb9d55341f44dbb99fc529bc
1 /* Test -Waddress for testing an address against NULL.
2 Origin: Ian Lance Taylor <iant@google.com>. */
4 /* { dg-do compile } */
5 /* { dg-options "-Waddress -fshow-column" } */
7 extern int foo (int);
9 int i;
11 void
12 bar (int a)
14 lab:
15 if (foo) /* { dg-warning "7:always evaluate as" "correct warning" } */
16 foo (0);
17 if (foo (1))
19 if (&i) /* { dg-warning "7:always evaluate as" "correct warning" } */
20 foo (2);
21 if (i)
22 foo (3);
23 if (&a) /* { dg-warning "7:always evaluate as" "correct warning" } */
24 foo (4);
25 if (a)
26 foo (5);
27 if (&&lab) /* { dg-warning "7:always evaluate as" "correct warning" } */
28 foo (6);
29 if (foo == 0) /* { dg-warning "11:the comparison will always evaluate as 'false'" "correct warning" } */
30 foo (7);
31 if (foo (1) == 0)
32 foo (8);
33 if (&i == 0) /* { dg-warning "10:the comparison will always evaluate as 'false'" "correct warning" } */
34 foo (9);
35 if (i == 0)
36 foo (10);
37 if (&a == 0) /* { dg-warning "10:the comparison will always evaluate as 'false'" "correct warning" } */
38 foo (11);
39 if (a == 0)
40 foo (12);
41 if (&&lab == 0) /* { dg-warning "13:the comparison will always evaluate as 'false'" "correct warning" } */
42 foo (13);
43 if (0 == foo) /* { dg-warning "9:the comparison will always evaluate as 'false'" "correct warning" } */
44 foo (14);
45 if (0 == foo (1))
46 foo (15);
47 if (0 == &i) /* { dg-warning "9:the comparison will always evaluate as 'false'" "correct warning" } */
48 foo (16);
49 if (0 == i)
50 foo (17);
51 if (0 == &a) /* { dg-warning "9:the comparison will always evaluate as 'false'" "correct warning" } */
52 foo (18);
53 if (0 == a)
54 foo (19);
55 if (0 == &&lab) /* { dg-warning "9:the comparison will always evaluate as 'false'" "correct warning" } */
56 foo (20);