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