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 | 404dfb46a9dde63548d59db3295681a1c3a684fc (patch) | |
tree | a25b849dd6e65cd375970c1a38b83f9db019ed04 /clang/test/Parser/recovery.cpp | |
parent | 8bc4a0ba147f2bc0508313b6c41bb03fd564cd4e (diff) | |
download | bcm5719-llvm-404dfb46a9dde63548d59db3295681a1c3a684fc.tar.gz bcm5719-llvm-404dfb46a9dde63548d59db3295681a1c3a684fc.zip |
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.
llvm-svn: 195163
Diffstat (limited to 'clang/test/Parser/recovery.cpp')
-rw-r--r-- | clang/test/Parser/recovery.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/clang/test/Parser/recovery.cpp b/clang/test/Parser/recovery.cpp index 0000f5c5428..b5b09484ad9 100644 --- a/clang/test/Parser/recovery.cpp +++ b/clang/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; +} |