diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-11-19 22:47:36 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-11-19 22:47:36 +0000 |
commit | fc764b6d50aba62a6dbf736a763197e0805d83ed (patch) | |
tree | b2a8ed3c29ffd900aa68a567b97eb591eabc8185 /test/Parser | |
parent | d46c8e0d67c7a20b5da330af3a36c47a5f0c0484 (diff) | |
download | clang-fc764b6d50aba62a6dbf736a763197e0805d83ed.tar.gz |
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
Diffstat (limited to 'test/Parser')
-rw-r--r-- | test/Parser/cxx-decl.cpp | 4 | ||||
-rw-r--r-- | test/Parser/recovery.cpp | 53 |
2 files changed, 55 insertions, 2 deletions
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 T> class Class1; class Class2 { -} // no ; +} // expected-error {{expected ';' after class}} -typedef Class1<Class2> Type1; // expected-error {{cannot combine with previous 'class' declaration specifier}} +typedef Class1<Class2> 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<typename T> struct MissingSemiT { +} // expected-error {{expected ';' after struct}} +MissingSemiT<int> 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; +} |