r189422 - AST: Don't treat a TemplateExpansion as a Template

David Majnemer david.majnemer at gmail.com
Tue Aug 27 17:00:28 PDT 2013


Author: majnemer
Date: Tue Aug 27 19:00:27 2013
New Revision: 189422

URL: http://llvm.org/viewvc/llvm-project?rev=189422&view=rev
Log:
AST: Don't treat a TemplateExpansion as a Template

Summary:
Instead of calling getAsTemplate(), call
getAsTemplateOrTemplatePattern() because it handles the
TemplateExpansion case too.

This fixes PR16997.

Reviewers: doug.gregor, rsmith

Reviewed By: rsmith

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1512

Modified:
    cfe/trunk/lib/AST/TypeLoc.cpp
    cfe/trunk/test/SemaTemplate/temp_arg_template.cpp

Modified: cfe/trunk/lib/AST/TypeLoc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypeLoc.cpp?rev=189422&r1=189421&r2=189422&view=diff
==============================================================================
--- cfe/trunk/lib/AST/TypeLoc.cpp (original)
+++ cfe/trunk/lib/AST/TypeLoc.cpp Tue Aug 27 19:00:27 2013
@@ -378,18 +378,16 @@ void TemplateSpecializationTypeLoc::init
     case TemplateArgument::Template:
     case TemplateArgument::TemplateExpansion: {
       NestedNameSpecifierLocBuilder Builder;
-      TemplateName Template = Args[i].getAsTemplate();
+      TemplateName Template = Args[i].getAsTemplateOrTemplatePattern();
       if (DependentTemplateName *DTN = Template.getAsDependentTemplateName())
         Builder.MakeTrivial(Context, DTN->getQualifier(), Loc);
       else if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
         Builder.MakeTrivial(Context, QTN->getQualifier(), Loc);
-      
+
       ArgInfos[i] = TemplateArgumentLocInfo(
-                                           Builder.getWithLocInContext(Context),
-                                            Loc, 
-                                Args[i].getKind() == TemplateArgument::Template
-                                            ? SourceLocation()
-                                            : Loc);
+          Builder.getWithLocInContext(Context), Loc,
+          Args[i].getKind() == TemplateArgument::Template ? SourceLocation()
+                                                          : Loc);
       break;
     }
 

Modified: cfe/trunk/test/SemaTemplate/temp_arg_template.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg_template.cpp?rev=189422&r1=189421&r2=189422&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/temp_arg_template.cpp (original)
+++ cfe/trunk/test/SemaTemplate/temp_arg_template.cpp Tue Aug 27 19:00:27 2013
@@ -60,3 +60,14 @@ template <typename Primitive, template <
 struct unbox_args {
   typedef typename Primitive::template call<F> x;
 };
+
+template <template <typename> class... Templates>
+struct template_tuple {};
+template <typename T>
+struct identity {};
+template <template <typename> class... Templates>
+template_tuple<Templates...> f7() {}
+
+void foo() {
+  f7<identity>();
+}





More information about the cfe-commits mailing list