Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Preprocessor / macro_vaopt_check.cpp
blob28f92fc17c6c5eb1bd1871195f820f2002137926
1 // RUN: %clang_cc1 %s -Eonly -verify -Wno-all -Wno-c++23-extensions -pedantic -std=c++20
2 // RUN: %clang_cc1 %s -Eonly -verify -Wno-all -Wno-c++23-extensions -pedantic -std=c++11
3 // RUN: %clang_cc1 -x c %s -Eonly -verify -Wno-all -Wno-c2x-extensions -pedantic -std=c99
5 //expected-error@+1{{missing '('}}
6 #define V1(...) __VA_OPT__
7 #undef V1
8 // OK
9 #define V1(...) __VA_OPT__ ()
10 #undef V1
12 //expected-warning@+1{{can only appear in the expansion of a variadic macro}}
13 #define V2() __VA_OPT__(x)
14 #undef V2
16 //expected-error@+2{{missing ')' after}}
17 //expected-note@+1{{to match this '('}}
18 #define V3(...) __VA_OPT__(
19 #undef V3
21 #define V4(...) __VA_OPT__(__VA_ARGS__)
22 #undef V4
24 //expected-error@+1{{nested}}
25 #define V5(...) __VA_OPT__(__VA_OPT__())
26 #undef V5
28 //expected-error@+1{{not followed by}}
29 #define V1(...) __VA_OPT__ (#)
30 #undef V1
32 //expected-error@+1{{cannot appear at start}}
33 #define V1(...) __VA_OPT__ (##)
34 #undef V1
36 //expected-error@+1{{cannot appear at start}}
37 #define V1(...) __VA_OPT__ (## X) x
38 #undef V1
40 //expected-error@+1{{cannot appear at end}}
41 #define V1(...) y __VA_OPT__ (X ##)
42 #undef V1
45 #define FOO(x,...) # __VA_OPT__(x) #x #__VA_OPT__(__VA_ARGS__) //OK
47 //expected-error@+1{{not followed by a macro parameter}}
48 #define V1(...) __VA_OPT__(#)
49 #undef V1
51 //expected-error@+1{{cannot appear at start}}
52 #define V1(...) a __VA_OPT__(##) b
53 #undef V1
55 //expected-error@+1{{cannot appear at start}}
56 #define V1(...) a __VA_OPT__(a ## b) b __VA_OPT__(##)
57 #undef V1
59 #define V1(x,...) # __VA_OPT__(b x) // OK
60 #undef V1
62 //expected-error@+2{{missing ')' after}}
63 //expected-note@+1{{to match this '('}}
64 #define V1(...) __VA_OPT__ ((())
65 #undef V1
67 // __VA_OPT__ can't appear anywhere else.
68 #if __VA_OPT__ // expected-warning {{__VA_OPT__ can only appear in the expansion of a variadic macro}}
69 #endif
71 // expected-warning@+2 {{__VA_OPT__ can only appear in the expansion of a variadic macro}}
72 #ifdef __VA_OPT__ // expected-warning {{__VA_OPT__ can only appear in the expansion of a variadic macro}}
73 #elifdef __VA_OPT__
74 #endif
76 #define BAD __VA_OPT__ // expected-warning {{__VA_OPT__ can only appear in the expansion of a variadic macro}}