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/Parser.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/Parser.cpp')
-rw-r--r-- | lib/Parse/Parser.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index 17eca37ef3..8903da29a0 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -851,22 +851,22 @@ bool Parser::TryAnnotateTypeOrScopeToken() { return false; } - if (AnnotateTemplateIdTokenAsType(0)) - return false; - + AnnotateTemplateIdTokenAsType(0); assert(Tok.is(tok::annot_typename) && "AnnotateTemplateIdTokenAsType isn't working properly"); - Ty = Actions.ActOnTypenameType(TypenameLoc, SS, SourceLocation(), - Tok.getAnnotationValue()); + if (Tok.getAnnotationValue()) + Ty = Actions.ActOnTypenameType(TypenameLoc, SS, SourceLocation(), + Tok.getAnnotationValue()); + else + Ty = true; } else { Diag(Tok, diag::err_expected_type_name_after_typename) << SS.getRange(); return false; } - // FIXME: better error recovery! Tok.setKind(tok::annot_typename); - Tok.setAnnotationValue(Ty.get()); + Tok.setAnnotationValue(Ty.isInvalid()? 0 : Ty.get()); Tok.setAnnotationEndLoc(Tok.getLocation()); Tok.setLocation(TypenameLoc); PP.AnnotateCachedTokens(Tok); @@ -925,7 +925,8 @@ bool Parser::TryAnnotateTypeOrScopeToken() { // template-id annotation in a context where we weren't allowed // to produce a type annotation token. Update the template-id // annotation token to a type annotation token now. - return !AnnotateTemplateIdTokenAsType(&SS); + AnnotateTemplateIdTokenAsType(&SS); + return true; } } |