diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-04-01 21:51:26 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-04-01 21:51:26 +0000 |
commit | 31a19b6989bbf326d2de5ae12e712e2a65ca9c34 (patch) | |
tree | e79ad32f23a5f590558c274cf11b000f10b04042 /lib/Parse/ParseDecl.cpp | |
parent | faa435a326a694e0517d035376e616ff82655fe5 (diff) |
Make parsing a semantic analysis a little more robust following Sema
failures that involve malformed types, e.g., "typename X::foo" where
"foo" isn't a type, or "std::vector<void>" that doens't instantiate
properly.
Similarly, be a bit smarter in our handling of ambiguities that occur
in Sema::getTypeName, to eliminate duplicate error messages about
ambiguous name lookup.
This eliminates two XFAILs in test/SemaCXX, one of which was crying
out to us, trying to tell us that we were producing repeated error
messages.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68251 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDecl.cpp')
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 11658d4c50..e233a22162 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -558,8 +558,11 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, } case tok::annot_typename: { - isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec, - Tok.getAnnotationValue()); + if (Tok.getAnnotationValue()) + isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec, + Tok.getAnnotationValue()); + else + DS.SetTypeSpecError(); DS.SetRangeEnd(Tok.getAnnotationEndLoc()); ConsumeToken(); // The typename @@ -648,9 +651,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, // Turn the template-id annotation token into a type annotation // token, then try again to parse it as a type-specifier. - if (AnnotateTemplateIdTokenAsType()) - DS.SetTypeSpecError(); - + AnnotateTemplateIdTokenAsType(); continue; } @@ -915,8 +916,11 @@ bool Parser::ParseOptionalTypeSpecifier(DeclSpec &DS, int& isInvalid, // simple-type-specifier: case tok::annot_typename: { - isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec, - Tok.getAnnotationValue()); + if (Tok.getAnnotationValue()) + isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec, + Tok.getAnnotationValue()); + else + DS.SetTypeSpecError(); DS.SetRangeEnd(Tok.getAnnotationEndLoc()); ConsumeToken(); // The typename @@ -1893,11 +1897,11 @@ void Parser::ParseDirectDeclarator(Declarator &D) { // FIXME: Inaccurate. SourceLocation NameLoc = Tok.getLocation(); SourceLocation EndLoc; - if (TypeTy *Type = ParseClassName(EndLoc)) { - D.setDestructor(Type, TildeLoc, NameLoc); - } else { + TypeResult Type = ParseClassName(EndLoc); + if (Type.isInvalid()) D.SetIdentifier(0, TildeLoc); - } + else + D.setDestructor(Type.get(), TildeLoc, NameLoc); } else { Diag(Tok, diag::err_expected_class_name); D.SetIdentifier(0, TildeLoc); |