Fix ICE in substring-handling building 502.gcc_r (PR 87562)
[official-gcc.git] / gcc / testsuite / c-c++-common / Wmultistatement-macros-8.c
blob06522a7d737bbca43c8bb1f5c01b07c8c94c2851
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 for (i = 0; i < 1; ++i) /* { dg-message "not guarded by this 'for' clause" } */ \
12 SWAP (x, y) /* { dg-message "in expansion of macro .SWAP." } */
14 #define M2 \
15 for (i = 0; i < 1; ++i) \
16 x++
18 #define M3 \
19 for (i = 0; i < 1; ++i) \
20 x++;;
22 #define M4 \
23 for (i = 0; i < 1; ++i) /* { dg-message "not guarded by this 'for' clause" } */ \
24 L1: \
25 SWAP (x, y) /* { dg-message "in expansion of macro .SWAP." } */
27 #define INC \
28 x++;;
30 int x, y, tmp;
32 void
33 fn0 (void)
35 int i;
36 for (i = 0; i < 1; ++i) /* { dg-message "not guarded by this 'for' clause" } */
37 SWAP (x, y); /* { dg-message "in expansion of macro .SWAP." } */
39 for (i = 0; i < 1; ++i) /* { dg-message "not guarded by this 'for' clause" } */
41 SWAP (x, y); /* { dg-message "in expansion of macro .SWAP." } */
42 goto L;
45 void
46 fn1 (void)
48 int i;
49 M1; /* { dg-message "in expansion of macro .M1." } */
50 M2;
51 M3;
52 M4; /* { dg-message "in expansion of macro .M4." } */
53 goto L1;
56 void
57 fn2 (void)
59 for (int i = 0; i < 1; ++i)
60 INC
62 for (int i = 0; i < 1; ++i)
63 ({ x = 10; x++; });