Richard Smith | 5371160 | 2011-11-29 09:09:06 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -pedantic -Wall -Wno-comment -verify -fcxx-exceptions -x c++ %s |
Rafael Espindola | 925213b | 2013-07-04 16:16:58 +0000 | [diff] [blame] | 2 | // RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -x c++ %s 2>&1 | FileCheck %s |
Nick Lewycky | 784fad7 | 2010-04-24 01:30:46 +0000 | [diff] [blame] | 3 | // RUN: cp %s %t |
Richard Smith | 5371160 | 2011-11-29 09:09:06 +0000 | [diff] [blame] | 4 | // RUN: not %clang_cc1 -pedantic -Wall -Wno-comment -fcxx-exceptions -fixit -x c++ %t |
| 5 | // RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -Wno-comment -fcxx-exceptions -x c++ %t |
Douglas Gregor | e3e01a2 | 2009-04-01 22:41:11 +0000 | [diff] [blame] | 6 | |
| 7 | /* This is a test of the various code modification hints that are |
Douglas Gregor | 7e70204 | 2009-04-02 03:20:30 +0000 | [diff] [blame] | 8 | provided as part of warning or extension diagnostics. All of the |
| 9 | warnings will be fixed by -fixit, and the resulting file should |
| 10 | compile cleanly with -Werror -pedantic. */ |
Douglas Gregor | e3e01a2 | 2009-04-01 22:41:11 +0000 | [diff] [blame] | 11 | |
Nick Lewycky | 784fad7 | 2010-04-24 01:30:46 +0000 | [diff] [blame] | 12 | struct C1 { |
Douglas Gregor | 170512f | 2009-04-01 23:51:29 +0000 | [diff] [blame] | 13 | virtual void f(); |
| 14 | static void g(); |
| 15 | }; |
Douglas Gregor | e3e01a2 | 2009-04-01 22:41:11 +0000 | [diff] [blame] | 16 | struct C2 : virtual public virtual C1 { }; // expected-error{{duplicate}} |
| 17 | |
Douglas Gregor | 170512f | 2009-04-01 23:51:29 +0000 | [diff] [blame] | 18 | virtual void C1::f() { } // expected-error{{'virtual' can only be specified inside the class definition}} |
| 19 | |
| 20 | static void C1::g() { } // expected-error{{'static' can only be specified inside the class definition}} |
| 21 | |
| 22 | template<int Value> struct CT { }; // expected-note{{previous use is here}} |
Douglas Gregor | e3e01a2 | 2009-04-01 22:41:11 +0000 | [diff] [blame] | 23 | |
| 24 | CT<10 >> 2> ct; // expected-warning{{require parentheses}} |
Douglas Gregor | 170512f | 2009-04-01 23:51:29 +0000 | [diff] [blame] | 25 | |
| 26 | class C3 { |
| 27 | public: |
| 28 | C3(C3, int i = 0); // expected-error{{copy constructor must pass its first argument by reference}} |
| 29 | }; |
| 30 | |
| 31 | struct CT<0> { }; // expected-error{{'template<>'}} |
| 32 | |
Richard Smith | 4e9ea71 | 2011-10-20 01:41:28 +0000 | [diff] [blame] | 33 | template<> union CT<1> { }; // expected-error{{tag type}} |
Anders Carlsson | 0b8ea55 | 2009-11-10 03:24:44 +0000 | [diff] [blame] | 34 | |
Douglas Gregor | f1d70ad | 2010-02-01 23:46:27 +0000 | [diff] [blame] | 35 | // Access declarations |
| 36 | class A { |
| 37 | protected: |
| 38 | int foo(); |
| 39 | }; |
Anders Carlsson | 0b8ea55 | 2009-11-10 03:24:44 +0000 | [diff] [blame] | 40 | |
Douglas Gregor | f1d70ad | 2010-02-01 23:46:27 +0000 | [diff] [blame] | 41 | class B : public A { |
| 42 | A::foo; // expected-warning{{access declarations are deprecated}} |
| 43 | }; |
Douglas Gregor | d6bc5e6 | 2010-03-24 07:14:45 +0000 | [diff] [blame] | 44 | |
Richard Smith | 4e9ea71 | 2011-10-20 01:41:28 +0000 | [diff] [blame] | 45 | void f() throw(); // expected-note{{previous}} |
Douglas Gregor | d6bc5e6 | 2010-03-24 07:14:45 +0000 | [diff] [blame] | 46 | void f(); // expected-warning{{missing exception specification}} |
Douglas Gregor | 2fb18b7 | 2010-04-14 20:27:54 +0000 | [diff] [blame] | 47 | |
| 48 | namespace rdar7853795 { |
| 49 | struct A { |
| 50 | bool getNumComponents() const; // expected-note{{declared here}} |
Nick Lewycky | 784fad7 | 2010-04-24 01:30:46 +0000 | [diff] [blame] | 51 | void dump() const { |
Douglas Gregor | 2fb18b7 | 2010-04-14 20:27:54 +0000 | [diff] [blame] | 52 | getNumComponenets(); // expected-error{{use of undeclared identifier 'getNumComponenets'; did you mean 'getNumComponents'?}} |
| 53 | } |
| 54 | }; |
| 55 | } |
Douglas Gregor | 3465e26 | 2010-09-07 14:35:10 +0000 | [diff] [blame] | 56 | |
| 57 | namespace rdar7796492 { |
Benjamin Kramer | 697067f | 2012-06-11 16:06:57 +0000 | [diff] [blame] | 58 | struct A { int x, y; A(); }; |
Douglas Gregor | 3465e26 | 2010-09-07 14:35:10 +0000 | [diff] [blame] | 59 | |
| 60 | A::A() |
| 61 | : x(1) y(2) { // expected-error{{missing ',' between base or member initializers}} |
| 62 | } |
| 63 | |
| 64 | } |
Gabor Greif | 80c2183 | 2010-09-08 00:31:13 +0000 | [diff] [blame] | 65 | |
Francois Pichet | 6d76e6c | 2010-10-01 21:19:28 +0000 | [diff] [blame] | 66 | // extra qualification on member |
| 67 | class C { |
Douglas Gregor | 43bc036 | 2012-09-13 20:16:20 +0000 | [diff] [blame] | 68 | int C::foo(); // expected-error {{extra qualification}} |
Francois Pichet | 6d76e6c | 2010-10-01 21:19:28 +0000 | [diff] [blame] | 69 | }; |
| 70 | |
Argyrios Kyrtzidis | b5c7c51 | 2010-10-08 02:39:23 +0000 | [diff] [blame] | 71 | namespace rdar8488464 { |
Richard Trieu | 4972a6d | 2012-01-19 22:01:51 +0000 | [diff] [blame] | 72 | int x = 0; |
| 73 | int x1 &= 0; // expected-error {{invalid '&=' at end of declaration; did you mean '='?}} |
| 74 | int x2 *= 0; // expected-error {{invalid '*=' at end of declaration; did you mean '='?}} |
| 75 | int x3 += 0; // expected-error {{invalid '+=' at end of declaration; did you mean '='?}} |
| 76 | int x4 -= 0; // expected-error {{invalid '-=' at end of declaration; did you mean '='?}} |
| 77 | int x5 != 0; // expected-error {{invalid '!=' at end of declaration; did you mean '='?}} |
| 78 | int x6 /= 0; // expected-error {{invalid '/=' at end of declaration; did you mean '='?}} |
| 79 | int x7 %= 0; // expected-error {{invalid '%=' at end of declaration; did you mean '='?}} |
| 80 | int x8 <= 0; // expected-error {{invalid '<=' at end of declaration; did you mean '='?}} |
| 81 | int x9 <<= 0; // expected-error {{invalid '<<=' at end of declaration; did you mean '='?}} |
| 82 | int x10 >= 0; // expected-error {{invalid '>=' at end of declaration; did you mean '='?}} |
| 83 | int x11 >>= 0; // expected-error {{invalid '>>=' at end of declaration; did you mean '='?}} |
| 84 | int x12 ^= 0; // expected-error {{invalid '^=' at end of declaration; did you mean '='?}} |
| 85 | int x13 |= 0; // expected-error {{invalid '|=' at end of declaration; did you mean '='?}} |
| 86 | int x14 == 0; // expected-error {{invalid '==' at end of declaration; did you mean '='?}} |
Argyrios Kyrtzidis | b5c7c51 | 2010-10-08 02:39:23 +0000 | [diff] [blame] | 87 | |
| 88 | void f() { |
Richard Trieu | 4972a6d | 2012-01-19 22:01:51 +0000 | [diff] [blame] | 89 | int x = 0; |
Argyrios Kyrtzidis | b5c7c51 | 2010-10-08 02:39:23 +0000 | [diff] [blame] | 90 | (void)x; |
Richard Trieu | 4972a6d | 2012-01-19 22:01:51 +0000 | [diff] [blame] | 91 | int x1 &= 0; // expected-error {{invalid '&=' at end of declaration; did you mean '='?}} |
| 92 | (void)x1; |
| 93 | int x2 *= 0; // expected-error {{invalid '*=' at end of declaration; did you mean '='?}} |
| 94 | (void)x2; |
| 95 | int x3 += 0; // expected-error {{invalid '+=' at end of declaration; did you mean '='?}} |
| 96 | (void)x3; |
| 97 | int x4 -= 0; // expected-error {{invalid '-=' at end of declaration; did you mean '='?}} |
| 98 | (void)x4; |
| 99 | int x5 != 0; // expected-error {{invalid '!=' at end of declaration; did you mean '='?}} |
| 100 | (void)x5; |
| 101 | int x6 /= 0; // expected-error {{invalid '/=' at end of declaration; did you mean '='?}} |
| 102 | (void)x6; |
| 103 | int x7 %= 0; // expected-error {{invalid '%=' at end of declaration; did you mean '='?}} |
| 104 | (void)x7; |
| 105 | int x8 <= 0; // expected-error {{invalid '<=' at end of declaration; did you mean '='?}} |
| 106 | (void)x8; |
| 107 | int x9 <<= 0; // expected-error {{invalid '<<=' at end of declaration; did you mean '='?}} |
| 108 | (void)x9; |
| 109 | int x10 >= 0; // expected-error {{invalid '>=' at end of declaration; did you mean '='?}} |
| 110 | (void)x10; |
| 111 | int x11 >>= 0; // expected-error {{invalid '>>=' at end of declaration; did you mean '='?}} |
| 112 | (void)x11; |
| 113 | int x12 ^= 0; // expected-error {{invalid '^=' at end of declaration; did you mean '='?}} |
| 114 | (void)x12; |
| 115 | int x13 |= 0; // expected-error {{invalid '|=' at end of declaration; did you mean '='?}} |
| 116 | (void)x13; |
| 117 | int x14 == 0; // expected-error {{invalid '==' at end of declaration; did you mean '='?}} |
| 118 | (void)x14; |
| 119 | if (int x = 0) { (void)x; } |
| 120 | if (int x1 &= 0) { (void)x1; } // expected-error {{invalid '&=' at end of declaration; did you mean '='?}} |
| 121 | if (int x2 *= 0) { (void)x2; } // expected-error {{invalid '*=' at end of declaration; did you mean '='?}} |
| 122 | if (int x3 += 0) { (void)x3; } // expected-error {{invalid '+=' at end of declaration; did you mean '='?}} |
| 123 | if (int x4 -= 0) { (void)x4; } // expected-error {{invalid '-=' at end of declaration; did you mean '='?}} |
| 124 | if (int x5 != 0) { (void)x5; } // expected-error {{invalid '!=' at end of declaration; did you mean '='?}} |
| 125 | if (int x6 /= 0) { (void)x6; } // expected-error {{invalid '/=' at end of declaration; did you mean '='?}} |
| 126 | if (int x7 %= 0) { (void)x7; } // expected-error {{invalid '%=' at end of declaration; did you mean '='?}} |
| 127 | if (int x8 <= 0) { (void)x8; } // expected-error {{invalid '<=' at end of declaration; did you mean '='?}} |
| 128 | if (int x9 <<= 0) { (void)x9; } // expected-error {{invalid '<<=' at end of declaration; did you mean '='?}} |
| 129 | if (int x10 >= 0) { (void)x10; } // expected-error {{invalid '>=' at end of declaration; did you mean '='?}} |
| 130 | if (int x11 >>= 0) { (void)x11; } // expected-error {{invalid '>>=' at end of declaration; did you mean '='?}} |
| 131 | if (int x12 ^= 0) { (void)x12; } // expected-error {{invalid '^=' at end of declaration; did you mean '='?}} |
| 132 | if (int x13 |= 0) { (void)x13; } // expected-error {{invalid '|=' at end of declaration; did you mean '='?}} |
| 133 | if (int x14 == 0) { (void)x14; } // expected-error {{invalid '==' at end of declaration; did you mean '='?}} |
Argyrios Kyrtzidis | b5c7c51 | 2010-10-08 02:39:23 +0000 | [diff] [blame] | 134 | } |
| 135 | } |
| 136 | |
Francois Pichet | 4e7a2c0 | 2011-03-27 19:41:34 +0000 | [diff] [blame] | 137 | template <class A> |
| 138 | class F1 { |
| 139 | public: |
| 140 | template <int B> |
| 141 | class Iterator { |
| 142 | }; |
| 143 | }; |
| 144 | |
| 145 | template<class T> |
| 146 | class F2 { |
| 147 | typename F1<T>:: /*template*/ Iterator<0> Mypos; // expected-error {{use 'template' keyword to treat 'Iterator' as a dependent template name}} |
| 148 | }; |
| 149 | |
| 150 | template <class T> |
| 151 | void f(){ |
| 152 | typename F1<T>:: /*template*/ Iterator<0> Mypos; // expected-error {{use 'template' keyword to treat 'Iterator' as a dependent template name}} |
| 153 | } |
| 154 | |
Anna Zaks | 3b40271 | 2011-07-28 19:51:27 +0000 | [diff] [blame] | 155 | // Tests for &/* fixits radar 7113438. |
| 156 | class AD {}; |
| 157 | class BD: public AD {}; |
| 158 | |
| 159 | void test (BD &br) { |
| 160 | AD* aPtr; |
| 161 | BD b; |
| 162 | aPtr = b; // expected-error {{assigning to 'AD *' from incompatible type 'BD'; take the address with &}} |
Richard Smith | 4e9ea71 | 2011-10-20 01:41:28 +0000 | [diff] [blame] | 163 | aPtr = br; // expected-error {{assigning to 'AD *' from incompatible type 'BD'; take the address with &}} |
Anna Zaks | 3b40271 | 2011-07-28 19:51:27 +0000 | [diff] [blame] | 164 | } |
| 165 | |
Richard Smith | 63168c7 | 2012-02-10 11:05:11 +0000 | [diff] [blame] | 166 | void foo1() const {} // expected-error {{non-member function cannot have 'const' qualifier}} |
| 167 | void foo2() volatile {} // expected-error {{non-member function cannot have 'volatile' qualifier}} |
| 168 | void foo3() const volatile {} // expected-error {{non-member function cannot have 'const volatile' qualifier}} |
Francois Pichet | 4e7a2c0 | 2011-03-27 19:41:34 +0000 | [diff] [blame] | 169 | |
Richard Smith | 09f76ee | 2011-10-19 21:33:05 +0000 | [diff] [blame] | 170 | struct S { void f(int, char); }; |
| 171 | int itsAComma, |
| 172 | itsAComma2 = 0, |
Richard Smith | 4e9ea71 | 2011-10-20 01:41:28 +0000 | [diff] [blame] | 173 | oopsAComma(42), // expected-error {{expected ';' at end of declaration}} |
Richard Smith | 09f76ee | 2011-10-19 21:33:05 +0000 | [diff] [blame] | 174 | AD oopsMoreCommas() { |
Richard Smith | 4e9ea71 | 2011-10-20 01:41:28 +0000 | [diff] [blame] | 175 | static int n = 0, // expected-error {{expected ';' at end of declaration}} |
Richard Smith | 09f76ee | 2011-10-19 21:33:05 +0000 | [diff] [blame] | 176 | static char c, |
Richard Smith | 4e9ea71 | 2011-10-20 01:41:28 +0000 | [diff] [blame] | 177 | &d = c, // expected-error {{expected ';' at end of declaration}} |
| 178 | S s, // expected-error {{expected ';' at end of declaration}} |
Richard Smith | 09f76ee | 2011-10-19 21:33:05 +0000 | [diff] [blame] | 179 | s.f(n, d); |
Richard Smith | 4e9ea71 | 2011-10-20 01:41:28 +0000 | [diff] [blame] | 180 | AD ad, // expected-error {{expected ';' at end of declaration}} |
Richard Smith | 09f76ee | 2011-10-19 21:33:05 +0000 | [diff] [blame] | 181 | return ad; |
| 182 | } |
Richard Smith | c8a7903 | 2012-01-09 22:31:44 +0000 | [diff] [blame] | 183 | struct MoreAccidentalCommas { |
| 184 | int a : 5, |
| 185 | b : 7, |
| 186 | : 4, // expected-error {{expected ';' at end of declaration}} |
| 187 | char c, // expected-error {{expected ';' at end of declaration}} |
| 188 | double d, // expected-error {{expected ';' at end of declaration}} |
| 189 | MoreAccidentalCommas *next, // expected-error {{expected ';' at end of declaration}} |
| 190 | public: |
| 191 | int k, // expected-error {{expected ';' at end of declaration}} |
| 192 | friend void f(MoreAccidentalCommas) {} |
| 193 | int k2, // expected-error {{expected ';' at end of declaration}} |
| 194 | virtual void g(), // expected-error {{expected ';' at end of declaration}} |
| 195 | }; |
Richard Smith | 675ea99 | 2011-11-29 05:27:40 +0000 | [diff] [blame] | 196 | |
Richard Smith | 5371160 | 2011-11-29 09:09:06 +0000 | [diff] [blame] | 197 | template<class T> struct Mystery; |
| 198 | template<class T> typedef Mystery<T>::type getMysteriousThing() { // \ |
| 199 | expected-error {{function definition declared 'typedef'}} \ |
| 200 | expected-error {{missing 'typename' prior to dependent}} |
| 201 | return Mystery<T>::get(); |
| 202 | } |
David Blaikie | f221e51 | 2012-04-02 19:15:28 +0000 | [diff] [blame] | 203 | |
David Blaikie | 3697983 | 2012-04-06 06:28:32 +0000 | [diff] [blame] | 204 | template<template<typename> Foo, // expected-error {{template template parameter requires 'class' after the parameter list}} |
| 205 | template<typename> typename Bar, // expected-error {{template template parameter requires 'class' after the parameter list}} |
| 206 | template<typename> struct Baz> // expected-error {{template template parameter requires 'class' after the parameter list}} |
David Blaikie | f221e51 | 2012-04-02 19:15:28 +0000 | [diff] [blame] | 207 | void func(); |
Kaelyn Uhrain | b3967d7 | 2012-04-19 23:17:45 +0000 | [diff] [blame] | 208 | |
Kaelyn Uhrain | b3967d7 | 2012-04-19 23:17:45 +0000 | [diff] [blame] | 209 | namespace ShadowedTagType { |
| 210 | class Foo { |
| 211 | public: |
| 212 | enum Bar { X, Y }; |
| 213 | void SetBar(Bar bar); |
Kaelyn Uhrain | 3fe3f85 | 2012-04-27 18:26:49 +0000 | [diff] [blame] | 214 | Bar Bar(); // expected-note 2 {{enum 'Bar' is hidden by a non-type declaration of 'Bar' here}} |
Kaelyn Uhrain | b3967d7 | 2012-04-19 23:17:45 +0000 | [diff] [blame] | 215 | private: |
| 216 | Bar bar_; // expected-error {{must use 'enum' tag to refer to type 'Bar' in this scope}} |
| 217 | }; |
| 218 | void Foo::SetBar(Bar bar) { bar_ = bar; } // expected-error {{must use 'enum' tag to refer to type 'Bar' in this scope}} |
Kaelyn Uhrain | d783617 | 2012-04-19 23:26:12 +0000 | [diff] [blame] | 219 | } |
Kaelyn Uhrain | 76e0734 | 2012-04-25 19:49:54 +0000 | [diff] [blame] | 220 | |
David Blaikie | 7665a62 | 2012-04-30 18:27:22 +0000 | [diff] [blame] | 221 | #define NULL __null |
| 222 | char c = NULL; // expected-warning {{implicit conversion of NULL constant to 'char'}} |
David Blaikie | 9366d2b | 2012-06-19 21:19:06 +0000 | [diff] [blame] | 223 | double dbl = NULL; // expected-warning {{implicit conversion of NULL constant to 'double'}} |
David Blaikie | 7665a62 | 2012-04-30 18:27:22 +0000 | [diff] [blame] | 224 | |
Kaelyn Uhrain | 76e0734 | 2012-04-25 19:49:54 +0000 | [diff] [blame] | 225 | namespace arrow_suggest { |
| 226 | |
| 227 | template <typename T> |
| 228 | class wrapped_ptr { |
| 229 | public: |
| 230 | wrapped_ptr(T* ptr) : ptr_(ptr) {} |
| 231 | T* operator->() { return ptr_; } |
| 232 | private: |
| 233 | T *ptr_; |
| 234 | }; |
| 235 | |
| 236 | class Worker { |
| 237 | public: |
| 238 | void DoSomething(); |
| 239 | }; |
| 240 | |
| 241 | void test() { |
| 242 | wrapped_ptr<Worker> worker(new Worker); |
| 243 | worker.DoSomething(); // expected-error {{no member named 'DoSomething' in 'arrow_suggest::wrapped_ptr<arrow_suggest::Worker>'; did you mean to use '->' instead of '.'?}} |
| 244 | } |
| 245 | |
| 246 | } // namespace arrow_suggest |
Kaelyn Uhrain | 1dac08d | 2012-06-07 23:57:12 +0000 | [diff] [blame] | 247 | |
| 248 | // Make sure fixing namespace-qualified identifiers functions properly with |
| 249 | // namespace-aware typo correction/ |
| 250 | namespace redecl_typo { |
| 251 | namespace Foo { |
| 252 | void BeEvil(); // expected-note {{'BeEvil' declared here}} |
| 253 | } |
| 254 | namespace Bar { |
| 255 | namespace Foo { |
| 256 | bool isGood(); // expected-note {{'Bar::Foo::isGood' declared here}} |
| 257 | void beEvil(); |
| 258 | } |
| 259 | } |
| 260 | bool Foo::isGood() { // expected-error {{out-of-line definition of 'isGood' does not match any declaration in namespace 'redecl_typo::Foo'; did you mean 'Bar::Foo::isGood'?}} |
| 261 | return true; |
| 262 | } |
| 263 | void Foo::beEvil() {} // expected-error {{out-of-line definition of 'beEvil' does not match any declaration in namespace 'redecl_typo::Foo'; did you mean 'BeEvil'?}} |
| 264 | } |
Richard Smith | 7b3f322 | 2012-06-18 06:11:04 +0000 | [diff] [blame] | 265 | |
| 266 | // Test behavior when a template-id is ended by a token which starts with '>'. |
| 267 | namespace greatergreater { |
| 268 | template<typename T> struct S { S(); S(T); }; |
| 269 | void f(S<int>=0); // expected-error {{a space is required between a right angle bracket and an equals sign (use '> =')}} |
| 270 | |
| 271 | // FIXME: The fix-its here overlap so -fixit mode can't apply the second one. |
| 272 | //void f(S<S<int>>=S<int>()); |
| 273 | |
| 274 | struct Shr { |
| 275 | template<typename T> Shr(T); |
| 276 | template<typename T> void operator >>=(T); |
| 277 | }; |
| 278 | |
| 279 | template<template<typename>> struct TemplateTemplateParam; // expected-error {{requires 'class'}} |
| 280 | |
| 281 | template<typename T> void t(); |
| 282 | void g() { |
| 283 | void (*p)() = &t<int>; |
| 284 | (void)(&t<int>==p); // expected-error {{use '> ='}} |
| 285 | (void)(&t<int>>=p); // expected-error {{use '> >'}} |
| 286 | (void)(&t<S<int>>>=p); // expected-error {{use '> >'}} |
| 287 | (Shr)&t<S<int>>>>=p; // expected-error {{use '> >'}} |
| 288 | |
| 289 | // FIXME: We correct this to '&t<int> > >= p;' not '&t<int> >>= p;' |
| 290 | //(Shr)&t<int>>>=p; |
| 291 | |
| 292 | // FIXME: The fix-its here overlap. |
| 293 | //(void)(&t<S<int>>==p); |
| 294 | } |
| 295 | } |
David Blaikie | c2ff8e1 | 2012-10-11 22:55:07 +0000 | [diff] [blame] | 296 | |
| 297 | class foo { |
| 298 | static void test() { |
| 299 | (void)&i; // expected-error{{must explicitly qualify name of member function when taking its address}} |
| 300 | } |
| 301 | int i(); |
| 302 | }; |
David Blaikie | 5e026f5 | 2013-03-20 17:42:13 +0000 | [diff] [blame] | 303 | |
| 304 | namespace dtor_fixit { |
| 305 | class foo { |
| 306 | ~bar() { } // expected-error {{expected the class name after '~' to name a destructor}} |
| 307 | // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:6-[[@LINE-1]]:9}:"foo" |
| 308 | }; |
| 309 | } |
Richard Smith | 9ce302e | 2013-07-11 05:10:21 +0000 | [diff] [blame^] | 310 | |
| 311 | namespace PR5066 { |
| 312 | template<typename T> struct X {}; |
| 313 | X<int *p> x; // expected-error {{type-id cannot have a name}} |
| 314 | } |