From fe3d7d088063cdee3b6fc7eff83da868d289a67b Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 1 Apr 2009 21:51:26 +0000 Subject: 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" 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 --- clang/lib/Parse/ParseTemplate.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'clang/lib/Parse/ParseTemplate.cpp') diff --git a/clang/lib/Parse/ParseTemplate.cpp b/clang/lib/Parse/ParseTemplate.cpp index 45d148e38b0..0f9bcd2219b 100644 --- a/clang/lib/Parse/ParseTemplate.cpp +++ b/clang/lib/Parse/ParseTemplate.cpp @@ -588,8 +588,10 @@ void Parser::AnnotateTemplateIdToken(TemplateTy Template, TemplateNameKind TNK, /// \brief Replaces a template-id annotation token with a type /// annotation token. /// -/// \returns true if there was an error, false otherwise. -bool Parser::AnnotateTemplateIdTokenAsType(const CXXScopeSpec *SS) { +/// If there was a failure when forming the type from the template-id, +/// a type annotation token will still be created, but will have a +/// NULL type pointer to signify an error. +void Parser::AnnotateTemplateIdTokenAsType(const CXXScopeSpec *SS) { assert(Tok.is(tok::annot_template_id) && "Requires template-id tokens"); TemplateIdAnnotation *TemplateId @@ -610,16 +612,9 @@ bool Parser::AnnotateTemplateIdTokenAsType(const CXXScopeSpec *SS) { TemplateArgsPtr, TemplateId->getTemplateArgLocations(), TemplateId->RAngleLoc); - if (Type.isInvalid()) { - // FIXME: better recovery? - ConsumeToken(); - TemplateId->Destroy(); - return true; - } - // Create the new "type" annotation token. Tok.setKind(tok::annot_typename); - Tok.setAnnotationValue(Type.get()); + Tok.setAnnotationValue(Type.isInvalid()? 0 : Type.get()); if (SS && SS->isNotEmpty()) // it was a C++ qualified type name. Tok.setLocation(SS->getBeginLoc()); @@ -629,8 +624,6 @@ bool Parser::AnnotateTemplateIdTokenAsType(const CXXScopeSpec *SS) { // class template specialization again. PP.ReplaceLastTokenWithAnnotation(Tok); TemplateId->Destroy(); - - return false; } /// ParseTemplateArgument - Parse a C++ template argument (C++ [temp.names]). -- cgit v1.2.3