xref: /illumos-gate/usr/src/tools/smatch/src/validation/preprocessor/preprocessor3.c (revision 1f5207b7604fb44407eb4342aff613f7c4508508)
1 /*
2  * Each iteration of the scanning of "SCAN()" re-evaluates the recursive
3  * B->A->B expansion.
4  *
5  * Did I already mention that the C preprocessor language
6  * is a perverse thing?
7  */
8 
9 #define LP (
10 
11 #define A() B LP )
12 #define B() A LP )
13 
14 #define SCAN(x) x
15 
16 A()                     // B ( )
17 SCAN( A() )             // A ( )
18 SCAN(SCAN( A() ))       // B ( )
19 SCAN(SCAN(SCAN( A() ))) // A ( )
20 /*
21  * check-name: Preprocessor #3
22  * check-description: Sparse used to get this wrong, outputting A third, not B.
23  * check-command: sparse -E $file
24  *
25  * check-output-start
26 
27 B ( )
28 A ( )
29 B ( )
30 A ( )
31  * check-output-end
32  */
33