Debian Codegraph @

clang/test/Preprocessor/macro_vaopt_check.cpp

raw
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
4
5 //expected-error@+1{{missing '('}}
6 #define V1(...) __VA_OPT__
7 #undef V1
8 // OK
9 #define V1(...) __VA_OPT__ ()
10 #undef V1
11
12 //expected-warning@+1{{can only appear in the expansion of a variadic macro}}
13 #define V2() __VA_OPT__(x)
14 #undef V2
15
16 //expected-error@+2{{missing ')' after}}
17 //expected-note@+1{{to match this '('}}
18 #define V3(...) __VA_OPT__(
19 #undef V3
20
21 #define V4(...) __VA_OPT__(__VA_ARGS__)
22 #undef V4
23
24 //expected-error@+1{{nested}}
25 #define V5(...) __VA_OPT__(__VA_OPT__())
26 #undef V5
27
28 //expected-error@+1{{not followed by}}
29 #define V1(...) __VA_OPT__ (#)
30 #undef V1
31
32 //expected-error@+1{{cannot appear at start}}
33 #define V1(...) __VA_OPT__ (##)
34 #undef V1
35
36 //expected-error@+1{{cannot appear at start}}
37 #define V1(...) __VA_OPT__ (## X) x
38 #undef V1
39
40 //expected-error@+1{{cannot appear at end}}
41 #define V1(...) y __VA_OPT__ (X ##)
42 #undef V1
43
44
45 #define FOO(x,...) # __VA_OPT__(x) #x #__VA_OPT__(__VA_ARGS__) //OK
46
47 //expected-error@+1{{not followed by a macro parameter}}
48 #define V1(...) __VA_OPT__(#)
49 #undef V1
50
51 //expected-error@+1{{cannot appear at start}}
52 #define V1(...) a __VA_OPT__(##) b
53 #undef V1
54
55 //expected-error@+1{{cannot appear at start}}
56 #define V1(...) a __VA_OPT__(a ## b) b __VA_OPT__(##)
57 #undef V1
58
59 #define V1(x,...) # __VA_OPT__(b x) // OK
60 #undef V1
61
62 //expected-error@+2{{missing ')' after}}
63 //expected-note@+1{{to match this '('}}
64 #define V1(...) __VA_OPT__ ((())
65 #undef V1
66
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
70
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
75
76 #define BAD __VA_OPT__ // expected-warning {{__VA_OPT__ can only appear in the expansion of a variadic macro}}