xref: /illumos-gate/usr/src/tools/smatch/src/validation/preprocessor/preprocessor22.c (revision 4c87aefe8930bd07275b8dd2e96ea5f24d93a52e)
1 #define CONFIG_FOO 1
2 
3 #define define_struct(name, fields...) struct fields name;
4 
5 define_struct(a, {
6 #ifdef CONFIG_FOO
7   int b;
8 #elif defined(CONFIG_BAR)
9   int c;
10 #else
11   int d;
12 #endif
13 });
14 /*
15  * check-name: Preprocessor #22
16  *
17  * check-description: Directives are not allowed within a macro argument list,
18  * although cpp deals with it to treat macro more like C functions.
19  *
20  * check-command: sparse -E $file
21  *
22  * check-error-start
23 preprocessor/preprocessor22.c:6:1: error: directive in argument list
24 preprocessor/preprocessor22.c:8:1: error: directive in argument list
25 preprocessor/preprocessor22.c:10:1: error: directive in argument list
26 preprocessor/preprocessor22.c:12:1: error: directive in argument list
27  * check-error-end
28  *
29  * check-output-start
30 
31 struct {
32 int b;
33 } a;;
34  * check-output-end
35  */
36