1 // RUN: %clang_cc1 -verify -std=c++11 %s
2 
3 8gi///===--- recovery.cpp ---===// // expected-error {{unqualified-id}}
4 namespace Std { // expected-note {{here}}
5   typedef int Important;
6 }
7 
8 / redeclare as an inline namespace // expected-error {{unqualified-id}}
9 inline namespace Std { // expected-error {{cannot be reopened as inline}}
10   Important n;
11 } / end namespace Std // expected-error {{unqualified-id}}
12 int x;
13 Std::Important y;
14 
15 extenr "C" { // expected-error {{did you mean 'extern'}}
16   void f();
17 }
18 void g() {
19   z = 1; // expected-error {{undeclared}}
20   f();
21 }
22 
23 struct S {
24   int a, b, c;
25   S();
26   int x // expected-error {{expected ';'}}
27   friend void f()
28 };
29 8S::S() : a{ 5 }, b{ 6 }, c{ 2 } { // expected-error {{unqualified-id}}
30   return;
31 }
32 int k;
33 int l = k // expected-error {{expected ';'}}
34 constexpr int foo();
35 
36 5int m = { l }, n = m; // expected-error {{unqualified-id}}
37 
38 namespace MissingBrace {
39   struct S { // expected-error {{missing '}' at end of definition of 'MissingBrace::S'}}
40     int f();
41   // };
42 
43   namespace N { int g(); } // expected-note {{still within definition of 'MissingBrace::S' here}}
44 
45   int k1 = S().h(); // expected-error {{no member named 'h' in 'MissingBrace::S'}}
46   int k2 = S().f() + N::g();
47 
48   template<typename T> struct PR17949 { // expected-error {{missing '}' at end of definition of 'MissingBrace::PR17949'}}
49 
50   namespace X { // expected-note {{still within definition of 'MissingBrace::PR17949' here}}
51   }
52 }
53 
54 namespace N {
55   int
56 } // expected-error {{unqualified-id}}
57 
58 strcut Uuuu { // expected-error {{did you mean 'struct'}} \
59               // expected-note {{'Uuuu' declared here}}
60 } *u[3];
61 uuuu v; // expected-error {{did you mean 'Uuuu'}}
62 
63 struct Redefined { // expected-note {{previous}}
64   Redefined() {}
65 };
66 struct Redefined { // expected-error {{redefinition}}
67   Redefined() {}
68 };
69 
70 struct MissingSemi5;
71 namespace N {
72   typedef int afterMissingSemi4;
73   extern MissingSemi5 afterMissingSemi5;
74 }
75 
76 struct MissingSemi1 {} // expected-error {{expected ';' after struct}}
77 static int afterMissingSemi1();
78 
79 class MissingSemi2 {} // expected-error {{expected ';' after class}}
80 MissingSemi1 *afterMissingSemi2;
81 
82 enum MissingSemi3 {} // expected-error {{expected ';' after enum}}
83 ::MissingSemi1 afterMissingSemi3;
84 
85 extern N::afterMissingSemi4 afterMissingSemi4b;
86 union MissingSemi4 { MissingSemi4(int); } // expected-error {{expected ';' after union}}
87 N::afterMissingSemi4 (afterMissingSemi4b);
88 
89 int afterMissingSemi5b;
90 struct MissingSemi5 { MissingSemi5(int); } // ok, no missing ';' here
91 N::afterMissingSemi5 (afterMissingSemi5b);
92 
93 template<typename T> struct MissingSemiT {
94 } // expected-error {{expected ';' after struct}}
95 MissingSemiT<int> msi;
96 
97 struct MissingSemiInStruct {
98   struct Inner1 {} // expected-error {{expected ';' after struct}}
99   static MissingSemi5 ms1;
100 
101   struct Inner2 {} // ok, no missing ';' here
102   static MissingSemi1;
103 
104   struct Inner3 {} // expected-error {{expected ';' after struct}}
105   static MissingSemi5 *p;
106 };
107 
108 void MissingSemiInFunction() {
109   struct Inner1 {} // expected-error {{expected ';' after struct}}
110   if (true) {}
111 
112   // FIXME: It would be nice to at least warn on this.
113   struct Inner2 { Inner2(int); } // ok, no missing ';' here
114   k = l;
115 
116   struct Inner3 {} // expected-error {{expected ';' after struct}}
117   Inner1 i1;
118 
119   struct Inner4 {} // ok, no missing ';' here
120   Inner5;
121 }
122