]> granicus.if.org Git - clang/commitdiff
When determining which template partial specialization is more specialized,
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 5 Nov 2010 23:25:18 +0000 (23:25 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 5 Nov 2010 23:25:18 +0000 (23:25 +0000)
make sure to setup the instantiation stack. Fixes rdar://8620775 & http://llvm.org/PR8234

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118314 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplateDeduction.cpp
test/SemaCXX/crashes.cpp

index 905e17e9c149396f728a9e8420e77c4a9d32332f..9b117b68132cb29cd8d4d7a98e0cd2a748162ee9 100644 (file)
@@ -2485,10 +2485,13 @@ Sema::getMoreSpecializedPartialSpecialization(
                                                                Info,
                                                                Deduced,
                                                                0);
-  if (Better1)
+  if (Better1) {
+    InstantiatingTemplate Inst(*this, PS2->getLocation(), PS2,
+                               Deduced.data(), Deduced.size(), Info);
     Better1 = !::FinishTemplateArgumentDeduction(*this, PS2, 
                                                  PS1->getTemplateArgs(), 
                                                  Deduced, Info);
+  }
   
   // Determine whether PS2 is at least as specialized as PS1
   Deduced.clear();
@@ -2500,10 +2503,13 @@ Sema::getMoreSpecializedPartialSpecialization(
                                                                Info,
                                                                Deduced,
                                                                0);
-  if (Better2)
+  if (Better2) {
+    InstantiatingTemplate Inst(*this, PS1->getLocation(), PS1,
+                               Deduced.data(), Deduced.size(), Info);
     Better2 = !::FinishTemplateArgumentDeduction(*this, PS1, 
                                                  PS2->getTemplateArgs(), 
                                                  Deduced, Info);
+  }
   
   if (Better1 == Better2)
     return 0;
index 53eecb6c14f24f0685f6844572ac9bd469501e2d..87bde2aa9398476b1bbb8e457996f14b100df7aa 100644 (file)
@@ -41,3 +41,30 @@ struct {
   new Y // expected-error{{no viable conversion}}
 };
 }
+
+// http://llvm.org/PR8234
+namespace PR8234 {
+template<typename Signature>
+class callback
+{
+};
+
+template<typename R , typename ARG_TYPE0>
+class callback<R( ARG_TYPE0)>
+{
+    public:
+        callback() {}
+};
+
+template< typename ARG_TYPE0>
+class callback<void( ARG_TYPE0)>
+{
+    public:
+        callback() {}
+};
+
+void f()
+{
+    callback<void(const int&)> op;
+}
+}