Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Preprocessor / warn-macro-undef.c
blobe7d16c836076ac5d894e50b004b0efce5497e9c4
1 // RUN: %clang_cc1 %s -Eonly -Wundef -verify=undef
2 // RUN: %clang_cc1 %s -Eonly -Wundef-prefix=A,BC -verify=undef-prefix
3 // RUN: %clang_cc1 %s -Eonly -Wundef -Wundef-prefix=A,BC -verify=both
4 // RUN: %clang_cc1 %s -Eonly -Werror=undef -verify=undef-error
5 // RUN: %clang_cc1 %s -Eonly -Werror=undef-prefix -Wundef-prefix=A,BC -verify=undef-prefix-error
6 // RUN: %clang_cc1 %s -Eonly -Werror=undef -Wundef-prefix=A,BC -verify=both-error
8 extern int x;
10 #if AB // #1
11 #endif
12 // undef-warning@#1 {{'AB' is not defined, evaluates to 0}}
13 // undef-prefix-warning@#1 {{'AB' is not defined, evaluates to 0}}
14 // both-warning@#1 {{'AB' is not defined, evaluates to 0}}
15 // undef-error-error@#1 {{'AB' is not defined, evaluates to 0}}
16 // undef-prefix-error-error@#1 {{'AB' is not defined, evaluates to 0}}
17 // both-error-error@#1 {{'AB' is not defined, evaluates to 0}}
19 #if B // #2
20 #endif
21 // undef-warning@#2 {{'B' is not defined, evaluates to 0}}
22 // no warning for undef-prefix
23 // both-warning@#2 {{'B' is not defined, evaluates to 0}}
24 // undef-error-error@#2 {{'B' is not defined, evaluates to 0}}
25 // no error for undef-prefix
26 // both-error-error@#2 {{'B' is not defined, evaluates to 0}}
28 #define BC 0
29 #if BC // no warning/error
30 #endif
32 #undef BC
33 #if BC // #3
34 #endif
35 // undef-warning@#3 {{'BC' is not defined, evaluates to 0}}
36 // undef-prefix-warning@#3 {{'BC' is not defined, evaluates to 0}}
37 // both-warning@#3 {{'BC' is not defined, evaluates to 0}}
38 // undef-error-error@#3 {{'BC' is not defined, evaluates to 0}}
39 // undef-prefix-error-error@#3 {{'BC' is not defined, evaluates to 0}}
40 // both-error-error@#3 {{'BC' is not defined, evaluates to 0}}
42 // Test that #pragma-enabled 'Wundef' can override 'Wundef-prefix'
43 #pragma clang diagnostic error "-Wundef"
45 #if C // #4
46 #endif
47 // undef-error@#4 {{'C' is not defined, evaluates to 0}}
48 // undef-prefix-error@#4 {{'C' is not defined, evaluates to 0}}
49 // both-error@#4 {{'C' is not defined, evaluates to 0}}
50 // undef-error-error@#4 {{'C' is not defined, evaluates to 0}}
51 // undef-prefix-error-error@#4 {{'C' is not defined, evaluates to 0}}
52 // both-error-error@#4 {{'C' is not defined, evaluates to 0}}