1 // RUN: %clang_cc1 -std=c++98 -fcxx-exceptions -verify %s
2 // RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -verify %s
3 // RUN: %clang_cc1 -std=c++1y -fcxx-exceptions -fsized-deallocation -verify %s
4 // RUN: %clang_cc1 -std=c++14 -fcxx-exceptions -fsized-deallocation -verify %s
5 // RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fsized-deallocation -verify %s
6 // RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fsized-deallocation -fconcepts-ts -DCONCEPTS_TS=1 -verify %s
7 // RUN: %clang_cc1 -fno-rtti -verify %s -DNO_EXCEPTIONS -DNO_RTTI
8 // RUN: %clang_cc1 -fcoroutines-ts -DNO_EXCEPTIONS -DCOROUTINES -verify %s
9 
10 // expected-no-diagnostics
11 
12 // FIXME using `defined` in a macro has undefined behavior.
13 #if __cplusplus < 201103L
14 #define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx98 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx98
15 #elif __cplusplus < 201402L
16 #define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx11 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx11
17 #elif __cplusplus < 201406L
18 #define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx14 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx14
19 #else
20 #define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx1z == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx1z
21 #endif
22 
23 // --- C++17 features ---
24 
25 #if check(variadic_using, 0, 0, 0, 201611) // FIXME: provisional name
26 #error "wrong value for __cpp_variadic_using"
27 #endif
28 
29 #if check(hex_float, 0, 0, 0, 201603)
30 #error "wrong value for __cpp_hex_float"
31 #endif
32 
33 #if check(inline_variables, 0, 0, 0, 201606) // FIXME: provisional name
34 #error "wrong value for __cpp_inline_variables"
35 #endif
36 
37 #if check(aligned_new, 0, 0, 0, 201606) // FIXME: provisional name
38 #error "wrong value for __cpp_aligned_new"
39 #endif
40 
41 #if check(noexcept_function_type, 0, 0, 0, 201510)
42 #error "wrong value for __cpp_noexcept_function_type"
43 #endif
44 
45 #if check(fold_expressions, 0, 0, 0, 201603)
46 #error "wrong value for __cpp_fold_expressions"
47 #endif
48 
49 #if check(capture_star_this, 0, 0, 0, 201603)
50 #error "wrong value for __cpp_capture_star_this"
51 #endif
52 
53 // constexpr checked below
54 
55 #if check(if_constexpr, 0, 0, 0, 201606) // FIXME: provisional name
56 #error "wrong value for __cpp_if_constexpr"
57 #endif
58 
59 // range_based_for checked below
60 
61 // static_assert checked below
62 
63 #if check(template_auto, 0, 0, 0, 201606) // FIXME: provisional name
64 #error "wrong value for __cpp_template_auto"
65 #endif
66 
67 #if check(namespace_attributes, 0, 0, 0, 201411)
68 // FIXME: allowed without warning in C++14 and C++11
69 #error "wrong value for __cpp_namespace_attributes"
70 #endif
71 
72 #if check(enumerator_attributes, 0, 0, 0, 201411)
73 // FIXME: allowed without warning in C++14 and C++11
74 #error "wrong value for __cpp_enumerator_attributes"
75 #endif
76 
77 #if check(nested_namespace_definitions, 0, 0, 0, 201411)
78 #error "wrong value for __cpp_nested_namespace_definitions"
79 #endif
80 
81 // inheriting_constructors checked below
82 
83 #if check(aggregate_bases, 0, 0, 0, 201603)
84 #error "wrong value for __cpp_aggregate_bases"
85 #endif
86 
87 #if check(structured_bindings, 0, 0, 0, 201606)
88 #error "wrong value for __cpp_structured_bindings"
89 #endif
90 
91 #if check(nontype_template_args, 0, 0, 0, 201411)
92 #error "wrong value for __cpp_nontype_template_args"
93 #endif
94 
95 #if check(template_template_args, 0, 0, 0, 0) // FIXME: should be 201611 when feature is enabled
96 #error "wrong value for __cpp_template_template_args"
97 #endif
98 
99 #if check(deduction_guides, 0, 0, 0, 201611) // FIXME: provisional name
100 #error "wrong value for __cpp_deduction_guides"
101 #endif
102 
103 // --- C++14 features ---
104 
105 #if check(binary_literals, 0, 0, 201304, 201304)
106 #error "wrong value for __cpp_binary_literals"
107 #endif
108 
109 // (Removed from SD-6.)
110 #if check(digit_separators, 0, 0, 201309, 201309)
111 #error "wrong value for __cpp_digit_separators"
112 #endif
113 
114 #if check(init_captures, 0, 0, 201304, 201304)
115 #error "wrong value for __cpp_init_captures"
116 #endif
117 
118 #if check(generic_lambdas, 0, 0, 201304, 201304)
119 #error "wrong value for __cpp_generic_lambdas"
120 #endif
121 
122 #if check(sized_deallocation, 0, 0, 201309, 201309)
123 #error "wrong value for __cpp_sized_deallocation"
124 #endif
125 
126 // constexpr checked below
127 
128 #if check(decltype_auto, 0, 0, 201304, 201304)
129 #error "wrong value for __cpp_decltype_auto"
130 #endif
131 
132 #if check(return_type_deduction, 0, 0, 201304, 201304)
133 #error "wrong value for __cpp_return_type_deduction"
134 #endif
135 
136 #if check(runtime_arrays, 0, 0, 0, 0)
137 #error "wrong value for __cpp_runtime_arrays"
138 #endif
139 
140 #if check(aggregate_nsdmi, 0, 0, 201304, 201304)
141 #error "wrong value for __cpp_aggregate_nsdmi"
142 #endif
143 
144 #if check(variable_templates, 0, 0, 201304, 201304)
145 #error "wrong value for __cpp_variable_templates"
146 #endif
147 
148 // --- C++11 features ---
149 
150 #if check(unicode_characters, 0, 200704, 200704, 200704)
151 #error "wrong value for __cpp_unicode_characters"
152 #endif
153 
154 #if check(raw_strings, 0, 200710, 200710, 200710)
155 #error "wrong value for __cpp_raw_strings"
156 #endif
157 
158 #if check(unicode_literals, 0, 200710, 200710, 200710)
159 #error "wrong value for __cpp_unicode_literals"
160 #endif
161 
162 #if check(user_defined_literals, 0, 200809, 200809, 200809)
163 #error "wrong value for __cpp_user_defined_literals"
164 #endif
165 
166 #if check(lambdas, 0, 200907, 200907, 200907)
167 #error "wrong value for __cpp_lambdas"
168 #endif
169 
170 #if check(constexpr, 0, 200704, 201304, 201603)
171 #error "wrong value for __cpp_constexpr"
172 #endif
173 
174 #if check(range_based_for, 0, 200907, 200907, 201603)
175 #error "wrong value for __cpp_range_based_for"
176 #endif
177 
178 #if check(static_assert, 0, 200410, 200410, 201411)
179 #error "wrong value for __cpp_static_assert"
180 #endif
181 
182 #if check(decltype, 0, 200707, 200707, 200707)
183 #error "wrong value for __cpp_decltype"
184 #endif
185 
186 #if check(attributes, 0, 200809, 200809, 200809)
187 #error "wrong value for __cpp_attributes"
188 #endif
189 
190 #if check(rvalue_references, 0, 200610, 200610, 200610)
191 #error "wrong value for __cpp_rvalue_references"
192 #endif
193 
194 #if check(variadic_templates, 0, 200704, 200704, 200704)
195 #error "wrong value for __cpp_variadic_templates"
196 #endif
197 
198 #if check(initializer_lists, 0, 200806, 200806, 200806)
199 #error "wrong value for __cpp_initializer_lists"
200 #endif
201 
202 #if check(delegating_constructors, 0, 200604, 200604, 200604)
203 #error "wrong value for __cpp_delegating_constructors"
204 #endif
205 
206 #if check(nsdmi, 0, 200809, 200809, 200809)
207 #error "wrong value for __cpp_nsdmi"
208 #endif
209 
210 #if check(inheriting_constructors, 0, 201511, 201511, 201511)
211 #error "wrong value for __cpp_inheriting_constructors"
212 #endif
213 
214 #if check(ref_qualifiers, 0, 200710, 200710, 200710)
215 #error "wrong value for __cpp_ref_qualifiers"
216 #endif
217 
218 #if check(alias_templates, 0, 200704, 200704, 200704)
219 #error "wrong value for __cpp_alias_templates"
220 #endif
221 
222 // --- C++98 features ---
223 
224 #if defined(NO_RTTI) ? check(rtti, 0, 0, 0, 0) : check(rtti, 199711, 199711, 199711, 199711)
225 #error "wrong value for __cpp_rtti"
226 #endif
227 
228 #if defined(NO_EXCEPTIONS) ? check(exceptions, 0, 0, 0, 0) : check(exceptions, 199711, 199711, 199711, 199711)
229 #error "wrong value for __cpp_exceptions"
230 #endif
231 
232 // --- TS features --
233 
234 #if check(experimental_concepts, 0, 0, CONCEPTS_TS, CONCEPTS_TS)
235 #error "wrong value for __cpp_experimental_concepts"
236 #endif
237 
238 #if defined(COROUTINES) ? check(coroutines, 201703L, 201703L, 201703L, 201703L) : check(coroutines, 0, 0, 0, 0)
239 #error "wrong value for __cpp_coroutines"
240 #endif
241