| 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 |  | 
| Richard Smith | 2b349ae | 2012-04-19 06:58:00 +0000 | [diff] [blame] | 4 | namespace std { | 
|  | 5 | struct type_info; | 
|  | 6 | using size_t = decltype(sizeof(0)); // expected-warning {{decltype}} expected-warning {{alias}} | 
|  | 7 | template<typename T> struct initializer_list { | 
|  | 8 | initializer_list(T*, size_t); | 
|  | 9 | T *p; | 
|  | 10 | size_t n; | 
|  | 11 | }; | 
|  | 12 | } | 
| Richard Smith | 2a98611 | 2012-02-25 10:20:59 +0000 | [diff] [blame] | 13 |  | 
| Richard Smith | 2b6b0ee | 2011-10-14 20:41:13 +0000 | [diff] [blame] | 14 | template<typename ...T>  // expected-warning {{variadic templates are incompatible with C++98}} | 
|  | 15 | class Variadic1 {}; | 
|  | 16 |  | 
|  | 17 | template<template<typename> class ...T>  // expected-warning {{variadic templates are incompatible with C++98}} | 
|  | 18 | class Variadic2 {}; | 
|  | 19 |  | 
|  | 20 | template<int ...I>  // expected-warning {{variadic templates are incompatible with C++98}} | 
|  | 21 | class Variadic3 {}; | 
| Richard Smith | f679b5b | 2011-10-14 20:48:27 +0000 | [diff] [blame] | 22 |  | 
| Michael Han | 64536a6 | 2012-11-06 19:34:54 +0000 | [diff] [blame] | 23 | alignas(8) int with_alignas; // expected-warning {{'alignas' is incompatible with C++98}} | 
| Richard Smith | f679b5b | 2011-10-14 20:48:27 +0000 | [diff] [blame] | 24 | int with_attribute [[ ]]; // expected-warning {{attributes are incompatible with C++98}} | 
| Richard Smith | acd4d3d | 2011-10-15 01:18:56 +0000 | [diff] [blame] | 25 |  | 
|  | 26 | void Literals() { | 
|  | 27 | (void)u8"str"; // expected-warning {{unicode literals are incompatible with C++98}} | 
|  | 28 | (void)u"str"; // expected-warning {{unicode literals are incompatible with C++98}} | 
|  | 29 | (void)U"str"; // expected-warning {{unicode literals are incompatible with C++98}} | 
|  | 30 | (void)u'x'; // expected-warning {{unicode literals are incompatible with C++98}} | 
|  | 31 | (void)U'x'; // expected-warning {{unicode literals are incompatible with C++98}} | 
|  | 32 |  | 
|  | 33 | (void)u8R"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}} | 
|  | 34 | (void)uR"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}} | 
|  | 35 | (void)UR"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}} | 
|  | 36 | (void)R"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}} | 
|  | 37 | (void)LR"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}} | 
|  | 38 | } | 
|  | 39 |  | 
|  | 40 | template<typename T> struct S {}; | 
| Richard Smith | 5d164bc | 2011-10-15 05:09:34 +0000 | [diff] [blame] | 41 | namespace TemplateParsing { | 
|  | 42 | S<::S<void> > s; // expected-warning {{'<::' is treated as digraph '<:' (aka '[') followed by ':' in C++98}} | 
|  | 43 | S< ::S<void>> t; // expected-warning {{consecutive right angle brackets are incompatible with C++98 (use '> >')}} | 
|  | 44 | } | 
|  | 45 |  | 
|  | 46 | void Lambda() { | 
| Richard Smith | 4297375 | 2012-02-16 20:41:22 +0000 | [diff] [blame] | 47 | []{}(); // expected-warning {{lambda expressions are incompatible with C++98}} | 
| Richard Smith | 5d164bc | 2011-10-15 05:09:34 +0000 | [diff] [blame] | 48 | } | 
|  | 49 |  | 
| Richard Smith | 2b349ae | 2012-04-19 06:58:00 +0000 | [diff] [blame] | 50 | struct Ctor { | 
|  | 51 | Ctor(int, char); | 
|  | 52 | Ctor(double, long); | 
|  | 53 | }; | 
|  | 54 | struct InitListCtor { | 
|  | 55 | InitListCtor(std::initializer_list<bool>); | 
|  | 56 | }; | 
|  | 57 |  | 
| Sebastian Redl | 1678d5f | 2012-03-18 22:25:45 +0000 | [diff] [blame] | 58 | int InitList(int i = {}) { // expected-warning {{generalized initializer lists are incompatible with C++98}} \ | 
|  | 59 | // expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}} | 
| Sebastian Redl | 82ace98 | 2012-02-11 23:51:08 +0000 | [diff] [blame] | 60 | (void)new int {}; // expected-warning {{generalized initializer lists are incompatible with C++98}} \ | 
|  | 61 | // expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}} | 
| Sebastian Redl | d74dd49 | 2012-02-12 18:41:05 +0000 | [diff] [blame] | 62 | (void)int{}; // expected-warning {{generalized initializer lists are incompatible with C++98}} \ | 
|  | 63 | // expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}} | 
| Richard Smith | c823973 | 2011-10-18 21:39:00 +0000 | [diff] [blame] | 64 | int x { 0 }; // expected-warning {{generalized initializer lists are incompatible with C++98}} | 
| Richard Smith | 2fbb3d8 | 2012-02-26 23:49:01 +0000 | [diff] [blame] | 65 | S<int> s = {}; // ok, aggregate | 
|  | 66 | s = {}; // expected-warning {{generalized initializer lists are incompatible with C++98}} | 
| Richard Smith | 2b349ae | 2012-04-19 06:58:00 +0000 | [diff] [blame] | 67 | std::initializer_list<int> xs = { 1, 2, 3 }; // expected-warning {{initialization of initializer_list object is incompatible with C++98}} | 
|  | 68 | auto ys = { 1, 2, 3 }; // expected-warning {{initialization of initializer_list object is incompatible with C++98}} \ | 
|  | 69 | // expected-warning {{'auto' type specifier is incompatible with C++98}} | 
|  | 70 | Ctor c1 = { 1, 2 }; // expected-warning {{constructor call from initializer list is incompatible with C++98}} | 
|  | 71 | Ctor c2 = { 3.0, 4l }; // expected-warning {{constructor call from initializer list is incompatible with C++98}} | 
|  | 72 | InitListCtor ilc = { true, false }; // expected-warning {{initialization of initializer_list object is incompatible with C++98}} | 
|  | 73 | const int &r = { 0 }; // expected-warning {{reference initialized from initializer list is incompatible with C++98}} | 
|  | 74 | struct { int a; const int &r; } rr = { 0, {{0}} }; // expected-warning {{reference initialized from initializer list is incompatible with C++98}} | 
| Richard Smith | c823973 | 2011-10-18 21:39:00 +0000 | [diff] [blame] | 75 | return { 0 }; // expected-warning {{generalized initializer lists are incompatible with C++98}} | 
| Richard Smith | 5d164bc | 2011-10-15 05:09:34 +0000 | [diff] [blame] | 76 | } | 
| Sebastian Redl | 6db0b1b | 2012-03-20 21:24:03 +0000 | [diff] [blame] | 77 | struct DelayedDefaultArgumentParseInitList { | 
|  | 78 | void f(int i = {1}) { // expected-warning {{generalized initializer lists are incompatible with C++98}} | 
|  | 79 | } | 
|  | 80 | }; | 
| Richard Smith | 5d164bc | 2011-10-15 05:09:34 +0000 | [diff] [blame] | 81 |  | 
| Richard Smith | e18f0fa | 2012-03-05 04:02:15 +0000 | [diff] [blame] | 82 | int operator"" _hello(const char *); // expected-warning {{literal operators are incompatible with C++98}} | 
| Richard Smith | 5d164bc | 2011-10-15 05:09:34 +0000 | [diff] [blame] | 83 |  | 
|  | 84 | enum EnumFixed : int { // expected-warning {{enumeration types with a fixed underlying type are incompatible with C++98}} | 
|  | 85 | }; | 
|  | 86 |  | 
|  | 87 | enum class EnumScoped { // expected-warning {{scoped enumerations are incompatible with C++98}} | 
|  | 88 | }; | 
|  | 89 |  | 
|  | 90 | void Deleted() = delete; // expected-warning {{deleted function definitions are incompatible with C++98}} | 
|  | 91 | struct Defaulted { | 
|  | 92 | Defaulted() = default; // expected-warning {{defaulted function definitions are incompatible with C++98}} | 
|  | 93 | }; | 
|  | 94 |  | 
|  | 95 | int &&RvalueReference = 0; // expected-warning {{rvalue references are incompatible with C++98}} | 
|  | 96 | struct RefQualifier { | 
|  | 97 | void f() &; // expected-warning {{reference qualifiers on functions are incompatible with C++98}} | 
|  | 98 | }; | 
|  | 99 |  | 
|  | 100 | auto f() -> int; // expected-warning {{trailing return types are incompatible with C++98}} | 
|  | 101 |  | 
|  | 102 | void RangeFor() { | 
|  | 103 | int xs[] = {1, 2, 3}; | 
|  | 104 | for (int &a : xs) { // expected-warning {{range-based for loop is incompatible with C++98}} | 
|  | 105 | } | 
|  | 106 | } | 
|  | 107 |  | 
|  | 108 | struct InClassInit { | 
|  | 109 | int n = 0; // expected-warning {{in-class initialization of non-static data members is incompatible with C++98}} | 
|  | 110 | }; | 
|  | 111 |  | 
|  | 112 | struct OverrideControlBase { | 
|  | 113 | virtual void f(); | 
|  | 114 | virtual void g(); | 
|  | 115 | }; | 
|  | 116 | struct OverrideControl final : OverrideControlBase { // expected-warning {{'final' keyword is incompatible with C++98}} | 
|  | 117 | virtual void f() override; // expected-warning {{'override' keyword is incompatible with C++98}} | 
|  | 118 | virtual void g() final; // expected-warning {{'final' keyword is incompatible with C++98}} | 
|  | 119 | }; | 
|  | 120 |  | 
|  | 121 | using AliasDecl = int; // expected-warning {{alias declarations are incompatible with C++98}} | 
|  | 122 | template<typename T> using AliasTemplate = T; // expected-warning {{alias declarations are incompatible with C++98}} | 
|  | 123 |  | 
| Richard Smith | 0bf8a492 | 2011-10-18 20:49:44 +0000 | [diff] [blame] | 124 | inline namespace InlineNS { // expected-warning {{inline namespaces are incompatible with C++98}} | 
| Richard Smith | 5d164bc | 2011-10-15 05:09:34 +0000 | [diff] [blame] | 125 | } | 
| Richard Smith | e41fac2 | 2011-10-15 05:42:01 +0000 | [diff] [blame] | 126 |  | 
|  | 127 | auto auto_deduction = 0; // expected-warning {{'auto' type specifier is incompatible with C++98}} | 
|  | 128 | 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] | 129 |  | 
|  | 130 | const int align_of = alignof(int); // expected-warning {{alignof expressions are incompatible with C++98}} | 
|  | 131 | char16_t c16 = 0; // expected-warning {{'char16_t' type specifier is incompatible with C++98}} | 
|  | 132 | char32_t c32 = 0; // expected-warning {{'char32_t' type specifier is incompatible with C++98}} | 
|  | 133 | constexpr int const_expr = 0; // expected-warning {{'constexpr' specifier is incompatible with C++98}} | 
|  | 134 | decltype(const_expr) decl_type = 0; // expected-warning {{'decltype' type specifier is incompatible with C++98}} | 
| Richard Smith | fd3da93 | 2012-02-24 18:10:23 +0000 | [diff] [blame] | 135 | __decltype(const_expr) decl_type2 = 0; // ok | 
| Richard Smith | b15c11c | 2011-10-17 23:06:20 +0000 | [diff] [blame] | 136 | void no_except() noexcept; // expected-warning {{noexcept specifications are incompatible with C++98}} | 
|  | 137 | bool no_except_expr = noexcept(1 + 1); // expected-warning {{noexcept expressions are incompatible with C++98}} | 
|  | 138 | void *null = nullptr; // expected-warning {{'nullptr' is incompatible with C++98}} | 
|  | 139 | 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] | 140 |  | 
| Richard Smith | d494c50 | 2012-04-27 19:33:05 +0000 | [diff] [blame] | 141 | // FIXME: Reintroduce this test if support for inheriting constructors is | 
|  | 142 | //        implemented. | 
|  | 143 | #if 0 | 
| Richard Smith | 0bf8a492 | 2011-10-18 20:49:44 +0000 | [diff] [blame] | 144 | struct InhCtorBase { | 
|  | 145 | InhCtorBase(int); | 
|  | 146 | }; | 
|  | 147 | struct InhCtorDerived : InhCtorBase { | 
| Richard Smith | d494c50 | 2012-04-27 19:33:05 +0000 | [diff] [blame] | 148 | using InhCtorBase::InhCtorBase; // xpected-warning {{inheriting constructors are incompatible with C++98}} | 
| Richard Smith | 0bf8a492 | 2011-10-18 20:49:44 +0000 | [diff] [blame] | 149 | }; | 
| Richard Smith | d494c50 | 2012-04-27 19:33:05 +0000 | [diff] [blame] | 150 | #endif | 
| Richard Smith | 0bf8a492 | 2011-10-18 20:49:44 +0000 | [diff] [blame] | 151 |  | 
|  | 152 | struct FriendMember { | 
|  | 153 | static void MemberFn(); | 
|  | 154 | friend void FriendMember::MemberFn(); // expected-warning {{friend declaration naming a member of the declaring class is incompatible with C++98}} | 
|  | 155 | }; | 
|  | 156 |  | 
|  | 157 | struct DelegCtor { | 
|  | 158 | DelegCtor(int) : DelegCtor() {} // expected-warning {{delegating constructors are incompatible with C++98}} | 
|  | 159 | DelegCtor(); | 
|  | 160 | }; | 
|  | 161 |  | 
|  | 162 | template<int n = 0> void DefaultFuncTemplateArg(); // expected-warning {{default template arguments for a function template are incompatible with C++98}} | 
|  | 163 |  | 
|  | 164 | template<typename T> int TemplateFn(T) { return 0; } | 
|  | 165 | void LocalTemplateArg() { | 
|  | 166 | struct S {}; | 
|  | 167 | TemplateFn(S()); // expected-warning {{local type 'S' as template argument is incompatible with C++98}} | 
|  | 168 | } | 
|  | 169 | struct {} obj_of_unnamed_type; // expected-note {{here}} | 
|  | 170 | int UnnamedTemplateArg = TemplateFn(obj_of_unnamed_type); // expected-warning {{unnamed type as template argument is incompatible with C++98}} | 
|  | 171 |  | 
|  | 172 | namespace RedundantParensInAddressTemplateParam { | 
|  | 173 | int n; | 
|  | 174 | template<int*p> struct S {}; | 
|  | 175 | S<(&n)> s; // expected-warning {{redundant parentheses surrounding address non-type template argument are incompatible with C++98}} | 
|  | 176 | S<(((&n)))> t; // expected-warning {{redundant parentheses surrounding address non-type template argument are incompatible with C++98}} | 
|  | 177 | } | 
|  | 178 |  | 
|  | 179 | namespace TemplateSpecOutOfScopeNs { | 
|  | 180 | template<typename T> struct S {}; // expected-note {{here}} | 
|  | 181 | } | 
|  | 182 | template<> struct TemplateSpecOutOfScopeNs::S<char> {}; // expected-warning {{class template specialization of 'S' outside namespace 'TemplateSpecOutOfScopeNs' is incompatible with C++98}} | 
|  | 183 |  | 
|  | 184 | struct Typename { | 
|  | 185 | template<typename T> struct Inner {}; | 
|  | 186 | }; | 
|  | 187 | typename ::Typename TypenameOutsideTemplate(); // expected-warning {{use of 'typename' outside of a template is incompatible with C++98}} | 
|  | 188 | Typename::template Inner<int> TemplateOutsideTemplate(); // expected-warning {{use of 'template' keyword outside of a template is incompatible with C++98}} | 
|  | 189 |  | 
|  | 190 | struct TrivialButNonPOD { | 
|  | 191 | int f(int); | 
|  | 192 | private: | 
|  | 193 | int k; | 
|  | 194 | }; | 
|  | 195 | void Ellipsis(int n, ...); | 
|  | 196 | void TrivialButNonPODThroughEllipsis() { | 
|  | 197 | Ellipsis(1, TrivialButNonPOD()); // expected-warning {{passing object of trivial but non-POD type 'TrivialButNonPOD' through variadic function is incompatible with C++98}} | 
|  | 198 | } | 
|  | 199 |  | 
|  | 200 | struct HasExplicitConversion { | 
|  | 201 | explicit operator bool(); // expected-warning {{explicit conversion functions are incompatible with C++98}} | 
|  | 202 | }; | 
| Richard Smith | c823973 | 2011-10-18 21:39:00 +0000 | [diff] [blame] | 203 |  | 
|  | 204 | struct Struct {}; | 
|  | 205 | enum Enum { enum_val = 0 }; | 
|  | 206 | struct BadFriends { | 
|  | 207 | friend enum ::Enum; // expected-warning {{befriending enumeration type 'enum ::Enum' is incompatible with C++98}} | 
|  | 208 | friend int; // expected-warning {{non-class friend type 'int' is incompatible with C++98}} | 
|  | 209 | friend Struct; // expected-warning {{befriending 'Struct' without 'struct' keyword is incompatible with C++98}} | 
|  | 210 | }; | 
|  | 211 |  | 
|  | 212 | 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] | 213 |  | 
|  | 214 | class PrivateMember { | 
|  | 215 | struct ImPrivate {}; | 
|  | 216 | }; | 
|  | 217 | 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]}} | 
|  | 218 | return typename T::ImPrivate(); | 
|  | 219 | } | 
|  | 220 | int SFINAEAccessControl(...) { return 0; } | 
|  | 221 | int CheckSFINAEAccessControl = SFINAEAccessControl(PrivateMember()); | 
| Richard Smith | a066ccf | 2011-10-19 00:54:10 +0000 | [diff] [blame] | 222 |  | 
|  | 223 | template<typename T> | 
|  | 224 | struct FriendRedefinition { | 
|  | 225 | friend void Friend() {} // expected-warning {{friend function 'Friend' would be implicitly redefined in C++98}} expected-note {{previous}} | 
|  | 226 | }; | 
|  | 227 | FriendRedefinition<int> FriendRedef1; | 
|  | 228 | FriendRedefinition<char> FriendRedef2; // expected-note {{requested here}} | 
| Richard Smith | c620f55 | 2011-10-19 16:55:56 +0000 | [diff] [blame] | 229 |  | 
|  | 230 | namespace CopyCtorIssues { | 
|  | 231 | struct Private { | 
|  | 232 | Private(); | 
|  | 233 | private: | 
|  | 234 | Private(const Private&); // expected-note {{declared private here}} | 
|  | 235 | }; | 
|  | 236 | struct NoViable { | 
|  | 237 | NoViable(); | 
|  | 238 | NoViable(NoViable&); // expected-note {{not viable}} | 
|  | 239 | }; | 
|  | 240 | struct Ambiguous { | 
|  | 241 | Ambiguous(); | 
|  | 242 | Ambiguous(const Ambiguous &, int = 0); // expected-note {{candidate}} | 
|  | 243 | Ambiguous(const Ambiguous &, double = 0); // expected-note {{candidate}} | 
|  | 244 | }; | 
| Richard Smith | 852265f | 2012-03-30 20:53:28 +0000 | [diff] [blame] | 245 | struct Deleted { | 
|  | 246 | Private p; // expected-note {{implicitly deleted}} | 
| Richard Smith | c620f55 | 2011-10-19 16:55:56 +0000 | [diff] [blame] | 247 | }; | 
|  | 248 |  | 
|  | 249 | const Private &a = Private(); // expected-warning {{copying variable of type 'CopyCtorIssues::Private' when binding a reference to a temporary would invoke an inaccessible constructor in C++98}} | 
|  | 250 | const NoViable &b = NoViable(); // expected-warning {{copying variable of type 'CopyCtorIssues::NoViable' when binding a reference to a temporary would find no viable constructor in C++98}} | 
|  | 251 | const Ambiguous &c = Ambiguous(); // expected-warning {{copying variable of type 'CopyCtorIssues::Ambiguous' when binding a reference to a temporary would find ambiguous constructors in C++98}} | 
|  | 252 | const Deleted &d = Deleted(); // expected-warning {{copying variable of type 'CopyCtorIssues::Deleted' when binding a reference to a temporary would invoke a deleted constructor in C++98}} | 
|  | 253 | } | 
| Richard Smith | f720df0 | 2011-10-19 20:41:51 +0000 | [diff] [blame] | 254 |  | 
|  | 255 | namespace UnionOrAnonStructMembers { | 
|  | 256 | struct NonTrivCtor { | 
| Richard Smith | 92f241f | 2012-12-08 02:53:02 +0000 | [diff] [blame^] | 257 | NonTrivCtor(); // expected-note 2{{user-provided default constructor}} | 
| Richard Smith | f720df0 | 2011-10-19 20:41:51 +0000 | [diff] [blame] | 258 | }; | 
|  | 259 | struct NonTrivCopy { | 
| Richard Smith | 92f241f | 2012-12-08 02:53:02 +0000 | [diff] [blame^] | 260 | NonTrivCopy(const NonTrivCopy&); // expected-note 2{{user-provided copy constructor}} | 
| Richard Smith | f720df0 | 2011-10-19 20:41:51 +0000 | [diff] [blame] | 261 | }; | 
|  | 262 | struct NonTrivDtor { | 
| Richard Smith | 92f241f | 2012-12-08 02:53:02 +0000 | [diff] [blame^] | 263 | ~NonTrivDtor(); // expected-note 2{{user-provided destructor}} | 
| Richard Smith | f720df0 | 2011-10-19 20:41:51 +0000 | [diff] [blame] | 264 | }; | 
|  | 265 | union BadUnion { | 
|  | 266 | NonTrivCtor ntc; // expected-warning {{union member 'ntc' with a non-trivial constructor is incompatible with C++98}} | 
|  | 267 | NonTrivCopy ntcp; // expected-warning {{union member 'ntcp' with a non-trivial copy constructor is incompatible with C++98}} | 
|  | 268 | NonTrivDtor ntd; // expected-warning {{union member 'ntd' with a non-trivial destructor is incompatible with C++98}} | 
|  | 269 | }; | 
|  | 270 | struct Wrap { | 
|  | 271 | struct { | 
|  | 272 | NonTrivCtor ntc; // expected-warning {{anonymous struct member 'ntc' with a non-trivial constructor is incompatible with C++98}} | 
|  | 273 | NonTrivCopy ntcp; // expected-warning {{anonymous struct member 'ntcp' with a non-trivial copy constructor is incompatible with C++98}} | 
|  | 274 | NonTrivDtor ntd; // expected-warning {{anonymous struct member 'ntd' with a non-trivial destructor is incompatible with C++98}} | 
|  | 275 | }; | 
|  | 276 | }; | 
| Richard Smith | 4297375 | 2012-02-16 20:41:22 +0000 | [diff] [blame] | 277 | union WithStaticDataMember { | 
|  | 278 | 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}} | 
|  | 279 | static const int n = 0; // expected-warning {{static data member 'n' in union is incompatible with C++98}} | 
|  | 280 | static int k; // expected-warning {{static data member 'k' in union is incompatible with C++98}} | 
|  | 281 | }; | 
| Richard Smith | f720df0 | 2011-10-19 20:41:51 +0000 | [diff] [blame] | 282 | } | 
| Richard Smith | 91c7bbd | 2011-10-20 03:28:47 +0000 | [diff] [blame] | 283 |  | 
|  | 284 | int EnumNNS = Enum::enum_val; // expected-warning {{enumeration type in nested name specifier is incompatible with C++98}} | 
|  | 285 | template<typename T> void EnumNNSFn() { | 
|  | 286 | int k = T::enum_val; // expected-warning {{enumeration type in nested name specifier is incompatible with C++98}} | 
|  | 287 | }; | 
|  | 288 | template void EnumNNSFn<Enum>(); // expected-note {{in instantiation}} | 
| Richard Smith | fe2750d | 2011-10-20 21:42:12 +0000 | [diff] [blame] | 289 |  | 
|  | 290 | void JumpDiagnostics(int n) { | 
|  | 291 | goto DirectJump; // expected-warning {{goto would jump into protected scope in C++98}} | 
|  | 292 | TrivialButNonPOD tnp1; // expected-note {{jump bypasses initialization of non-POD variable}} | 
|  | 293 |  | 
|  | 294 | DirectJump: | 
|  | 295 | void *Table[] = {&&DirectJump, &&Later}; | 
|  | 296 | goto *Table[n]; // expected-warning {{indirect goto might cross protected scopes in C++98}} | 
|  | 297 |  | 
|  | 298 | TrivialButNonPOD tnp2; // expected-note {{jump bypasses initialization of non-POD variable}} | 
|  | 299 | Later: // expected-note {{possible target of indirect goto}} | 
|  | 300 | switch (n) { | 
|  | 301 | TrivialButNonPOD tnp3; // expected-note {{jump bypasses initialization of non-POD variable}} | 
|  | 302 | default: // expected-warning {{switch case would be in a protected scope in C++98}} | 
|  | 303 | return; | 
|  | 304 | } | 
|  | 305 | } | 
| Richard Smith | 2a98611 | 2012-02-25 10:20:59 +0000 | [diff] [blame] | 306 |  | 
|  | 307 | namespace UnevaluatedMemberAccess { | 
|  | 308 | struct S { | 
|  | 309 | int n; | 
|  | 310 | int f() { return sizeof(S::n); } // ok | 
|  | 311 | }; | 
|  | 312 | int k = sizeof(S::n); // expected-warning {{use of non-static data member 'n' in an unevaluated context is incompatible with C++98}} | 
|  | 313 | 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}} | 
|  | 314 | } | 
| Richard Smith | 2a70e65 | 2012-03-09 22:27:51 +0000 | [diff] [blame] | 315 |  | 
|  | 316 | namespace LiteralUCNs { | 
|  | 317 | char c1 = '\u001e'; // expected-warning {{universal character name referring to a control character is incompatible with C++98}} | 
|  | 318 | wchar_t c2 = L'\u0041'; // expected-warning {{specifying character 'A' with a universal character name is incompatible with C++98}} | 
|  | 319 | const char *s1 = "foo\u0031"; // expected-warning {{specifying character '1' with a universal character name is incompatible with C++98}} | 
|  | 320 | const wchar_t *s2 = L"bar\u0085"; // expected-warning {{universal character name referring to a control character is incompatible with C++98}} | 
|  | 321 | } | 
| Richard Smith | 9380e0e | 2012-04-04 21:11:30 +0000 | [diff] [blame] | 322 |  | 
|  | 323 | namespace NonTypeTemplateArgs { | 
|  | 324 | template<typename T, T v> struct S {}; | 
|  | 325 | const int k = 5; // expected-note {{here}} | 
|  | 326 | static void f() {} // expected-note {{here}} | 
|  | 327 | S<const int&, k> s1; // expected-warning {{non-type template argument referring to object 'k' with internal linkage is incompatible with C++98}} | 
|  | 328 | S<void(&)(), f> s2; // expected-warning {{non-type template argument referring to function 'f' with internal linkage is incompatible with C++98}} | 
|  | 329 | } | 
| Richard Smith | bc8c5b5 | 2012-04-26 01:51:03 +0000 | [diff] [blame] | 330 |  | 
| Richard Smith | bc8c5b5 | 2012-04-26 01:51:03 +0000 | [diff] [blame] | 331 | namespace NullPointerTemplateArg { | 
|  | 332 | struct A {}; | 
|  | 333 | template<int*> struct X {}; | 
|  | 334 | template<int A::*> struct Y {}; | 
|  | 335 | X<(int*)0> x; // expected-warning {{use of null pointer as non-type template argument is incompatible with C++98}} | 
|  | 336 | Y<(int A::*)0> y; // expected-warning {{use of null pointer as non-type template argument is incompatible with C++98}} | 
|  | 337 | } | 
| Benjamin Kramer | bc7dd9e | 2012-07-30 15:53:26 +0000 | [diff] [blame] | 338 |  | 
|  | 339 | namespace PR13480 { | 
|  | 340 | struct basic_iterator { | 
| Richard Smith | 92f241f | 2012-12-08 02:53:02 +0000 | [diff] [blame^] | 341 | basic_iterator(const basic_iterator &it) {} // expected-note {{because type 'PR13480::basic_iterator' has a user-provided copy constructor}} | 
|  | 342 | basic_iterator(basic_iterator &it) {} | 
| Benjamin Kramer | bc7dd9e | 2012-07-30 15:53:26 +0000 | [diff] [blame] | 343 | }; | 
|  | 344 |  | 
|  | 345 | union test { | 
|  | 346 | basic_iterator it; // expected-warning {{union member 'it' with a non-trivial copy constructor is incompatible with C++98}} | 
|  | 347 | }; | 
|  | 348 | } | 
| Benjamin Kramer | e3895eb | 2012-07-30 16:41:40 +0000 | [diff] [blame] | 349 |  | 
|  | 350 | namespace AssignOpUnion { | 
|  | 351 | struct a { | 
| Richard Smith | 92f241f | 2012-12-08 02:53:02 +0000 | [diff] [blame^] | 352 | void operator=(const a &it) {} // expected-note {{because type 'AssignOpUnion::a' has a user-provided copy assignment operator}} | 
|  | 353 | void operator=(a &it) {} | 
| Benjamin Kramer | e3895eb | 2012-07-30 16:41:40 +0000 | [diff] [blame] | 354 | }; | 
|  | 355 |  | 
|  | 356 | struct b { | 
| Richard Smith | 92f241f | 2012-12-08 02:53:02 +0000 | [diff] [blame^] | 357 | void operator=(const b &it) {} // expected-note {{because type 'AssignOpUnion::b' has a user-provided copy assignment operator}} | 
| Benjamin Kramer | e3895eb | 2012-07-30 16:41:40 +0000 | [diff] [blame] | 358 | }; | 
|  | 359 |  | 
|  | 360 | union test1 { | 
|  | 361 | a x; // expected-warning {{union member 'x' with a non-trivial copy assignment operator is incompatible with C++98}} | 
|  | 362 | b y; // expected-warning {{union member 'y' with a non-trivial copy assignment operator is incompatible with C++98}} | 
|  | 363 | }; | 
|  | 364 | } | 
| Douglas Gregor | a3d3fe9 | 2012-08-30 21:47:37 +0000 | [diff] [blame] | 365 |  | 
|  | 366 | namespace rdar11736429 { | 
| Richard Smith | 92f241f | 2012-12-08 02:53:02 +0000 | [diff] [blame^] | 367 | struct X { // expected-note {{because type 'rdar11736429::X' has no default constructor}} | 
| Douglas Gregor | a3d3fe9 | 2012-08-30 21:47:37 +0000 | [diff] [blame] | 368 | X(const X&) = delete; // expected-warning{{deleted function definitions are incompatible with C++98}} \ | 
| Richard Smith | 92f241f | 2012-12-08 02:53:02 +0000 | [diff] [blame^] | 369 | // expected-note {{implicit default constructor suppressed by user-declared constructor}} | 
| Douglas Gregor | a3d3fe9 | 2012-08-30 21:47:37 +0000 | [diff] [blame] | 370 | }; | 
|  | 371 |  | 
|  | 372 | union S { | 
|  | 373 | X x; // expected-warning{{union member 'x' with a non-trivial constructor is incompatible with C++98}} | 
|  | 374 | }; | 
|  | 375 | } |