diff options
author | John McCall <rjmccall@apple.com> | 2010-07-30 06:26:29 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-07-30 06:26:29 +0000 |
commit | 207014eb2b372aa33721e86d90a8a586ba8dc8ae (patch) | |
tree | 4b927c519af3af593ad65ec58ba61855c618d75e /lib/Parse/ParseDeclCXX.cpp | |
parent | 27940d2fb346325d6001a7661e4ada099cd8e59c (diff) |
Improve error recovery when presented with an ill-formed template-id
(e.g. due to a broken template argument) following template parameters.
Fixes rdar://problem/8254267
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109853 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDeclCXX.cpp')
-rw-r--r-- | lib/Parse/ParseDeclCXX.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index e6db331200..7ed07a277c 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -680,7 +680,8 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind, // "FOO : BAR" is not a potential typo for "FOO::BAR". ColonProtectionRAIIObject X(*this); - ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, true); + if (ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, true)) + DS.SetTypeSpecError(); if (SS.isSet()) if (Tok.isNot(tok::identifier) && Tok.isNot(tok::annot_template_id)) Diag(Tok, diag::err_expected_ident); @@ -804,10 +805,13 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind, else TUK = Action::TUK_Reference; - if (!Name && !TemplateId && TUK != Action::TUK_Definition) { - // We have a declaration or reference to an anonymous class. - Diag(StartLoc, diag::err_anon_type_definition) - << DeclSpec::getSpecifierName(TagType); + if (!Name && !TemplateId && (DS.getTypeSpecType() == DeclSpec::TST_error || + TUK != Action::TUK_Definition)) { + if (DS.getTypeSpecType() != DeclSpec::TST_error) { + // We have a declaration or reference to an anonymous class. + Diag(StartLoc, diag::err_anon_type_definition) + << DeclSpec::getSpecifierName(TagType); + } SkipUntil(tok::comma, true); |