[PATCH] AST: Don't treat a TemplateExpansion as a Template
David Majnemer
david.majnemer at gmail.com
Sun Aug 25 15:12:43 PDT 2013
Hi doug.gregor, rsmith,
Instead of calling getAsTemplate(), call
getAsTemplateOrTemplatePattern() because it handles the
TemplateExpansion case too.
This fixes PR16997.
http://llvm-reviews.chandlerc.com/D1512
Files:
lib/AST/TypeLoc.cpp
test/SemaCXX/crash-lambda-12645424.cpp
Index: lib/AST/TypeLoc.cpp
===================================================================
--- lib/AST/TypeLoc.cpp
+++ lib/AST/TypeLoc.cpp
@@ -378,18 +378,16 @@
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;
}
Index: test/SemaCXX/crash-lambda-12645424.cpp
===================================================================
--- test/SemaCXX/crash-lambda-12645424.cpp
+++ test/SemaCXX/crash-lambda-12645424.cpp
@@ -41,3 +41,14 @@
class Z {
int empty = on(0) >> [] {}; // expected-error {{invalid operands to binary expression}}
};
+
+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>();
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1512.1.patch
Type: text/x-patch
Size: 1905 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130825/2463ed26/attachment.bin>
More information about the cfe-commits
mailing list