• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: not %clang_cc1 -fsyntax-only -fmacro-backtrace-limit 0 %s 2>&1 | FileCheck %s --check-prefix=ALL
2 // RUN: not %clang_cc1 -fsyntax-only -fmacro-backtrace-limit 2 %s 2>&1 | FileCheck %s --check-prefix=SKIP
3 
4 #define F(x) x + 1
5 #define G(x) F(x) + 2
6 #define ADD(x,y) G(x) + y
7 #define LEVEL4(x) ADD(p,x)
8 #define LEVEL3(x) LEVEL4(x)
9 #define LEVEL2(x) LEVEL3(x)
10 #define LEVEL1(x) LEVEL2(x)
11 
12 int a = LEVEL1(b);
13 
14 // ALL: {{.*}}:12:9: error: use of undeclared identifier 'p'
15 // ALL-NEXT: int a = LEVEL1(b);
16 // ALL-NEXT:         ^
17 // ALL-NEXT: {{.*}}:10:19: note: expanded from macro 'LEVEL1'
18 // ALL-NEXT: #define LEVEL1(x) LEVEL2(x)
19 // ALL-NEXT:                   ^
20 // ALL-NEXT: {{.*}}:9:19: note: expanded from macro 'LEVEL2'
21 // ALL-NEXT: #define LEVEL2(x) LEVEL3(x)
22 // ALL-NEXT:                   ^
23 // ALL-NEXT: {{.*}}:8:19: note: expanded from macro 'LEVEL3'
24 // ALL-NEXT: #define LEVEL3(x) LEVEL4(x)
25 // ALL-NEXT:                   ^
26 // ALL-NEXT: {{.*}}:7:23: note: expanded from macro 'LEVEL4'
27 // ALL-NEXT: #define LEVEL4(x) ADD(p,x)
28 // ALL-NEXT:                       ^
29 // ALL-NEXT: {{.*}}:12:16: error: use of undeclared identifier 'b'
30 // ALL-NEXT: int a = LEVEL1(b);
31 // ALL-NEXT:                ^
32 // ALL-NEXT: 2 errors generated.
33 
34 // SKIP: {{.*}}:12:9: error: use of undeclared identifier 'p'
35 // SKIP-NEXT: int a = LEVEL1(b);
36 // SKIP-NEXT:         ^
37 // SKIP-NEXT: {{.*}}:10:19: note: expanded from macro 'LEVEL1'
38 // SKIP-NEXT: #define LEVEL1(x) LEVEL2(x)
39 // SKIP-NEXT:                   ^
40 // SKIP-NEXT: note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
41 // SKIP-NEXT: {{.*}}:7:23: note: expanded from macro 'LEVEL4'
42 // SKIP-NEXT: #define LEVEL4(x) ADD(p,x)
43 // SKIP-NEXT:                       ^
44 // SKIP-NEXT: {{.*}}:12:16: error: use of undeclared identifier 'b'
45 // SKIP-NEXT: int a = LEVEL1(b);
46 // SKIP-NEXT:                ^
47 // SKIP-NEXT: 2 errors generated.
48