1 // RUN: %clang_cc1 -verify -std=c++11 -fms-extensions %s
3 8gi
///===--- recovery.cpp ---===// // expected-error {{unqualified-id}}
4 namespace Std
{ // expected-note {{here}}
8 / redeclare as an
inline namespace // expected-error {{unqualified-id}}
9 inline namespace Std
{ // expected-error {{cannot be reopened as inline}}
11 } / end
namespace Std
// expected-error {{unqualified-id}}
15 extenr
"C" { // expected-error {{did you mean 'extern'}}
19 z
= 1; // expected-error {{undeclared}}
26 int x
// expected-error {{expected ';'}}
29 8S::S() : a
{ 5 }, b
{ 6 }, c
{ 2 } { // expected-error {{unqualified-id}}
33 int l
= k
// expected-error {{expected ';'}}
36 5int m
= { l
}, n
= m
; // expected-error {{unqualified-id}}
38 namespace MissingBrace
{
39 struct S
{ // expected-error {{missing '}' at end of definition of 'MissingBrace::S'}}
43 namespace N
{ int g(); } // expected-note {{still within definition of 'MissingBrace::S' here}}
45 int k1
= S().h(); // expected-error {{no member named 'h' in 'MissingBrace::S'}}
46 int k2
= S().f() + N::g();
48 template<typename T
> struct PR17949
{ // expected-error {{missing '}' at end of definition of 'MissingBrace::PR17949'}}
50 namespace X
{ // expected-note {{still within definition of 'MissingBrace::PR17949' here}}
56 } // expected-error {{unqualified-id}}
58 strcut Uuuu
{ // expected-error {{did you mean 'struct'}} \
59 // expected-note {{'Uuuu' declared here}}
61 uuuu v
; // expected-error {{did you mean 'Uuuu'}}
63 struct Redefined
{ // expected-note {{previous}}
66 struct Redefined
{ // expected-error {{redefinition}}
72 typedef int afterMissingSemi4
;
73 extern MissingSemi5 afterMissingSemi5
;
76 struct MissingSemi1
{} // expected-error {{expected ';' after struct}}
77 static int afterMissingSemi1();
79 class MissingSemi2
{} // expected-error {{expected ';' after class}}
80 MissingSemi1
*afterMissingSemi2
;
82 enum MissingSemi3
{} // expected-error {{expected ';' after enum}}
83 ::MissingSemi1 afterMissingSemi3
;
85 extern N::afterMissingSemi4 afterMissingSemi4b
;
86 union MissingSemi4
{ MissingSemi4(int); } // expected-error {{expected ';' after union}}
87 N::afterMissingSemi4 (afterMissingSemi4b
);
89 int afterMissingSemi5b
;
90 struct MissingSemi5
{ MissingSemi5(int); } // ok, no missing ';' here
91 N::afterMissingSemi5 (afterMissingSemi5b
);
93 template<typename T
> struct MissingSemiT
{
94 } // expected-error {{expected ';' after struct}}
95 MissingSemiT
<int> msi
;
97 struct MissingSemiInStruct
{
98 struct Inner1
{} // expected-error {{expected ';' after struct}}
99 static MissingSemi5 ms1
;
101 struct Inner2
{} // ok, no missing ';' here
104 struct Inner3
{} // expected-error {{expected ';' after struct}}
105 static MissingSemi5
*p
;
108 void MissingSemiInFunction() {
109 struct Inner1
{} // expected-error {{expected ';' after struct}}
112 // FIXME: It would be nice to at least warn on this.
113 struct Inner2
{ Inner2(int); } // ok, no missing ';' here
116 struct Inner3
{} // expected-error {{expected ';' after struct}}
119 struct Inner4
{} // ok, no missing ';' here
124 template<typename T
> struct Foo
{};
126 struct MissingSemiThenTemplate1
{} // expected-error {{expected ';' after struct}}
127 NS::Foo
<int> missingSemiBeforeFunctionReturningTemplateId1();
130 struct MissingSemiThenTemplate2
{} // expected-error {{expected ';' after struct}}
131 Foo
<int> missingSemiBeforeFunctionReturningTemplateId2();
134 enum class EnumID
{};
135 template <typename
> struct TempID
;
136 template <> struct TempID
<BadType
> // expected-error{{use of undeclared identifier 'BadType'}}
137 : BadType
, // expected-error {{expected class name}}
138 EnumID::Garbage
// expected-error {{expected class name}}
139 ; // expected-error@-1 {{expected '{' after base class list}}
144 const int V1
= 1; // expected-note {{declared here}}
147 enum E1
{ V2
= 2 }; // expected-note {{declared here}}
148 static const int V3
= 3; // expected-note {{declared here}}
151 V4
= 4, // expected-note {{declared here}}
152 V6
// expected-note {{declared here}}
154 enum class EC3
{ V0
= 0, V5
= 5 }; // expected-note {{declared here}}
160 case ns::V1:: break; // expected-error{{'V1' cannot appear before '::' because it is not a class, namespace, or enumeration; did you mean ':'?}}
161 case C1::V2:: break; // expected-error{{'V2' cannot appear before '::' because it is not a class, namespace, or enumeration; did you mean ':'?}}
162 case C1::V3:: break; // expected-error{{'V3' cannot appear before '::' because it is not a class, namespace, or enumeration; did you mean ':'?}}
163 case V4:: break; // expected-error{{'V4' cannot appear before '::' because it is not a class, namespace, or enumeration; did you mean ':'?}}
164 case V6:: func_3(); // expected-error{{'V6' cannot appear before '::' because it is not a class, namespace, or enumeration; did you mean ':'?}}
170 case EC3::V5:: break; // expected-error{{'V5' cannot appear before '::' because it is not a class, namespace, or enumeration; did you mean ':'?}}
174 template<class T
> struct TS1
{
177 template<class T
> void func(int x
) {
179 case TS1
<T
>::A:: break; // expected-error{{expected unqualified-id}}
187 static int n
; // expected-note{{declared here}}
188 int nn
; // expected-note 2 {{declared here}}
192 return x
? S::n :: 0; // expected-error{{'n' cannot appear before '::' because it is not a class, namespace, or enumeration; did you mean ':'?}}
194 int func_4(int x
, S
&s
) {
195 return x
? s
.nn :: x
; // expected-error{{'nn' cannot appear before '::' because it is not a class, namespace, or enumeration; did you mean ':'?}}
197 int func_5(int x
, S
&s
) {
198 return x
? s
.nn :: S::n
; // expected-error{{'nn' cannot appear before '::' because it is not a class, namespace, or enumeration; did you mean ':'?}}
205 struct S2 :: S3 :: public S2
{ // expected-error{{'public' cannot be a part of nested name specifier; did you mean ':'?}}
209 namespace InvalidEmptyNames
{
210 // These shouldn't crash, the diagnostics aren't important.
211 struct ::, struct ::; // expected-error 2 {{expected identifier}} expected-error 2 {{declaration of anonymous struct must be a definition}} expected-warning {{declaration does not declare anything}}
212 enum ::, enum ::; // expected-error 2 {{expected identifier}} expected-warning {{declaration does not declare anything}}
213 struct ::__super
, struct ::__super
; // expected-error 2 {{expected identifier}} expected-error 2 {{expected '::' after '__super'}}
214 struct ::template foo
, struct ::template bar
; // expected-error 2 {{expected identifier}} expected-error 2 {{declaration of anonymous struct must be a definition}} expected-warning {{declaration does not declare anything}}
215 struct ::foo
struct::; // expected-error {{no struct named 'foo' in the global namespace}} expected-error {{expected identifier}} expected-error {{declaration of anonymous struct must be a definition}}
216 class :: : {} a
; // expected-error {{expected identifier}} expected-error {{expected class name}}