From: Sebastian Redl Date: Sun, 24 Apr 2011 16:27:48 +0000 (+0000) Subject: Make the invalid declarator recovery when parsing members work the same as when parsi... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d941fa4ff0d0d64b5a541dbd4f99693bff7f6e8d;p=clang Make the invalid declarator recovery when parsing members work the same as when parsing global decls. It's still rather broken (skipping much too far when the declarator belongs to a function definition), but at least not so broken as to mismatch braces. Tested by the removal of the fixme in the template test case. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130101 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 119bf0f762..f59302868b 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -1551,7 +1551,7 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, // Error parsing the declarator? if (!DeclaratorInfo.hasName()) { // If so, skip until the semi-colon or a }. - SkipUntil(tok::r_brace, true); + SkipUntil(tok::r_brace, true, true); if (Tok.is(tok::semi)) ConsumeToken(); return; diff --git a/test/SemaTemplate/deduction-crash.cpp b/test/SemaTemplate/deduction-crash.cpp index 1860c7577c..8a15605734 100644 --- a/test/SemaTemplate/deduction-crash.cpp +++ b/test/SemaTemplate/deduction-crash.cpp @@ -4,7 +4,7 @@ // Note that the error count below doesn't matter. We just want to // make sure that the parser doesn't crash. -// CHECK: 16 errors +// CHECK: 14 errors template struct int_; diff --git a/test/SemaTemplate/explicit-instantiation.cpp b/test/SemaTemplate/explicit-instantiation.cpp index ffec3c2b97..63016fd715 100644 --- a/test/SemaTemplate/explicit-instantiation.cpp +++ b/test/SemaTemplate/explicit-instantiation.cpp @@ -88,15 +88,12 @@ template struct X3 { }; inline template struct X3; // expected-warning{{ignoring 'inline' keyword on explicit template instantiation}} static template struct X3; // expected-warning{{ignoring 'static' keyword on explicit template instantiation}} -namespace PR7622 { // expected-note{{to match this}} +namespace PR7622 { template struct basic_streambuf; - // FIXME: Very poor recovery here. template struct basic_streambuf{friend bob<>()}; // expected-error{{unknown type name 'bob'}} \ // expected-error{{ expected member name or ';' after declaration specifiers}} - template struct basic_streambuf; // expected-error{{explicit instantiation of 'basic_streambuf' in class scope}} -} // expected-error{{expected ';' after struct}} - -//expected-error{{expected '}'}} + template struct basic_streambuf; +}