xref: /aosp_15_r20/external/clang/test/Lexer/cxx-features.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -std=c++98 -verify %s
2*67e74705SXin Li // RUN: %clang_cc1 -std=c++11 -verify %s
3*67e74705SXin Li // RUN: %clang_cc1 -std=c++1y -fsized-deallocation -verify %s
4*67e74705SXin Li // RUN: %clang_cc1 -std=c++14 -fsized-deallocation -verify %s
5*67e74705SXin Li // RUN: %clang_cc1 -std=c++1z -fsized-deallocation -verify %s
6*67e74705SXin Li // RUN: %clang_cc1 -std=c++1z -fsized-deallocation -fconcepts-ts -DCONCEPTS_TS=1 -verify %s
7*67e74705SXin Li // RUN: %clang_cc1 -fcoroutines -DCOROUTINES -verify %s
8*67e74705SXin Li 
9*67e74705SXin Li // expected-no-diagnostics
10*67e74705SXin Li 
11*67e74705SXin Li // FIXME using `defined` in a macro has undefined behavior.
12*67e74705SXin Li #if __cplusplus < 201103L
13*67e74705SXin Li #define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx98 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx98
14*67e74705SXin Li #elif __cplusplus < 201402L
15*67e74705SXin Li #define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx11 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx11
16*67e74705SXin Li #elif __cplusplus < 201406L
17*67e74705SXin Li #define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx14 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx14
18*67e74705SXin Li #else
19*67e74705SXin Li #define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx1z == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx1z
20*67e74705SXin Li #endif
21*67e74705SXin Li 
22*67e74705SXin Li #if check(binary_literals, 0, 0, 201304, 201304)
23*67e74705SXin Li #error "wrong value for __cpp_binary_literals"
24*67e74705SXin Li #endif
25*67e74705SXin Li 
26*67e74705SXin Li #if check(digit_separators, 0, 0, 201309, 201309)
27*67e74705SXin Li #error "wrong value for __cpp_digit_separators"
28*67e74705SXin Li #endif
29*67e74705SXin Li 
30*67e74705SXin Li #if check(init_captures, 0, 0, 201304, 201304)
31*67e74705SXin Li #error "wrong value for __cpp_init_captures"
32*67e74705SXin Li #endif
33*67e74705SXin Li 
34*67e74705SXin Li #if check(generic_lambdas, 0, 0, 201304, 201304)
35*67e74705SXin Li #error "wrong value for __cpp_generic_lambdas"
36*67e74705SXin Li #endif
37*67e74705SXin Li 
38*67e74705SXin Li #if check(sized_deallocation, 0, 0, 201309, 201309)
39*67e74705SXin Li #error "wrong value for __cpp_sized_deallocation"
40*67e74705SXin Li #endif
41*67e74705SXin Li 
42*67e74705SXin Li #if check(constexpr, 0, 200704, 201304, 201304)
43*67e74705SXin Li #error "wrong value for __cpp_constexpr"
44*67e74705SXin Li #endif
45*67e74705SXin Li 
46*67e74705SXin Li #if check(decltype_auto, 0, 0, 201304, 201304)
47*67e74705SXin Li #error "wrong value for __cpp_decltype_auto"
48*67e74705SXin Li #endif
49*67e74705SXin Li 
50*67e74705SXin Li #if check(return_type_deduction, 0, 0, 201304, 201304)
51*67e74705SXin Li #error "wrong value for __cpp_return_type_deduction"
52*67e74705SXin Li #endif
53*67e74705SXin Li 
54*67e74705SXin Li #if check(runtime_arrays, 0, 0, 0, 0)
55*67e74705SXin Li #error "wrong value for __cpp_runtime_arrays"
56*67e74705SXin Li #endif
57*67e74705SXin Li 
58*67e74705SXin Li #if check(aggregate_nsdmi, 0, 0, 201304, 201304)
59*67e74705SXin Li #error "wrong value for __cpp_aggregate_nsdmi"
60*67e74705SXin Li #endif
61*67e74705SXin Li 
62*67e74705SXin Li #if check(variable_templates, 0, 0, 201304, 201304)
63*67e74705SXin Li #error "wrong value for __cpp_variable_templates"
64*67e74705SXin Li #endif
65*67e74705SXin Li 
66*67e74705SXin Li #if check(unicode_characters, 0, 200704, 200704, 200704)
67*67e74705SXin Li #error "wrong value for __cpp_unicode_characters"
68*67e74705SXin Li #endif
69*67e74705SXin Li 
70*67e74705SXin Li #if check(raw_strings, 0, 200710, 200710, 200710)
71*67e74705SXin Li #error "wrong value for __cpp_raw_strings"
72*67e74705SXin Li #endif
73*67e74705SXin Li 
74*67e74705SXin Li #if check(unicode_literals, 0, 200710, 200710, 200710)
75*67e74705SXin Li #error "wrong value for __cpp_unicode_literals"
76*67e74705SXin Li #endif
77*67e74705SXin Li 
78*67e74705SXin Li #if check(user_defined_literals, 0, 200809, 200809, 200809)
79*67e74705SXin Li #error "wrong value for __cpp_user_defined_literals"
80*67e74705SXin Li #endif
81*67e74705SXin Li 
82*67e74705SXin Li #if check(lambdas, 0, 200907, 200907, 200907)
83*67e74705SXin Li #error "wrong value for __cpp_lambdas"
84*67e74705SXin Li #endif
85*67e74705SXin Li 
86*67e74705SXin Li #if check(range_based_for, 0, 200907, 200907, 200907)
87*67e74705SXin Li #error "wrong value for __cpp_range_based_for"
88*67e74705SXin Li #endif
89*67e74705SXin Li 
90*67e74705SXin Li #if check(static_assert, 0, 200410, 200410, 200410)
91*67e74705SXin Li #error "wrong value for __cpp_static_assert"
92*67e74705SXin Li #endif
93*67e74705SXin Li 
94*67e74705SXin Li #if check(decltype, 0, 200707, 200707, 200707)
95*67e74705SXin Li #error "wrong value for __cpp_decltype"
96*67e74705SXin Li #endif
97*67e74705SXin Li 
98*67e74705SXin Li #if check(attributes, 0, 200809, 200809, 200809)
99*67e74705SXin Li #error "wrong value for __cpp_attributes"
100*67e74705SXin Li #endif
101*67e74705SXin Li 
102*67e74705SXin Li #if check(rvalue_references, 0, 200610, 200610, 200610)
103*67e74705SXin Li #error "wrong value for __cpp_rvalue_references"
104*67e74705SXin Li #endif
105*67e74705SXin Li 
106*67e74705SXin Li #if check(variadic_templates, 0, 200704, 200704, 200704)
107*67e74705SXin Li #error "wrong value for __cpp_variadic_templates"
108*67e74705SXin Li #endif
109*67e74705SXin Li 
110*67e74705SXin Li #if check(initializer_lists, 0, 200806, 200806, 200806)
111*67e74705SXin Li #error "wrong value for __cpp_initializer_lists"
112*67e74705SXin Li #endif
113*67e74705SXin Li 
114*67e74705SXin Li #if check(delegating_constructors, 0, 200604, 200604, 200604)
115*67e74705SXin Li #error "wrong value for __cpp_delegating_constructors"
116*67e74705SXin Li #endif
117*67e74705SXin Li 
118*67e74705SXin Li #if check(nsdmi, 0, 200809, 200809, 200809)
119*67e74705SXin Li #error "wrong value for __cpp_nsdmi"
120*67e74705SXin Li #endif
121*67e74705SXin Li 
122*67e74705SXin Li #if check(inheriting_constructors, 0, 200802, 200802, 200802)
123*67e74705SXin Li #error "wrong value for __cpp_inheriting_constructors"
124*67e74705SXin Li #endif
125*67e74705SXin Li 
126*67e74705SXin Li #if check(ref_qualifiers, 0, 200710, 200710, 200710)
127*67e74705SXin Li #error "wrong value for __cpp_ref_qualifiers"
128*67e74705SXin Li #endif
129*67e74705SXin Li 
130*67e74705SXin Li #if check(alias_templates, 0, 200704, 200704, 200704)
131*67e74705SXin Li #error "wrong value for __cpp_alias_templates"
132*67e74705SXin Li #endif
133*67e74705SXin Li 
134*67e74705SXin Li #if check(experimental_concepts, 0, 0, CONCEPTS_TS, CONCEPTS_TS)
135*67e74705SXin Li #error "wrong value for __cpp_experimental_concepts"
136*67e74705SXin Li #endif
137*67e74705SXin Li 
138*67e74705SXin Li #if (COROUTINES && !__cpp_coroutines) || (!COROUTINES && __cpp_coroutines)
139*67e74705SXin Li #error "wrong value for __cpp_coroutines"
140*67e74705SXin Li #endif
141