Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / gcc.dg / Wparentheses-3.c
blob64899887c389e4afe78d7e2fc573ad301068448b
1 /* Test operation of -Wparentheses. Warnings for assignments used as
2 truth-values. */
3 /* Origin: Joseph Myers <jsm@polyomino.org.uk> */
5 /* { dg-do compile } */
6 /* { dg-options "-Wparentheses -std=gnu99" } */
8 int foo (int);
10 int a, b, c;
11 _Bool d;
13 int
14 bar (void)
16 if (a = b) /* { dg-warning "assignment" "correct warning" } */
17 foo (0);
18 if ((a = b))
19 foo (1);
20 if (a = a) /* { dg-warning "assignment" "correct warning" } */
21 foo (2);
22 if ((a = a))
23 foo (3);
24 if (b = c) /* { dg-warning "assignment" "correct warning" } */
25 foo (4);
26 else
27 foo (5);
28 if ((b = c))
29 foo (6);
30 else
31 foo (7);
32 if (b = b) /* { dg-warning "assignment" "correct warning" } */
33 foo (8);
34 else
35 foo (9);
36 if ((b = b))
37 foo (10);
38 else
39 foo (11);
40 while (c = b) /* { dg-warning "assignment" "correct warning" } */
41 foo (12);
42 while ((c = b))
43 foo (13);
44 while (c = c) /* { dg-warning "assignment" "correct warning" } */
45 foo (14);
46 while ((c = c))
47 foo (15);
48 do foo (16); while (a = b); /* { dg-warning "assignment" "correct warning" } */
49 do foo (17); while ((a = b));
50 do foo (18); while (a = a); /* { dg-warning "assignment" "correct warning" } */
51 do foo (19); while ((a = a));
52 for (;c = b;) /* { dg-warning "assignment" "correct warning" } */
53 foo (20);
54 for (;(c = b);)
55 foo (21);
56 for (;c = c;) /* { dg-warning "assignment" "correct warning" } */
57 foo (22);
58 for (;(c = c);)
59 foo (23);
60 d = a = b; /* { dg-warning "assignment" "correct warning" } */
61 foo (24);
62 d = (a = b);
63 foo (25);
64 d = a = a; /* { dg-warning "assignment" "correct warning" } */
65 foo (26);
66 d = (a = a);
67 foo (27);