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