1// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -verify %s 2// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s 3 4template<typename ...T> // expected-warning {{variadic templates are incompatible with C++98}} 5class Variadic1 {}; 6 7template<template<typename> class ...T> // expected-warning {{variadic templates are incompatible with C++98}} 8class Variadic2 {}; 9 10template<int ...I> // expected-warning {{variadic templates are incompatible with C++98}} 11class Variadic3 {}; 12 13int alignas(8) with_alignas; // expected-warning {{'alignas' is incompatible with C++98}} 14int with_attribute [[ ]]; // expected-warning {{attributes are incompatible with C++98}} 15 16void Literals() { 17 (void)u8"str"; // expected-warning {{unicode literals are incompatible with C++98}} 18 (void)u"str"; // expected-warning {{unicode literals are incompatible with C++98}} 19 (void)U"str"; // expected-warning {{unicode literals are incompatible with C++98}} 20 (void)u'x'; // expected-warning {{unicode literals are incompatible with C++98}} 21 (void)U'x'; // expected-warning {{unicode literals are incompatible with C++98}} 22 23 (void)u8R"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}} 24 (void)uR"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}} 25 (void)UR"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}} 26 (void)R"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}} 27 (void)LR"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}} 28} 29 30template<typename T> struct S {}; 31namespace TemplateParsing { 32 S<::S<void> > s; // expected-warning {{'<::' is treated as digraph '<:' (aka '[') followed by ':' in C++98}} 33 S< ::S<void>> t; // expected-warning {{consecutive right angle brackets are incompatible with C++98 (use '> >')}} 34} 35 36void Lambda() { 37 []{}; // expected-warning {{lambda expressions are incompatible with C++98}} 38} 39 40int InitList() { 41 (void)new int {}; // expected-warning {{generalized initializer lists are incompatible with C++98}} 42 (void)int{}; // expected-warning {{generalized initializer lists are incompatible with C++98}} 43 int x { 0 }; // expected-warning {{generalized initializer lists are incompatible with C++98}} 44 return { 0 }; // expected-warning {{generalized initializer lists are incompatible with C++98}} 45} 46 47int operator""_hello(const char *); // expected-warning {{literal operators are incompatible with C++98}} 48 49enum EnumFixed : int { // expected-warning {{enumeration types with a fixed underlying type are incompatible with C++98}} 50}; 51 52enum class EnumScoped { // expected-warning {{scoped enumerations are incompatible with C++98}} 53}; 54 55void Deleted() = delete; // expected-warning {{deleted function definitions are incompatible with C++98}} 56struct Defaulted { 57 Defaulted() = default; // expected-warning {{defaulted function definitions are incompatible with C++98}} 58}; 59 60int &&RvalueReference = 0; // expected-warning {{rvalue references are incompatible with C++98}} 61struct RefQualifier { 62 void f() &; // expected-warning {{reference qualifiers on functions are incompatible with C++98}} 63}; 64 65auto f() -> int; // expected-warning {{trailing return types are incompatible with C++98}} 66 67void RangeFor() { 68 int xs[] = {1, 2, 3}; 69 for (int &a : xs) { // expected-warning {{range-based for loop is incompatible with C++98}} 70 } 71} 72 73struct InClassInit { 74 int n = 0; // expected-warning {{in-class initialization of non-static data members is incompatible with C++98}} 75}; 76 77struct OverrideControlBase { 78 virtual void f(); 79 virtual void g(); 80}; 81struct OverrideControl final : OverrideControlBase { // expected-warning {{'final' keyword is incompatible with C++98}} 82 virtual void f() override; // expected-warning {{'override' keyword is incompatible with C++98}} 83 virtual void g() final; // expected-warning {{'final' keyword is incompatible with C++98}} 84}; 85 86using AliasDecl = int; // expected-warning {{alias declarations are incompatible with C++98}} 87template<typename T> using AliasTemplate = T; // expected-warning {{alias declarations are incompatible with C++98}} 88 89inline namespace InlineNS { // expected-warning {{inline namespaces are incompatible with C++98}} 90} 91 92auto auto_deduction = 0; // expected-warning {{'auto' type specifier is incompatible with C++98}} 93int *p = new auto(0); // expected-warning {{'auto' type specifier is incompatible with C++98}} 94 95const int align_of = alignof(int); // expected-warning {{alignof expressions are incompatible with C++98}} 96char16_t c16 = 0; // expected-warning {{'char16_t' type specifier is incompatible with C++98}} 97char32_t c32 = 0; // expected-warning {{'char32_t' type specifier is incompatible with C++98}} 98constexpr int const_expr = 0; // expected-warning {{'constexpr' specifier is incompatible with C++98}} 99decltype(const_expr) decl_type = 0; // expected-warning {{'decltype' type specifier is incompatible with C++98}} 100void no_except() noexcept; // expected-warning {{noexcept specifications are incompatible with C++98}} 101bool no_except_expr = noexcept(1 + 1); // expected-warning {{noexcept expressions are incompatible with C++98}} 102void *null = nullptr; // expected-warning {{'nullptr' is incompatible with C++98}} 103static_assert(true, "!"); // expected-warning {{static_assert declarations are incompatible with C++98}} 104 105struct InhCtorBase { 106 InhCtorBase(int); 107}; 108struct InhCtorDerived : InhCtorBase { 109 using InhCtorBase::InhCtorBase; // expected-warning {{inherited constructors are incompatible with C++98}} 110}; 111 112struct FriendMember { 113 static void MemberFn(); 114 friend void FriendMember::MemberFn(); // expected-warning {{friend declaration naming a member of the declaring class is incompatible with C++98}} 115}; 116 117struct DelegCtor { 118 DelegCtor(int) : DelegCtor() {} // expected-warning {{delegating constructors are incompatible with C++98}} 119 DelegCtor(); 120}; 121 122template<int n = 0> void DefaultFuncTemplateArg(); // expected-warning {{default template arguments for a function template are incompatible with C++98}} 123 124template<typename T> int TemplateFn(T) { return 0; } 125void LocalTemplateArg() { 126 struct S {}; 127 TemplateFn(S()); // expected-warning {{local type 'S' as template argument is incompatible with C++98}} 128} 129struct {} obj_of_unnamed_type; // expected-note {{here}} 130int UnnamedTemplateArg = TemplateFn(obj_of_unnamed_type); // expected-warning {{unnamed type as template argument is incompatible with C++98}} 131 132namespace RedundantParensInAddressTemplateParam { 133 int n; 134 template<int*p> struct S {}; 135 S<(&n)> s; // expected-warning {{redundant parentheses surrounding address non-type template argument are incompatible with C++98}} 136 S<(((&n)))> t; // expected-warning {{redundant parentheses surrounding address non-type template argument are incompatible with C++98}} 137} 138 139namespace TemplateSpecOutOfScopeNs { 140 template<typename T> struct S {}; // expected-note {{here}} 141} 142template<> struct TemplateSpecOutOfScopeNs::S<char> {}; // expected-warning {{class template specialization of 'S' outside namespace 'TemplateSpecOutOfScopeNs' is incompatible with C++98}} 143 144struct Typename { 145 template<typename T> struct Inner {}; 146}; 147typename ::Typename TypenameOutsideTemplate(); // expected-warning {{use of 'typename' outside of a template is incompatible with C++98}} 148Typename::template Inner<int> TemplateOutsideTemplate(); // expected-warning {{use of 'template' keyword outside of a template is incompatible with C++98}} 149 150struct TrivialButNonPOD { 151 int f(int); 152private: 153 int k; 154}; 155void Ellipsis(int n, ...); 156void TrivialButNonPODThroughEllipsis() { 157 Ellipsis(1, TrivialButNonPOD()); // expected-warning {{passing object of trivial but non-POD type 'TrivialButNonPOD' through variadic function is incompatible with C++98}} 158} 159 160struct HasExplicitConversion { 161 explicit operator bool(); // expected-warning {{explicit conversion functions are incompatible with C++98}} 162}; 163 164struct Struct {}; 165enum Enum { enum_val = 0 }; 166struct BadFriends { 167 friend enum ::Enum; // expected-warning {{befriending enumeration type 'enum ::Enum' is incompatible with C++98}} 168 friend int; // expected-warning {{non-class friend type 'int' is incompatible with C++98}} 169 friend Struct; // expected-warning {{befriending 'Struct' without 'struct' keyword is incompatible with C++98}} 170}; 171 172int n = {}; // expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}} 173 174class PrivateMember { 175 struct ImPrivate {}; 176}; 177template<typename T> typename T::ImPrivate SFINAEAccessControl(T t) { // expected-warning {{substitution failure due to access control is incompatible with C++98}} expected-note {{while substituting deduced template arguments into function template 'SFINAEAccessControl' [with T = PrivateMember]}} 178 return typename T::ImPrivate(); 179} 180int SFINAEAccessControl(...) { return 0; } 181int CheckSFINAEAccessControl = SFINAEAccessControl(PrivateMember()); 182 183template<typename T> 184struct FriendRedefinition { 185 friend void Friend() {} // expected-warning {{friend function 'Friend' would be implicitly redefined in C++98}} expected-note {{previous}} 186}; 187FriendRedefinition<int> FriendRedef1; 188FriendRedefinition<char> FriendRedef2; // expected-note {{requested here}} 189