From fc764b6d50aba62a6dbf736a763197e0805d83ed Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 19 Nov 2013 22:47:36 +0000 Subject: PR9547: If we're parsing a simple-declaration that contains a tag definition, and we see an ill-formed declarator that would probably be well-formed if the tag definition were just missing a semicolon, use that as the diagnostic instead of producing some other mysterious error. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195163 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Parser/cxx-decl.cpp | 4 ++-- test/Parser/recovery.cpp | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 2 deletions(-) (limited to 'test/Parser') diff --git a/test/Parser/cxx-decl.cpp b/test/Parser/cxx-decl.cpp index 06272504bc..8c4c6175f5 100644 --- a/test/Parser/cxx-decl.cpp +++ b/test/Parser/cxx-decl.cpp @@ -108,9 +108,9 @@ template class Class1; class Class2 { -} // no ; +} // expected-error {{expected ';' after class}} -typedef Class1 Type1; // expected-error {{cannot combine with previous 'class' declaration specifier}} +typedef Class1 Type1; // rdar : // 8307865 struct CodeCompleteConsumer { diff --git a/test/Parser/recovery.cpp b/test/Parser/recovery.cpp index 0000f5c542..b5b09484ad 100644 --- a/test/Parser/recovery.cpp +++ b/test/Parser/recovery.cpp @@ -66,3 +66,56 @@ struct Redefined { // expected-note {{previous}} struct Redefined { // expected-error {{redefinition}} Redefined() {} }; + +struct MissingSemi5; +namespace N { + typedef int afterMissingSemi4; + extern MissingSemi5 afterMissingSemi5; +} + +struct MissingSemi1 {} // expected-error {{expected ';' after struct}} +static int afterMissingSemi1(); + +class MissingSemi2 {} // expected-error {{expected ';' after class}} +MissingSemi1 *afterMissingSemi2; + +enum MissingSemi3 {} // expected-error {{expected ';' after enum}} +::MissingSemi1 afterMissingSemi3; + +extern N::afterMissingSemi4 afterMissingSemi4b; +union MissingSemi4 { MissingSemi4(int); } // expected-error {{expected ';' after union}} +N::afterMissingSemi4 (afterMissingSemi4b); + +int afterMissingSemi5b; +struct MissingSemi5 { MissingSemi5(int); } // ok, no missing ';' here +N::afterMissingSemi5 (afterMissingSemi5b); + +template struct MissingSemiT { +} // expected-error {{expected ';' after struct}} +MissingSemiT msi; + +struct MissingSemiInStruct { + struct Inner1 {} // expected-error {{expected ';' after struct}} + static MissingSemi5 ms1; + + struct Inner2 {} // ok, no missing ';' here + static MissingSemi1; + + struct Inner3 {} // expected-error {{expected ';' after struct}} + static MissingSemi5 *p; +}; + +void MissingSemiInFunction() { + struct Inner1 {} // expected-error {{expected ';' after struct}} + if (true) {} + + // FIXME: It would be nice to at least warn on this. + struct Inner2 { Inner2(int); } // ok, no missing ';' here + k = l; + + struct Inner3 {} // expected-error {{expected ';' after struct}} + Inner1 i1; + + struct Inner4 {} // ok, no missing ';' here + Inner5; +} -- cgit v1.2.1