1 /* PR c/81448 */
2 /* { dg-do compile } */
3 /* { dg-options "-Wmultistatement-macros" } */
4 
5 extern int i;
6 
7 #define BAD4 i++; i++ /* { dg-warning "macro expands to multiple statements" } */
8 #define BAD5 i++; i++ /* { dg-warning "macro expands to multiple statements" } */
9 #define BAD6 i++; i++ /* { dg-warning "macro expands to multiple statements" } */
10 #define BAD7 i++; i++ /* { dg-warning "macro expands to multiple statements" } */
11 #define BAD8 i++; i++ /* { dg-warning "macro expands to multiple statements" } */
12 #define BAD9 i++; i++ /* { dg-warning "macro expands to multiple statements" } */
13 #define IF if (1) /* { dg-message "not guarded by this 'if' clause" } */
14 #define IF2 IF /* { dg-message "in expansion of macro .IF." } */
15 #define BADB7 BAD7 /* { dg-message "in expansion of macro .BAD7." } */
16 #define BADB8 BAD8 /* { dg-message "in expansion of macro .BAD8." } */
17 #define BADB9 BAD9 /* { dg-message "in expansion of macro .BAD9." } */
18 
19 #define FN0				\
20 void fn0 (void)				\
21 {					\
22   IF					\
23     i++;				\
24   return;				\
25 }
26 
27 #define FN1				\
28 void fn1 (void)				\
29 {					\
30   IF2					\
31     i++;				\
32   return;				\
33 }
34 
35 #define FN2				\
36 void fn2 (void)				\
37 {					\
38   if (1)				\
39     i++;				\
40   return;				\
41 }
42 
43 #define TOP FN3
44 #define FN3				\
45 void fn3 (void)				\
46 {					\
47   IF					\
48     i++;				\
49   return;				\
50 }
51 
52 #define TOP2 FN4 /* { dg-message "in expansion of macro .FN4." } */
53 #define FN4				\
54 void fn4 (void)				\
55 {					\
56   IF2 /* { dg-message "in expansion of macro .IF2." } */ \
57     BAD4; /* { dg-message "in expansion of macro .BAD4." } */ \
58 }
59 
60 #define FN5				\
61 void fn5 (void)				\
62 {					\
63   IF /* { dg-message "in expansion of macro .IF." } */	\
64     BAD5; /* { dg-message "in expansion of macro .BAD5." } */ \
65 }
66 
67 #define FN6				\
68 void fn6 (void)				\
69 {					\
70   if (1) /* { dg-message "not guarded by this 'if' clause" } */ \
71     BAD6; /* { dg-message "in expansion of macro .BAD6." } */ \
72 }
73 
74 #define FN7				\
75 void fn7 (void)				\
76 {					\
77   if (1) /* { dg-message "not guarded by this 'if' clause" } */	\
78     BADB7; /* { dg-message "in expansion of macro .BADB7." } */ \
79 }
80 
81 #define FN8				\
82 void fn8 (void)				\
83 {					\
84   IF2 /* { dg-message "in expansion of macro .IF2." } */ \
85     BADB8; /* { dg-message "in expansion of macro .BADB8." } */ \
86 }
87 
88 #define FN9				\
89 void fn9 (void)				\
90 {					\
91   IF /* { dg-message "in expansion of macro .IF." } */ \
92     BADB9; /* { dg-message "in expansion of macro .BADB9." } */	\
93 }
94 
95 FN0
96 FN1
97 FN2
98 TOP
99 TOP2 /* { dg-message "in expansion of macro .TOP2." } */
100 FN5 /* { dg-message "in expansion of macro .FN5." } */
101 FN6 /* { dg-message "in expansion of macro .FN6." } */
102 FN7 /* { dg-message "in expansion of macro .FN7." } */
103 FN8 /* { dg-message "in expansion of macro .FN8." } */
104 FN9 /* { dg-message "in expansion of macro .FN9." } */
105