aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2012-08-28 04:13:54 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2012-08-28 04:13:54 +0000
commit02e221bad95aada3190fa6189e38023cba27bc72 (patch)
treef13d3ba326f26bf789c47caf4d22a6df3785b2a0
parent4c3b8a3ed28c52dc56d3a1b9670d71e5f7070c62 (diff)
Fix for assertion when solving unresolved templates.
Patch by Magee, Josh. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162737 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/TreeTransform.h3
-rw-r--r--test/Sema/template-specialization.cpp21
2 files changed, 23 insertions, 1 deletions
diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h
index ef58cb62b9..2bbc41326e 100644
--- a/lib/Sema/TreeTransform.h
+++ b/lib/Sema/TreeTransform.h
@@ -7487,7 +7487,8 @@ TreeTransform<Derived>::TransformUnresolvedLookupExpr(
// If we have template arguments, rebuild them, then rebuild the
// templateid expression.
TemplateArgumentListInfo TransArgs(Old->getLAngleLoc(), Old->getRAngleLoc());
- if (getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
+ if (Old->hasExplicitTemplateArgs() &&
+ getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
Old->getNumTemplateArgs(),
TransArgs))
return ExprError();
diff --git a/test/Sema/template-specialization.cpp b/test/Sema/template-specialization.cpp
new file mode 100644
index 0000000000..ae7bc332fc
--- /dev/null
+++ b/test/Sema/template-specialization.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+// Verify the absence of assertion failures when solving calls to unresolved
+// template member functions.
+
+struct A {
+ template <typename T>
+ static void bar(int) { } // expected-note {{candidate template ignored: couldn't infer template argument 'T'}}
+};
+
+struct B {
+ template <int i>
+ static void foo() {
+ int array[i];
+ A::template bar(array[0]); // expected-error {{no matching function for call to 'bar'}}
+ }
+};
+
+int main() {
+ B::foo<4>(); // expected-note {{in instantiation of function template specialization 'B::foo<4>'}}
+ return 0;
+}