[cfe-commits] r86034 - in /cfe/trunk: lib/Parse/ParseTemplate.cpp test/SemaTemplate/temp_arg_nontype.cpp

Douglas Gregor dgregor at apple.com
Wed Nov 4 10:18:19 PST 2009


Author: dgregor
Date: Wed Nov  4 12:18:19 2009
New Revision: 86034

URL: http://llvm.org/viewvc/llvm-project?rev=86034&view=rev
Log:
Properly replace (cxxscope, template-id) annotation tokens with a
single typename annotation token when backtracing. Fixes PR5350.

Modified:
    cfe/trunk/lib/Parse/ParseTemplate.cpp
    cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp

Modified: cfe/trunk/lib/Parse/ParseTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTemplate.cpp?rev=86034&r1=86033&r2=86034&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseTemplate.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp Wed Nov  4 12:18:19 2009
@@ -809,12 +809,11 @@
   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();
 }
 

Modified: cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp?rev=86034&r1=86033&r2=86034&view=diff

==============================================================================
--- cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp (original)
+++ cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp Wed Nov  4 12:18:19 2009
@@ -122,3 +122,17 @@
 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;
+}





More information about the cfe-commits mailing list