fixit.cpp revision 4147d307086cf024a40a080e2bf379e9725f6f41
1// RUN: cp %s %t 2// RUN: %clang_cc1 -pedantic -Wall -fixit -x c++ %t || true 3// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -x c++ %t 4 5/* This is a test of the various code modification hints that are 6 provided as part of warning or extension diagnostics. All of the 7 warnings will be fixed by -fixit, and the resulting file should 8 compile cleanly with -Werror -pedantic. */ 9 10struct C1 { 11 virtual void f(); 12 static void g(); 13}; 14struct C2 : virtual public virtual C1 { }; // expected-error{{duplicate}} 15 16virtual void C1::f() { } // expected-error{{'virtual' can only be specified inside the class definition}} 17 18static void C1::g() { } // expected-error{{'static' can only be specified inside the class definition}} 19 20template<int Value> struct CT { }; // expected-note{{previous use is here}} 21 22CT<10 >> 2> ct; // expected-warning{{require parentheses}} 23 24class C3 { 25public: 26 C3(C3, int i = 0); // expected-error{{copy constructor must pass its first argument by reference}} 27}; 28 29struct CT<0> { }; // expected-error{{'template<>'}} 30 31template<> class CT<1> { }; // expected-error{{tag type}} 32 33// Access declarations 34class A { 35protected: 36 int foo(); 37}; 38 39class B : public A { 40 A::foo; // expected-warning{{access declarations are deprecated}} 41}; 42 43void f() throw(); 44void f(); // expected-warning{{missing exception specification}} 45 46namespace rdar7853795 { 47 struct A { 48 bool getNumComponents() const; // expected-note{{declared here}} 49 void dump() const { 50 getNumComponenets(); // expected-error{{use of undeclared identifier 'getNumComponenets'; did you mean 'getNumComponents'?}} 51 } 52 }; 53} 54 55namespace rdar7796492 { 56 class A { int x, y; A(); }; 57 58 A::A() 59 : x(1) y(2) { // expected-error{{missing ',' between base or member initializers}} 60 } 61 62} 63 64// extra qualification on member 65class C { 66 int C::foo(); 67}; 68 69namespace rdar8488464 { 70int x == 0; // expected-error {{invalid '==' at end of declaration; did you mean '='?}} 71 72void f() { 73 int x == 0; // expected-error {{invalid '==' at end of declaration; did you mean '='?}} 74 (void)x; 75 if (int x == 0) { // expected-error {{invalid '==' at end of declaration; did you mean '='?}} 76 (void)x; 77 } 78} 79} 80 81template <class A> 82class F1 { 83public: 84 template <int B> 85 class Iterator { 86 }; 87}; 88 89template<class T> 90class F2 { 91 typename F1<T>:: /*template*/ Iterator<0> Mypos; // expected-error {{use 'template' keyword to treat 'Iterator' as a dependent template name}} 92}; 93 94template <class T> 95void f(){ 96 typename F1<T>:: /*template*/ Iterator<0> Mypos; // expected-error {{use 'template' keyword to treat 'Iterator' as a dependent template name}} 97} 98 99 100