| Richard Smith | f679b5b | 2011-10-14 20:48:27 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -verify %s | 
| Richard Smith | 0bf8a492 | 2011-10-18 20:49:44 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s | 
| Richard Smith | 2b6b0ee | 2011-10-14 20:41:13 +0000 | [diff] [blame] | 3 |  | 
|  | 4 | template<typename ...T>  // expected-warning {{variadic templates are incompatible with C++98}} | 
|  | 5 | class Variadic1 {}; | 
|  | 6 |  | 
|  | 7 | template<template<typename> class ...T>  // expected-warning {{variadic templates are incompatible with C++98}} | 
|  | 8 | class Variadic2 {}; | 
|  | 9 |  | 
|  | 10 | template<int ...I>  // expected-warning {{variadic templates are incompatible with C++98}} | 
|  | 11 | class Variadic3 {}; | 
| Richard Smith | f679b5b | 2011-10-14 20:48:27 +0000 | [diff] [blame] | 12 |  | 
|  | 13 | int alignas(8) with_alignas; // expected-warning {{'alignas' is incompatible with C++98}} | 
|  | 14 | int with_attribute [[ ]]; // expected-warning {{attributes are incompatible with C++98}} | 
| Richard Smith | acd4d3d | 2011-10-15 01:18:56 +0000 | [diff] [blame] | 15 |  | 
|  | 16 | void 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 |  | 
|  | 30 | template<typename T> struct S {}; | 
| Richard Smith | 5d164bc | 2011-10-15 05:09:34 +0000 | [diff] [blame] | 31 | namespace 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 |  | 
|  | 36 | void Lambda() { | 
|  | 37 | []{}; // expected-warning {{lambda expressions are incompatible with C++98}} | 
|  | 38 | } | 
|  | 39 |  | 
|  | 40 | int 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}} | 
| Richard Smith | c823973 | 2011-10-18 21:39:00 +0000 | [diff] [blame] | 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}} | 
| Richard Smith | 5d164bc | 2011-10-15 05:09:34 +0000 | [diff] [blame] | 45 | } | 
|  | 46 |  | 
|  | 47 | int operator""_hello(const char *); // expected-warning {{literal operators are incompatible with C++98}} | 
|  | 48 |  | 
|  | 49 | enum EnumFixed : int { // expected-warning {{enumeration types with a fixed underlying type are incompatible with C++98}} | 
|  | 50 | }; | 
|  | 51 |  | 
|  | 52 | enum class EnumScoped { // expected-warning {{scoped enumerations are incompatible with C++98}} | 
|  | 53 | }; | 
|  | 54 |  | 
|  | 55 | void Deleted() = delete; // expected-warning {{deleted function definitions are incompatible with C++98}} | 
|  | 56 | struct Defaulted { | 
|  | 57 | Defaulted() = default; // expected-warning {{defaulted function definitions are incompatible with C++98}} | 
|  | 58 | }; | 
|  | 59 |  | 
|  | 60 | int &&RvalueReference = 0; // expected-warning {{rvalue references are incompatible with C++98}} | 
|  | 61 | struct RefQualifier { | 
|  | 62 | void f() &; // expected-warning {{reference qualifiers on functions are incompatible with C++98}} | 
|  | 63 | }; | 
|  | 64 |  | 
|  | 65 | auto f() -> int; // expected-warning {{trailing return types are incompatible with C++98}} | 
|  | 66 |  | 
|  | 67 | void 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 |  | 
|  | 73 | struct InClassInit { | 
|  | 74 | int n = 0; // expected-warning {{in-class initialization of non-static data members is incompatible with C++98}} | 
|  | 75 | }; | 
|  | 76 |  | 
|  | 77 | struct OverrideControlBase { | 
|  | 78 | virtual void f(); | 
|  | 79 | virtual void g(); | 
|  | 80 | }; | 
|  | 81 | struct 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 |  | 
|  | 86 | using AliasDecl = int; // expected-warning {{alias declarations are incompatible with C++98}} | 
|  | 87 | template<typename T> using AliasTemplate = T; // expected-warning {{alias declarations are incompatible with C++98}} | 
|  | 88 |  | 
| Richard Smith | 0bf8a492 | 2011-10-18 20:49:44 +0000 | [diff] [blame] | 89 | inline namespace InlineNS { // expected-warning {{inline namespaces are incompatible with C++98}} | 
| Richard Smith | 5d164bc | 2011-10-15 05:09:34 +0000 | [diff] [blame] | 90 | } | 
| Richard Smith | e41fac2 | 2011-10-15 05:42:01 +0000 | [diff] [blame] | 91 |  | 
|  | 92 | auto auto_deduction = 0; // expected-warning {{'auto' type specifier is incompatible with C++98}} | 
|  | 93 | int *p = new auto(0); // expected-warning {{'auto' type specifier is incompatible with C++98}} | 
| Richard Smith | b15c11c | 2011-10-17 23:06:20 +0000 | [diff] [blame] | 94 |  | 
|  | 95 | const int align_of = alignof(int); // expected-warning {{alignof expressions are incompatible with C++98}} | 
|  | 96 | char16_t c16 = 0; // expected-warning {{'char16_t' type specifier is incompatible with C++98}} | 
|  | 97 | char32_t c32 = 0; // expected-warning {{'char32_t' type specifier is incompatible with C++98}} | 
|  | 98 | constexpr int const_expr = 0; // expected-warning {{'constexpr' specifier is incompatible with C++98}} | 
|  | 99 | decltype(const_expr) decl_type = 0; // expected-warning {{'decltype' type specifier is incompatible with C++98}} | 
|  | 100 | void no_except() noexcept; // expected-warning {{noexcept specifications are incompatible with C++98}} | 
|  | 101 | bool no_except_expr = noexcept(1 + 1); // expected-warning {{noexcept expressions are incompatible with C++98}} | 
|  | 102 | void *null = nullptr; // expected-warning {{'nullptr' is incompatible with C++98}} | 
|  | 103 | static_assert(true, "!"); // expected-warning {{static_assert declarations are incompatible with C++98}} | 
| Richard Smith | 0bf8a492 | 2011-10-18 20:49:44 +0000 | [diff] [blame] | 104 |  | 
|  | 105 | struct InhCtorBase { | 
|  | 106 | InhCtorBase(int); | 
|  | 107 | }; | 
|  | 108 | struct InhCtorDerived : InhCtorBase { | 
|  | 109 | using InhCtorBase::InhCtorBase; // expected-warning {{inherited constructors are incompatible with C++98}} | 
|  | 110 | }; | 
|  | 111 |  | 
|  | 112 | struct 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 |  | 
|  | 117 | struct DelegCtor { | 
|  | 118 | DelegCtor(int) : DelegCtor() {} // expected-warning {{delegating constructors are incompatible with C++98}} | 
|  | 119 | DelegCtor(); | 
|  | 120 | }; | 
|  | 121 |  | 
|  | 122 | template<int n = 0> void DefaultFuncTemplateArg(); // expected-warning {{default template arguments for a function template are incompatible with C++98}} | 
|  | 123 |  | 
|  | 124 | template<typename T> int TemplateFn(T) { return 0; } | 
|  | 125 | void LocalTemplateArg() { | 
|  | 126 | struct S {}; | 
|  | 127 | TemplateFn(S()); // expected-warning {{local type 'S' as template argument is incompatible with C++98}} | 
|  | 128 | } | 
|  | 129 | struct {} obj_of_unnamed_type; // expected-note {{here}} | 
|  | 130 | int UnnamedTemplateArg = TemplateFn(obj_of_unnamed_type); // expected-warning {{unnamed type as template argument is incompatible with C++98}} | 
|  | 131 |  | 
|  | 132 | namespace 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 |  | 
|  | 139 | namespace TemplateSpecOutOfScopeNs { | 
|  | 140 | template<typename T> struct S {}; // expected-note {{here}} | 
|  | 141 | } | 
|  | 142 | template<> struct TemplateSpecOutOfScopeNs::S<char> {}; // expected-warning {{class template specialization of 'S' outside namespace 'TemplateSpecOutOfScopeNs' is incompatible with C++98}} | 
|  | 143 |  | 
|  | 144 | struct Typename { | 
|  | 145 | template<typename T> struct Inner {}; | 
|  | 146 | }; | 
|  | 147 | typename ::Typename TypenameOutsideTemplate(); // expected-warning {{use of 'typename' outside of a template is incompatible with C++98}} | 
|  | 148 | Typename::template Inner<int> TemplateOutsideTemplate(); // expected-warning {{use of 'template' keyword outside of a template is incompatible with C++98}} | 
|  | 149 |  | 
|  | 150 | struct TrivialButNonPOD { | 
|  | 151 | int f(int); | 
|  | 152 | private: | 
|  | 153 | int k; | 
|  | 154 | }; | 
|  | 155 | void Ellipsis(int n, ...); | 
|  | 156 | void 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 |  | 
|  | 160 | struct HasExplicitConversion { | 
|  | 161 | explicit operator bool(); // expected-warning {{explicit conversion functions are incompatible with C++98}} | 
|  | 162 | }; | 
| Richard Smith | c823973 | 2011-10-18 21:39:00 +0000 | [diff] [blame] | 163 |  | 
|  | 164 | struct Struct {}; | 
|  | 165 | enum Enum { enum_val = 0 }; | 
|  | 166 | struct 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 |  | 
|  | 172 | int n = {}; // expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}} | 
| Richard Smith | 38c0e04 | 2011-10-19 00:07:01 +0000 | [diff] [blame] | 173 |  | 
|  | 174 | class PrivateMember { | 
|  | 175 | struct ImPrivate {}; | 
|  | 176 | }; | 
|  | 177 | template<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 | } | 
|  | 180 | int SFINAEAccessControl(...) { return 0; } | 
|  | 181 | int CheckSFINAEAccessControl = SFINAEAccessControl(PrivateMember()); | 
| Richard Smith | a066ccf | 2011-10-19 00:54:10 +0000 | [diff] [blame^] | 182 |  | 
|  | 183 | template<typename T> | 
|  | 184 | struct FriendRedefinition { | 
|  | 185 | friend void Friend() {} // expected-warning {{friend function 'Friend' would be implicitly redefined in C++98}} expected-note {{previous}} | 
|  | 186 | }; | 
|  | 187 | FriendRedefinition<int> FriendRedef1; | 
|  | 188 | FriendRedefinition<char> FriendRedef2; // expected-note {{requested here}} |