1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -verify %s
2*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -std=c++14 -Wc++98-compat -verify %s -DCXX14COMPAT
3f4a2713aSLionel Sambuc
4f4a2713aSLionel Sambuc namespace std {
5f4a2713aSLionel Sambuc struct type_info;
6f4a2713aSLionel Sambuc using size_t = decltype(sizeof(0)); // expected-warning {{decltype}} expected-warning {{alias}}
7f4a2713aSLionel Sambuc template<typename T> struct initializer_list {
8f4a2713aSLionel Sambuc initializer_list(T*, size_t);
9f4a2713aSLionel Sambuc T *p;
10f4a2713aSLionel Sambuc size_t n;
11f4a2713aSLionel Sambuc T *begin();
12f4a2713aSLionel Sambuc T *end();
13f4a2713aSLionel Sambuc };
14f4a2713aSLionel Sambuc }
15f4a2713aSLionel Sambuc
16f4a2713aSLionel Sambuc template<typename ...T> // expected-warning {{variadic templates are incompatible with C++98}}
17f4a2713aSLionel Sambuc class Variadic1 {};
18f4a2713aSLionel Sambuc
19f4a2713aSLionel Sambuc template<template<typename> class ...T> // expected-warning {{variadic templates are incompatible with C++98}}
20f4a2713aSLionel Sambuc class Variadic2 {};
21f4a2713aSLionel Sambuc
22f4a2713aSLionel Sambuc template<int ...I> // expected-warning {{variadic templates are incompatible with C++98}}
23f4a2713aSLionel Sambuc class Variadic3 {};
24f4a2713aSLionel Sambuc
25f4a2713aSLionel Sambuc alignas(8) int with_alignas; // expected-warning {{'alignas' is incompatible with C++98}}
26*0a6a1f1dSLionel Sambuc int with_attribute [[ ]]; // expected-warning {{C++11 attribute syntax is incompatible with C++98}}
27f4a2713aSLionel Sambuc
Literals()28f4a2713aSLionel Sambuc void Literals() {
29f4a2713aSLionel Sambuc (void)u8"str"; // expected-warning {{unicode literals are incompatible with C++98}}
30f4a2713aSLionel Sambuc (void)u"str"; // expected-warning {{unicode literals are incompatible with C++98}}
31f4a2713aSLionel Sambuc (void)U"str"; // expected-warning {{unicode literals are incompatible with C++98}}
32f4a2713aSLionel Sambuc (void)u'x'; // expected-warning {{unicode literals are incompatible with C++98}}
33f4a2713aSLionel Sambuc (void)U'x'; // expected-warning {{unicode literals are incompatible with C++98}}
34f4a2713aSLionel Sambuc
35f4a2713aSLionel Sambuc (void)u8R"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}}
36f4a2713aSLionel Sambuc (void)uR"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}}
37f4a2713aSLionel Sambuc (void)UR"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}}
38f4a2713aSLionel Sambuc (void)R"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}}
39f4a2713aSLionel Sambuc (void)LR"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}}
40f4a2713aSLionel Sambuc }
41f4a2713aSLionel Sambuc
42f4a2713aSLionel Sambuc template<typename T> struct S {};
43f4a2713aSLionel Sambuc namespace TemplateParsing {
44f4a2713aSLionel Sambuc S<::S<void> > s; // expected-warning {{'<::' is treated as digraph '<:' (aka '[') followed by ':' in C++98}}
45f4a2713aSLionel Sambuc S< ::S<void>> t; // expected-warning {{consecutive right angle brackets are incompatible with C++98 (use '> >')}}
46f4a2713aSLionel Sambuc }
47f4a2713aSLionel Sambuc
Lambda()48f4a2713aSLionel Sambuc void Lambda() {
49f4a2713aSLionel Sambuc []{}(); // expected-warning {{lambda expressions are incompatible with C++98}}
50f4a2713aSLionel Sambuc }
51f4a2713aSLionel Sambuc
52f4a2713aSLionel Sambuc struct Ctor {
53f4a2713aSLionel Sambuc Ctor(int, char);
54f4a2713aSLionel Sambuc Ctor(double, long);
55f4a2713aSLionel Sambuc };
56f4a2713aSLionel Sambuc struct InitListCtor {
57f4a2713aSLionel Sambuc InitListCtor(std::initializer_list<bool>);
58f4a2713aSLionel Sambuc };
59f4a2713aSLionel Sambuc
InitList(int i={})60f4a2713aSLionel Sambuc int InitList(int i = {}) { // expected-warning {{generalized initializer lists are incompatible with C++98}} \
61f4a2713aSLionel Sambuc // expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}}
62f4a2713aSLionel Sambuc (void)new int {}; // expected-warning {{generalized initializer lists are incompatible with C++98}} \
63f4a2713aSLionel Sambuc // expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}}
64f4a2713aSLionel Sambuc (void)int{}; // expected-warning {{generalized initializer lists are incompatible with C++98}} \
65f4a2713aSLionel Sambuc // expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}}
66f4a2713aSLionel Sambuc int x { 0 }; // expected-warning {{generalized initializer lists are incompatible with C++98}}
67f4a2713aSLionel Sambuc S<int> s = {}; // ok, aggregate
68f4a2713aSLionel Sambuc s = {}; // expected-warning {{generalized initializer lists are incompatible with C++98}}
69f4a2713aSLionel Sambuc std::initializer_list<int> xs = { 1, 2, 3 }; // expected-warning {{initialization of initializer_list object is incompatible with C++98}}
70f4a2713aSLionel Sambuc auto ys = { 1, 2, 3 }; // expected-warning {{initialization of initializer_list object is incompatible with C++98}} \
71f4a2713aSLionel Sambuc // expected-warning {{'auto' type specifier is incompatible with C++98}}
72f4a2713aSLionel Sambuc Ctor c1 = { 1, 2 }; // expected-warning {{constructor call from initializer list is incompatible with C++98}}
73f4a2713aSLionel Sambuc Ctor c2 = { 3.0, 4l }; // expected-warning {{constructor call from initializer list is incompatible with C++98}}
74f4a2713aSLionel Sambuc InitListCtor ilc = { true, false }; // expected-warning {{initialization of initializer_list object is incompatible with C++98}}
75f4a2713aSLionel Sambuc const int &r = { 0 }; // expected-warning {{reference initialized from initializer list is incompatible with C++98}}
76f4a2713aSLionel Sambuc struct { int a; const int &r; } rr = { 0, {0} }; // expected-warning {{reference initialized from initializer list is incompatible with C++98}}
77f4a2713aSLionel Sambuc return { 0 }; // expected-warning {{generalized initializer lists are incompatible with C++98}}
78f4a2713aSLionel Sambuc }
79f4a2713aSLionel Sambuc struct DelayedDefaultArgumentParseInitList {
fDelayedDefaultArgumentParseInitList80f4a2713aSLionel Sambuc void f(int i = {1}) { // expected-warning {{generalized initializer lists are incompatible with C++98}}
81f4a2713aSLionel Sambuc }
82f4a2713aSLionel Sambuc };
83f4a2713aSLionel Sambuc
84f4a2713aSLionel Sambuc int operator"" _hello(const char *); // expected-warning {{literal operators are incompatible with C++98}}
85f4a2713aSLionel Sambuc
86f4a2713aSLionel Sambuc enum EnumFixed : int { // expected-warning {{enumeration types with a fixed underlying type are incompatible with C++98}}
87f4a2713aSLionel Sambuc };
88f4a2713aSLionel Sambuc
89f4a2713aSLionel Sambuc enum class EnumScoped { // expected-warning {{scoped enumerations are incompatible with C++98}}
90f4a2713aSLionel Sambuc };
91f4a2713aSLionel Sambuc
92f4a2713aSLionel Sambuc void Deleted() = delete; // expected-warning {{deleted function definitions are incompatible with C++98}}
93f4a2713aSLionel Sambuc struct Defaulted {
94f4a2713aSLionel Sambuc Defaulted() = default; // expected-warning {{defaulted function definitions are incompatible with C++98}}
95f4a2713aSLionel Sambuc };
96f4a2713aSLionel Sambuc
97f4a2713aSLionel Sambuc int &&RvalueReference = 0; // expected-warning {{rvalue references are incompatible with C++98}}
98f4a2713aSLionel Sambuc struct RefQualifier {
99f4a2713aSLionel Sambuc void f() &; // expected-warning {{reference qualifiers on functions are incompatible with C++98}}
100f4a2713aSLionel Sambuc };
101f4a2713aSLionel Sambuc
102f4a2713aSLionel Sambuc auto f() -> int; // expected-warning {{trailing return types are incompatible with C++98}}
103f4a2713aSLionel Sambuc
RangeFor()104f4a2713aSLionel Sambuc void RangeFor() {
105f4a2713aSLionel Sambuc int xs[] = {1, 2, 3};
106f4a2713aSLionel Sambuc for (int &a : xs) { // expected-warning {{range-based for loop is incompatible with C++98}}
107f4a2713aSLionel Sambuc }
108f4a2713aSLionel Sambuc for (auto &b : {1, 2, 3}) {
109f4a2713aSLionel Sambuc // expected-warning@-1 {{range-based for loop is incompatible with C++98}}
110f4a2713aSLionel Sambuc // expected-warning@-2 {{'auto' type specifier is incompatible with C++98}}
111f4a2713aSLionel Sambuc // expected-warning@-3 {{initialization of initializer_list object is incompatible with C++98}}
112f4a2713aSLionel Sambuc // expected-warning@-4 {{reference initialized from initializer list is incompatible with C++98}}
113f4a2713aSLionel Sambuc }
114f4a2713aSLionel Sambuc struct Agg { int a, b; } const &agg = { 1, 2 }; // expected-warning {{reference initialized from initializer list is incompatible with C++98}}
115f4a2713aSLionel Sambuc }
116f4a2713aSLionel Sambuc
117f4a2713aSLionel Sambuc struct InClassInit {
118f4a2713aSLionel Sambuc int n = 0; // expected-warning {{in-class initialization of non-static data members is incompatible with C++98}}
119f4a2713aSLionel Sambuc };
120f4a2713aSLionel Sambuc
121f4a2713aSLionel Sambuc struct OverrideControlBase {
122f4a2713aSLionel Sambuc virtual void f();
123f4a2713aSLionel Sambuc virtual void g();
124f4a2713aSLionel Sambuc };
125f4a2713aSLionel Sambuc struct OverrideControl final : OverrideControlBase { // expected-warning {{'final' keyword is incompatible with C++98}}
126f4a2713aSLionel Sambuc virtual void f() override; // expected-warning {{'override' keyword is incompatible with C++98}}
127f4a2713aSLionel Sambuc virtual void g() final; // expected-warning {{'final' keyword is incompatible with C++98}}
128f4a2713aSLionel Sambuc };
129f4a2713aSLionel Sambuc
130f4a2713aSLionel Sambuc using AliasDecl = int; // expected-warning {{alias declarations are incompatible with C++98}}
131f4a2713aSLionel Sambuc template<typename T> using AliasTemplate = T; // expected-warning {{alias declarations are incompatible with C++98}}
132f4a2713aSLionel Sambuc
133f4a2713aSLionel Sambuc inline namespace InlineNS { // expected-warning {{inline namespaces are incompatible with C++98}}
134f4a2713aSLionel Sambuc }
135f4a2713aSLionel Sambuc
136f4a2713aSLionel Sambuc auto auto_deduction = 0; // expected-warning {{'auto' type specifier is incompatible with C++98}}
137f4a2713aSLionel Sambuc int *p = new auto(0); // expected-warning {{'auto' type specifier is incompatible with C++98}}
138f4a2713aSLionel Sambuc
139f4a2713aSLionel Sambuc const int align_of = alignof(int); // expected-warning {{alignof expressions are incompatible with C++98}}
140f4a2713aSLionel Sambuc char16_t c16 = 0; // expected-warning {{'char16_t' type specifier is incompatible with C++98}}
141f4a2713aSLionel Sambuc char32_t c32 = 0; // expected-warning {{'char32_t' type specifier is incompatible with C++98}}
142f4a2713aSLionel Sambuc constexpr int const_expr = 0; // expected-warning {{'constexpr' specifier is incompatible with C++98}}
143f4a2713aSLionel Sambuc decltype(const_expr) decl_type = 0; // expected-warning {{'decltype' type specifier is incompatible with C++98}}
144f4a2713aSLionel Sambuc __decltype(const_expr) decl_type2 = 0; // ok
145f4a2713aSLionel Sambuc void no_except() noexcept; // expected-warning {{noexcept specifications are incompatible with C++98}}
146f4a2713aSLionel Sambuc bool no_except_expr = noexcept(1 + 1); // expected-warning {{noexcept expressions are incompatible with C++98}}
147f4a2713aSLionel Sambuc void *null = nullptr; // expected-warning {{'nullptr' is incompatible with C++98}}
148f4a2713aSLionel Sambuc static_assert(true, "!"); // expected-warning {{static_assert declarations are incompatible with C++98}}
149f4a2713aSLionel Sambuc
150f4a2713aSLionel Sambuc struct InhCtorBase {
151f4a2713aSLionel Sambuc InhCtorBase(int);
152f4a2713aSLionel Sambuc };
153f4a2713aSLionel Sambuc struct InhCtorDerived : InhCtorBase {
154f4a2713aSLionel Sambuc using InhCtorBase::InhCtorBase; // expected-warning {{inheriting constructors are incompatible with C++98}}
155f4a2713aSLionel Sambuc };
156f4a2713aSLionel Sambuc
157f4a2713aSLionel Sambuc struct FriendMember {
158f4a2713aSLionel Sambuc static void MemberFn();
159f4a2713aSLionel Sambuc friend void FriendMember::MemberFn(); // expected-warning {{friend declaration naming a member of the declaring class is incompatible with C++98}}
160f4a2713aSLionel Sambuc };
161f4a2713aSLionel Sambuc
162f4a2713aSLionel Sambuc struct DelegCtor {
DelegCtorDelegCtor163f4a2713aSLionel Sambuc DelegCtor(int) : DelegCtor() {} // expected-warning {{delegating constructors are incompatible with C++98}}
164f4a2713aSLionel Sambuc DelegCtor();
165f4a2713aSLionel Sambuc };
166f4a2713aSLionel Sambuc
167f4a2713aSLionel Sambuc template<int n = 0> void DefaultFuncTemplateArg(); // expected-warning {{default template arguments for a function template are incompatible with C++98}}
168f4a2713aSLionel Sambuc
TemplateFn(T)169f4a2713aSLionel Sambuc template<typename T> int TemplateFn(T) { return 0; }
LocalTemplateArg()170f4a2713aSLionel Sambuc void LocalTemplateArg() {
171f4a2713aSLionel Sambuc struct S {};
172f4a2713aSLionel Sambuc TemplateFn(S()); // expected-warning {{local type 'S' as template argument is incompatible with C++98}}
173f4a2713aSLionel Sambuc }
174f4a2713aSLionel Sambuc struct {} obj_of_unnamed_type; // expected-note {{here}}
175f4a2713aSLionel Sambuc int UnnamedTemplateArg = TemplateFn(obj_of_unnamed_type); // expected-warning {{unnamed type as template argument is incompatible with C++98}}
176f4a2713aSLionel Sambuc
177f4a2713aSLionel Sambuc namespace RedundantParensInAddressTemplateParam {
178f4a2713aSLionel Sambuc int n;
179f4a2713aSLionel Sambuc template<int*p> struct S {};
180f4a2713aSLionel Sambuc S<(&n)> s; // expected-warning {{redundant parentheses surrounding address non-type template argument are incompatible with C++98}}
181f4a2713aSLionel Sambuc S<(((&n)))> t; // expected-warning {{redundant parentheses surrounding address non-type template argument are incompatible with C++98}}
182f4a2713aSLionel Sambuc }
183f4a2713aSLionel Sambuc
184f4a2713aSLionel Sambuc namespace TemplateSpecOutOfScopeNs {
185f4a2713aSLionel Sambuc template<typename T> struct S {}; // expected-note {{here}}
186f4a2713aSLionel Sambuc }
187f4a2713aSLionel Sambuc template<> struct TemplateSpecOutOfScopeNs::S<char> {}; // expected-warning {{class template specialization of 'S' outside namespace 'TemplateSpecOutOfScopeNs' is incompatible with C++98}}
188f4a2713aSLionel Sambuc
189f4a2713aSLionel Sambuc struct Typename {
190f4a2713aSLionel Sambuc template<typename T> struct Inner {};
191f4a2713aSLionel Sambuc };
192f4a2713aSLionel Sambuc typename ::Typename TypenameOutsideTemplate(); // expected-warning {{use of 'typename' outside of a template is incompatible with C++98}}
193f4a2713aSLionel Sambuc Typename::template Inner<int> TemplateOutsideTemplate(); // expected-warning {{use of 'template' keyword outside of a template is incompatible with C++98}}
194f4a2713aSLionel Sambuc
195f4a2713aSLionel Sambuc struct TrivialButNonPOD {
196f4a2713aSLionel Sambuc int f(int);
197f4a2713aSLionel Sambuc private:
198f4a2713aSLionel Sambuc int k;
199f4a2713aSLionel Sambuc };
200f4a2713aSLionel Sambuc void Ellipsis(int n, ...);
TrivialButNonPODThroughEllipsis()201f4a2713aSLionel Sambuc void TrivialButNonPODThroughEllipsis() {
202f4a2713aSLionel Sambuc Ellipsis(1, TrivialButNonPOD()); // expected-warning {{passing object of trivial but non-POD type 'TrivialButNonPOD' through variadic function is incompatible with C++98}}
203f4a2713aSLionel Sambuc }
204f4a2713aSLionel Sambuc
205f4a2713aSLionel Sambuc struct HasExplicitConversion {
206f4a2713aSLionel Sambuc explicit operator bool(); // expected-warning {{explicit conversion functions are incompatible with C++98}}
207f4a2713aSLionel Sambuc };
208f4a2713aSLionel Sambuc
209f4a2713aSLionel Sambuc struct Struct {};
210f4a2713aSLionel Sambuc enum Enum { enum_val = 0 };
211f4a2713aSLionel Sambuc struct BadFriends {
212f4a2713aSLionel Sambuc friend enum ::Enum; // expected-warning {{befriending enumeration type 'enum ::Enum' is incompatible with C++98}}
213f4a2713aSLionel Sambuc friend int; // expected-warning {{non-class friend type 'int' is incompatible with C++98}}
214f4a2713aSLionel Sambuc friend Struct; // expected-warning {{befriending 'Struct' without 'struct' keyword is incompatible with C++98}}
215f4a2713aSLionel Sambuc };
216f4a2713aSLionel Sambuc
217f4a2713aSLionel Sambuc int n = {}; // expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}}
218f4a2713aSLionel Sambuc
219f4a2713aSLionel Sambuc class PrivateMember {
220f4a2713aSLionel Sambuc struct ImPrivate {};
221f4a2713aSLionel Sambuc };
SFINAEAccessControl(T t)222*0a6a1f1dSLionel Sambuc template<typename T> typename T::ImPrivate SFINAEAccessControl(T t) { // expected-warning {{substitution failure due to access control is incompatible with C++98}}
223f4a2713aSLionel Sambuc return typename T::ImPrivate();
224f4a2713aSLionel Sambuc }
SFINAEAccessControl(...)225f4a2713aSLionel Sambuc int SFINAEAccessControl(...) { return 0; }
226*0a6a1f1dSLionel Sambuc int CheckSFINAEAccessControl = SFINAEAccessControl(PrivateMember()); // expected-note {{while substituting deduced template arguments into function template 'SFINAEAccessControl' [with T = PrivateMember]}}
227f4a2713aSLionel Sambuc
228f4a2713aSLionel Sambuc namespace UnionOrAnonStructMembers {
229f4a2713aSLionel Sambuc struct NonTrivCtor {
230f4a2713aSLionel Sambuc NonTrivCtor(); // expected-note 2{{user-provided default constructor}}
231f4a2713aSLionel Sambuc };
232f4a2713aSLionel Sambuc struct NonTrivCopy {
233f4a2713aSLionel Sambuc NonTrivCopy(const NonTrivCopy&); // expected-note 2{{user-provided copy constructor}}
234f4a2713aSLionel Sambuc };
235f4a2713aSLionel Sambuc struct NonTrivDtor {
236f4a2713aSLionel Sambuc ~NonTrivDtor(); // expected-note 2{{user-provided destructor}}
237f4a2713aSLionel Sambuc };
238f4a2713aSLionel Sambuc union BadUnion {
239f4a2713aSLionel Sambuc NonTrivCtor ntc; // expected-warning {{union member 'ntc' with a non-trivial constructor is incompatible with C++98}}
240f4a2713aSLionel Sambuc NonTrivCopy ntcp; // expected-warning {{union member 'ntcp' with a non-trivial copy constructor is incompatible with C++98}}
241f4a2713aSLionel Sambuc NonTrivDtor ntd; // expected-warning {{union member 'ntd' with a non-trivial destructor is incompatible with C++98}}
242f4a2713aSLionel Sambuc };
243f4a2713aSLionel Sambuc struct Wrap {
244f4a2713aSLionel Sambuc struct {
245f4a2713aSLionel Sambuc NonTrivCtor ntc; // expected-warning {{anonymous struct member 'ntc' with a non-trivial constructor is incompatible with C++98}}
246f4a2713aSLionel Sambuc NonTrivCopy ntcp; // expected-warning {{anonymous struct member 'ntcp' with a non-trivial copy constructor is incompatible with C++98}}
247f4a2713aSLionel Sambuc NonTrivDtor ntd; // expected-warning {{anonymous struct member 'ntd' with a non-trivial destructor is incompatible with C++98}}
248f4a2713aSLionel Sambuc };
249f4a2713aSLionel Sambuc };
250f4a2713aSLionel Sambuc union WithStaticDataMember {
251f4a2713aSLionel Sambuc static constexpr double d = 0.0; // expected-warning {{static data member 'd' in union is incompatible with C++98}} expected-warning {{'constexpr' specifier is incompatible with C++98}}
252f4a2713aSLionel Sambuc static const int n = 0; // expected-warning {{static data member 'n' in union is incompatible with C++98}}
253f4a2713aSLionel Sambuc static int k; // expected-warning {{static data member 'k' in union is incompatible with C++98}}
254f4a2713aSLionel Sambuc };
255f4a2713aSLionel Sambuc }
256f4a2713aSLionel Sambuc
257f4a2713aSLionel Sambuc int EnumNNS = Enum::enum_val; // expected-warning {{enumeration type in nested name specifier is incompatible with C++98}}
EnumNNSFn()258f4a2713aSLionel Sambuc template<typename T> void EnumNNSFn() {
259f4a2713aSLionel Sambuc int k = T::enum_val; // expected-warning {{enumeration type in nested name specifier is incompatible with C++98}}
260f4a2713aSLionel Sambuc };
261f4a2713aSLionel Sambuc template void EnumNNSFn<Enum>(); // expected-note {{in instantiation}}
262f4a2713aSLionel Sambuc
JumpDiagnostics(int n)263f4a2713aSLionel Sambuc void JumpDiagnostics(int n) {
264*0a6a1f1dSLionel Sambuc goto DirectJump; // expected-warning {{jump from this goto statement to its label is incompatible with C++98}}
265f4a2713aSLionel Sambuc TrivialButNonPOD tnp1; // expected-note {{jump bypasses initialization of non-POD variable}}
266f4a2713aSLionel Sambuc
267f4a2713aSLionel Sambuc DirectJump:
268f4a2713aSLionel Sambuc void *Table[] = {&&DirectJump, &&Later};
269*0a6a1f1dSLionel Sambuc goto *Table[n]; // expected-warning {{jump from this indirect goto statement to one of its possible targets is incompatible with C++98}}
270f4a2713aSLionel Sambuc
271f4a2713aSLionel Sambuc TrivialButNonPOD tnp2; // expected-note {{jump bypasses initialization of non-POD variable}}
272*0a6a1f1dSLionel Sambuc Later: // expected-note {{possible target of indirect goto statement}}
273f4a2713aSLionel Sambuc switch (n) {
274f4a2713aSLionel Sambuc TrivialButNonPOD tnp3; // expected-note {{jump bypasses initialization of non-POD variable}}
275*0a6a1f1dSLionel Sambuc default: // expected-warning {{jump from switch statement to this case label is incompatible with C++98}}
276f4a2713aSLionel Sambuc return;
277f4a2713aSLionel Sambuc }
278f4a2713aSLionel Sambuc }
279f4a2713aSLionel Sambuc
280f4a2713aSLionel Sambuc namespace UnevaluatedMemberAccess {
281f4a2713aSLionel Sambuc struct S {
282f4a2713aSLionel Sambuc int n;
fUnevaluatedMemberAccess::S283f4a2713aSLionel Sambuc int f() { return sizeof(S::n); } // ok
284f4a2713aSLionel Sambuc };
285f4a2713aSLionel Sambuc int k = sizeof(S::n); // expected-warning {{use of non-static data member 'n' in an unevaluated context is incompatible with C++98}}
286f4a2713aSLionel Sambuc const std::type_info &ti = typeid(S::n); // expected-warning {{use of non-static data member 'n' in an unevaluated context is incompatible with C++98}}
287f4a2713aSLionel Sambuc }
288f4a2713aSLionel Sambuc
289f4a2713aSLionel Sambuc namespace LiteralUCNs {
290f4a2713aSLionel Sambuc char c1 = '\u001e'; // expected-warning {{universal character name referring to a control character is incompatible with C++98}}
291f4a2713aSLionel Sambuc wchar_t c2 = L'\u0041'; // expected-warning {{specifying character 'A' with a universal character name is incompatible with C++98}}
292f4a2713aSLionel Sambuc const char *s1 = "foo\u0031"; // expected-warning {{specifying character '1' with a universal character name is incompatible with C++98}}
293f4a2713aSLionel Sambuc const wchar_t *s2 = L"bar\u0085"; // expected-warning {{universal character name referring to a control character is incompatible with C++98}}
294f4a2713aSLionel Sambuc }
295f4a2713aSLionel Sambuc
296f4a2713aSLionel Sambuc namespace NonTypeTemplateArgs {
297f4a2713aSLionel Sambuc template<typename T, T v> struct S {};
298f4a2713aSLionel Sambuc const int k = 5; // expected-note {{here}}
f()299f4a2713aSLionel Sambuc static void f() {} // expected-note {{here}}
300f4a2713aSLionel Sambuc S<const int&, k> s1; // expected-warning {{non-type template argument referring to object 'k' with internal linkage is incompatible with C++98}}
301f4a2713aSLionel Sambuc S<void(&)(), f> s2; // expected-warning {{non-type template argument referring to function 'f' with internal linkage is incompatible with C++98}}
302f4a2713aSLionel Sambuc }
303f4a2713aSLionel Sambuc
304f4a2713aSLionel Sambuc namespace NullPointerTemplateArg {
305f4a2713aSLionel Sambuc struct A {};
306f4a2713aSLionel Sambuc template<int*> struct X {};
307f4a2713aSLionel Sambuc template<int A::*> struct Y {};
308f4a2713aSLionel Sambuc X<(int*)0> x; // expected-warning {{use of null pointer as non-type template argument is incompatible with C++98}}
309f4a2713aSLionel Sambuc Y<(int A::*)0> y; // expected-warning {{use of null pointer as non-type template argument is incompatible with C++98}}
310f4a2713aSLionel Sambuc }
311f4a2713aSLionel Sambuc
312f4a2713aSLionel Sambuc namespace PR13480 {
313f4a2713aSLionel Sambuc struct basic_iterator {
basic_iteratorPR13480::basic_iterator314f4a2713aSLionel Sambuc basic_iterator(const basic_iterator &it) {} // expected-note {{because type 'PR13480::basic_iterator' has a user-provided copy constructor}}
basic_iteratorPR13480::basic_iterator315f4a2713aSLionel Sambuc basic_iterator(basic_iterator &it) {}
316f4a2713aSLionel Sambuc };
317f4a2713aSLionel Sambuc
318f4a2713aSLionel Sambuc union test {
319f4a2713aSLionel Sambuc basic_iterator it; // expected-warning {{union member 'it' with a non-trivial copy constructor is incompatible with C++98}}
320f4a2713aSLionel Sambuc };
321f4a2713aSLionel Sambuc }
322f4a2713aSLionel Sambuc
323f4a2713aSLionel Sambuc namespace AssignOpUnion {
324f4a2713aSLionel Sambuc struct a {
operator =AssignOpUnion::a325f4a2713aSLionel Sambuc void operator=(const a &it) {} // expected-note {{because type 'AssignOpUnion::a' has a user-provided copy assignment operator}}
operator =AssignOpUnion::a326f4a2713aSLionel Sambuc void operator=(a &it) {}
327f4a2713aSLionel Sambuc };
328f4a2713aSLionel Sambuc
329f4a2713aSLionel Sambuc struct b {
operator =AssignOpUnion::b330f4a2713aSLionel Sambuc void operator=(const b &it) {} // expected-note {{because type 'AssignOpUnion::b' has a user-provided copy assignment operator}}
331f4a2713aSLionel Sambuc };
332f4a2713aSLionel Sambuc
333f4a2713aSLionel Sambuc union test1 {
334f4a2713aSLionel Sambuc a x; // expected-warning {{union member 'x' with a non-trivial copy assignment operator is incompatible with C++98}}
335f4a2713aSLionel Sambuc b y; // expected-warning {{union member 'y' with a non-trivial copy assignment operator is incompatible with C++98}}
336f4a2713aSLionel Sambuc };
337f4a2713aSLionel Sambuc }
338f4a2713aSLionel Sambuc
339f4a2713aSLionel Sambuc namespace rdar11736429 {
340f4a2713aSLionel Sambuc struct X { // expected-note {{because type 'rdar11736429::X' has no default constructor}}
341f4a2713aSLionel Sambuc X(const X&) = delete; // expected-warning{{deleted function definitions are incompatible with C++98}} \
342f4a2713aSLionel Sambuc // expected-note {{implicit default constructor suppressed by user-declared constructor}}
343f4a2713aSLionel Sambuc };
344f4a2713aSLionel Sambuc
345f4a2713aSLionel Sambuc union S {
346f4a2713aSLionel Sambuc X x; // expected-warning{{union member 'x' with a non-trivial constructor is incompatible with C++98}}
347f4a2713aSLionel Sambuc };
348f4a2713aSLionel Sambuc }
349f4a2713aSLionel Sambuc
350f4a2713aSLionel Sambuc template<typename T> T var = T(10);
351*0a6a1f1dSLionel Sambuc #ifdef CXX14COMPAT
352*0a6a1f1dSLionel Sambuc // expected-warning@-2 {{variable templates are incompatible with C++ standards before C++14}}
353f4a2713aSLionel Sambuc #else
354*0a6a1f1dSLionel Sambuc // expected-warning@-4 {{variable templates are a C++14 extension}}
355f4a2713aSLionel Sambuc #endif
356f4a2713aSLionel Sambuc
357*0a6a1f1dSLionel Sambuc // No diagnostic for specializations of variable templates; we will have
358*0a6a1f1dSLionel Sambuc // diagnosed the primary template.
359f4a2713aSLionel Sambuc template<typename T> T* var<T*> = new T();
360f4a2713aSLionel Sambuc template<> int var<int> = 10;
361f4a2713aSLionel Sambuc template int var<int>;
362f4a2713aSLionel Sambuc float fvar = var<float>;
363f4a2713aSLionel Sambuc
364f4a2713aSLionel Sambuc class A {
365f4a2713aSLionel Sambuc template<typename T> static T var = T(10);
366*0a6a1f1dSLionel Sambuc #ifdef CXX14COMPAT
367*0a6a1f1dSLionel Sambuc // expected-warning@-2 {{variable templates are incompatible with C++ standards before C++14}}
368f4a2713aSLionel Sambuc #else
369*0a6a1f1dSLionel Sambuc // expected-warning@-4 {{variable templates are a C++14 extension}}
370f4a2713aSLionel Sambuc #endif
371f4a2713aSLionel Sambuc
372f4a2713aSLionel Sambuc template<typename T> static T* var<T*> = new T();
373f4a2713aSLionel Sambuc };
374f4a2713aSLionel Sambuc
375f4a2713aSLionel Sambuc struct B { template<typename T> static T v; };
376*0a6a1f1dSLionel Sambuc #ifdef CXX14COMPAT
377*0a6a1f1dSLionel Sambuc // expected-warning@-2 {{variable templates are incompatible with C++ standards before C++14}}
378f4a2713aSLionel Sambuc #else
379*0a6a1f1dSLionel Sambuc // expected-warning@-4 {{variable templates are a C++14 extension}}
380f4a2713aSLionel Sambuc #endif
381f4a2713aSLionel Sambuc
382f4a2713aSLionel Sambuc template<typename T> T B::v = T();
383*0a6a1f1dSLionel Sambuc #ifdef CXX14COMPAT
384*0a6a1f1dSLionel Sambuc // expected-warning@-2 {{variable templates are incompatible with C++ standards before C++14}}
385f4a2713aSLionel Sambuc #else
386*0a6a1f1dSLionel Sambuc // expected-warning@-4 {{variable templates are a C++14 extension}}
387f4a2713aSLionel Sambuc #endif
388f4a2713aSLionel Sambuc
389f4a2713aSLionel Sambuc template<typename T> T* B::v<T*> = new T();
390f4a2713aSLionel Sambuc template<> int B::v<int> = 10;
391f4a2713aSLionel Sambuc template int B::v<int>;
392f4a2713aSLionel Sambuc float fsvar = B::v<float>;
393f4a2713aSLionel Sambuc
394*0a6a1f1dSLionel Sambuc #ifdef CXX14COMPAT
395*0a6a1f1dSLionel Sambuc int digit_seps = 123'456; // expected-warning {{digit separators are incompatible with C++ standards before C++14}}
396f4a2713aSLionel Sambuc #endif
397