File: macro_vaopt_check.cpp

package info (click to toggle)
llvm-toolchain-13 1%3A13.0.1-11
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,418,840 kB
  • sloc: cpp: 5,290,826; ansic: 996,570; asm: 544,593; python: 188,212; objc: 72,027; lisp: 30,291; f90: 25,395; sh: 24,898; javascript: 9,780; pascal: 9,398; perl: 7,484; ml: 5,432; awk: 3,523; makefile: 2,913; xml: 953; cs: 573; fortran: 539
file content (76 lines) | stat: -rw-r--r-- 2,199 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// RUN: %clang_cc1 %s -Eonly -verify -Wno-all -pedantic -std=c++20
// RUN: %clang_cc1 %s -Eonly -verify -Wno-all -pedantic -std=c++11
// RUN: %clang_cc1 -x c %s -Eonly -verify -Wno-all -pedantic -std=c99

//expected-error@+1{{missing '('}}
#define V1(...) __VA_OPT__  
#undef V1
// OK
#define V1(...) __VA_OPT__  ()
#undef V1 

//expected-warning@+1{{can only appear in the expansion of a variadic macro}}
#define V2() __VA_OPT__(x) 
#undef V2

//expected-error@+2{{missing ')' after}}
//expected-note@+1{{to match this '('}}
#define V3(...) __VA_OPT__(
#undef V3

#define V4(...) __VA_OPT__(__VA_ARGS__)
#undef V4

//expected-error@+1{{nested}}
#define V5(...) __VA_OPT__(__VA_OPT__())
#undef V5

//expected-error@+1{{not followed by}}
#define V1(...) __VA_OPT__  (#)
#undef V1

//expected-error@+1{{cannot appear at start}}
#define V1(...) __VA_OPT__  (##)
#undef V1

//expected-error@+1{{cannot appear at start}}
#define V1(...) __VA_OPT__  (## X) x
#undef V1

//expected-error@+1{{cannot appear at end}}
#define V1(...) y __VA_OPT__  (X ##)
#undef V1
                            

#define FOO(x,...) # __VA_OPT__(x) #x #__VA_OPT__(__VA_ARGS__) //OK

//expected-error@+1{{not followed by a macro parameter}}
#define V1(...) __VA_OPT__(#)
#undef V1

//expected-error@+1{{cannot appear at start}}
#define V1(...) a __VA_OPT__(##) b
#undef V1

//expected-error@+1{{cannot appear at start}}
#define V1(...) a __VA_OPT__(a ## b) b __VA_OPT__(##)
#undef V1

#define V1(x,...) # __VA_OPT__(b x) // OK
#undef V1

//expected-error@+2{{missing ')' after}}
//expected-note@+1{{to match this '('}}
#define V1(...) __VA_OPT__  ((())
#undef V1

// __VA_OPT__ can't appear anywhere else.
#if __VA_OPT__ // expected-warning {{__VA_OPT__ can only appear in the expansion of a variadic macro}}
#endif

// expected-warning@+2 {{__VA_OPT__ can only appear in the expansion of a variadic macro}}
#ifdef __VA_OPT__ // expected-warning {{__VA_OPT__ can only appear in the expansion of a variadic macro}}
#elifdef __VA_OPT__
#endif

#define BAD __VA_OPT__ // expected-warning {{__VA_OPT__ can only appear in the expansion of a variadic macro}}