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