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 | fe3d7d088063cdee3b6fc7eff83da868d289a67b (patch) | |
tree | d60ad76918e7902929b2308417255bb32f440d94 /clang/lib/Parse/Parser.cpp | |
parent | 7182686dbfca9ee66a187e339438f1cf61346856 (diff) | |
download | bcm5719-llvm-fe3d7d088063cdee3b6fc7eff83da868d289a67b.tar.gz bcm5719-llvm-fe3d7d088063cdee3b6fc7eff83da868d289a67b.zip |
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.
llvm-svn: 68251
Diffstat (limited to 'clang/lib/Parse/Parser.cpp')
-rw-r--r-- | clang/lib/Parse/Parser.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index 17eca37ef3c..8903da29a03 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/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; } } |