]> granicus.if.org Git - clang/commitdiff
Properly replace (cxxscope, template-id) annotation tokens with a
authorDouglas Gregor <dgregor@apple.com>
Wed, 4 Nov 2009 18:18:19 +0000 (18:18 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 4 Nov 2009 18:18:19 +0000 (18:18 +0000)
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

lib/Parse/ParseTemplate.cpp
test/SemaTemplate/temp_arg_nontype.cpp

index 045acd86ad0f2d46cf93f92044f90b9880c96714..99578837c21c15af1ab4ef37a5bc48c0ced72f69 100644 (file)
@@ -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();
 }
 
index 534030dba0ea26f72ff39fdd4f5339c6541d94d6..814801ccff99777e3e9b30af871716089285a7c4 100644 (file)
@@ -122,3 +122,17 @@ extern FuncPtr0<&func0> *fp0;
 int func0(int, int);
 extern FuncPtr0<&func0> *fp0;
 
+// PR5350
+namespace ns {
+  template <typename T>
+  struct Foo {
+    static const bool value = true;
+  };
+  
+  template <bool b>
+  struct Bar {};
+  
+  const bool value = false;
+  
+  Bar<bool(ns::Foo<int>::value)> x;
+}