1 // RUN: cp %s %t
2 // RUN: not %clang_cc1 -pedantic -Wall -fixit -x c++ %t
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 
10 struct C1 {
11   virtual void f();
12   static void g();
13 };
14 struct C2 : virtual public virtual C1 { }; // expected-error{{duplicate}}
15 
16 virtual void C1::f() { } // expected-error{{'virtual' can only be specified inside the class definition}}
17 
18 static void C1::g() { } // expected-error{{'static' can only be specified inside the class definition}}
19 
20 template<int Value> struct CT { }; // expected-note{{previous use is here}}
21 
22 CT<10 >> 2> ct; // expected-warning{{require parentheses}}
23 
24 class C3 {
25 public:
26   C3(C3, int i = 0); // expected-error{{copy constructor must pass its first argument by reference}}
27 };
28 
29 struct CT<0> { }; // expected-error{{'template<>'}}
30 
31 template<> class CT<1> { }; // expected-error{{tag type}}
32 
33 // Access declarations
34 class A {
35 protected:
36   int foo();
37 };
38 
39 class B : public A {
40   A::foo; // expected-warning{{access declarations are deprecated}}
41 };
42 
43 void f() throw();
44 void f(); // expected-warning{{missing exception specification}}
45 
46 namespace 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 
55 namespace 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
65 class C {
66   int C::foo();
67 };
68 
69 namespace rdar8488464 {
70 int x == 0; // expected-error {{invalid '==' at end of declaration; did you mean '='?}}
71 
72 void 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 
81 template <class A>
82 class F1 {
83 public:
84   template <int B>
85   class Iterator {
86   };
87 };
88 
89 template<class T>
90 class F2  {
91   typename F1<T>:: /*template*/  Iterator<0> Mypos; // expected-error {{use 'template' keyword to treat 'Iterator' as a dependent template name}}
92 };
93 
94 template <class T>
95 void 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 // Tests for &/* fixits radar 7113438.
100 class AD {};
101 class BD: public AD {};
102 
103 void test (BD &br) {
104   AD* aPtr;
105   BD b;
106   aPtr = b; // expected-error {{assigning to 'AD *' from incompatible type 'BD'; take the address with &}}
107   aPtr = br; // expected-error {{assigning to 'A *' from incompatible type 'B'; take the address with &}}
108 }
109 
110 
111