Fix ICE in substring-handling building 502.gcc_r (PR 87562)
[official-gcc.git] / gcc / testsuite / c-c++-common / Wmultistatement-macros-10.c
blob766ed25242aade0a1f6a46a3c6c8f1e8eca18ce4
1 /* PR c/80116 */
2 /* { dg-options "-Wmultistatement-macros" } */
3 /* { dg-do compile } */
5 #define SWAP(x, y) \
6 tmp = x; /* { dg-warning "macro expands to multiple statements" } */ \
7 x = y; \
8 y = tmp
10 #define M1 \
11 switch (x) /* { dg-message "not guarded by this 'switch' clause" } */ \
12 case 1: \
13 SWAP (x, y) /* { dg-message "in expansion of macro .SWAP." } */
15 #define M2 \
16 switch (x) \
17 case 1: \
18 x++
20 #define M3 \
21 switch (x) \
22 case 1: \
23 x++;;
25 #define M4 \
26 switch (x) /* { dg-message "not guarded by this 'switch' clause" } */ \
27 L1: \
28 case 1: \
29 SWAP (x, y) /* { dg-message "in expansion of macro .SWAP." } */
31 #define INC \
32 x++;;
34 int x, y, tmp;
36 void
37 fn0 (void)
39 switch (x) /* { dg-message "not guarded by this 'switch' clause" } */
40 case 1:
41 SWAP (x, y); /* { dg-message "in expansion of macro .SWAP." } */
43 switch (x) /* { dg-message "not guarded by this 'switch' clause" } */
44 case 1:
45 case 2:
46 case 3:
47 case 4:
48 case 5:
49 SWAP (x, y); /* { dg-message "in expansion of macro .SWAP." } */
52 void
53 fn1 (void)
55 M1; /* { dg-message "in expansion of macro .M1." } */
56 M2;
57 M3;
58 M4; /* { dg-message "in expansion of macro .M4." } */
59 goto L1;
62 void
63 fn2 (void)
65 switch (x)
66 case 1:
67 INC
69 switch (x)
70 case 1:
71 ({ x = 10; x++; });
74 void
75 fn3 (void)
77 switch (x)
79 case 1:
80 SWAP (x, y);