From: Douglas Gregor Date: Wed, 4 Nov 2009 18:18:19 +0000 (+0000) Subject: Properly replace (cxxscope, template-id) annotation tokens with a X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=862354188764f4a20be21d103bc2abd074ad048a;p=clang Properly replace (cxxscope, template-id) annotation tokens with a single typename annotation token when backtracing. Fixes PR5350. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86034 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParseTemplate.cpp b/lib/Parse/ParseTemplate.cpp index 045acd86ad..99578837c2 100644 --- a/lib/Parse/ParseTemplate.cpp +++ b/lib/Parse/ParseTemplate.cpp @@ -809,12 +809,11 @@ void Parser::AnnotateTemplateIdTokenAsType(const CXXScopeSpec *SS) { Tok.setAnnotationValue(Type.isInvalid()? 0 : Type.get()); if (SS && SS->isNotEmpty()) // it was a C++ qualified type name. Tok.setLocation(SS->getBeginLoc()); + Tok.setAnnotationEndLoc(TemplateId->TemplateNameLoc); - // We might be backtracking, in which case we need to replace the - // template-id annotation token with the type annotation within the - // set of cached tokens. That way, we won't try to form the same - // class template specialization again. - PP.ReplaceLastTokenWithAnnotation(Tok); + // Replace the template-id annotation token, and possible the scope-specifier + // that precedes it, with the typename annotation token. + PP.AnnotateCachedTokens(Tok); TemplateId->Destroy(); } diff --git a/test/SemaTemplate/temp_arg_nontype.cpp b/test/SemaTemplate/temp_arg_nontype.cpp index 534030dba0..814801ccff 100644 --- a/test/SemaTemplate/temp_arg_nontype.cpp +++ b/test/SemaTemplate/temp_arg_nontype.cpp @@ -122,3 +122,17 @@ extern FuncPtr0<&func0> *fp0; int func0(int, int); extern FuncPtr0<&func0> *fp0; +// PR5350 +namespace ns { + template + struct Foo { + static const bool value = true; + }; + + template + struct Bar {}; + + const bool value = false; + + Bar::value)> x; +}