]> granicus.if.org Git - clang/commitdiff
When comparing two templates in the template differ, consider them the
authorDouglas Gregor <dgregor@apple.com>
Thu, 31 Jan 2013 01:08:35 +0000 (01:08 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 31 Jan 2013 01:08:35 +0000 (01:08 +0000)
same if they are actually the same; having the same name isn't
enough. Fixes <rdar://problem/12931988>.

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

lib/AST/ASTDiagnostic.cpp
test/Misc/diag-template-diffing.cpp

index 514633ab5b7f69d74717450dc13d65133446d552..fb3544f03aa642f7789c4b5645e48feb22c5cd7a 100644 (file)
@@ -920,8 +920,8 @@ class TemplateDiff {
   /// even if the template arguments are not.
   static bool hasSameBaseTemplate(const TemplateSpecializationType *FromTST,
                                   const TemplateSpecializationType *ToTST) {
-    return FromTST->getTemplateName().getAsTemplateDecl()->getIdentifier() ==
-           ToTST->getTemplateName().getAsTemplateDecl()->getIdentifier();
+    return FromTST->getTemplateName().getAsTemplateDecl()->getCanonicalDecl() ==
+           ToTST->getTemplateName().getAsTemplateDecl()->getCanonicalDecl();
   }
 
   /// hasSameTemplate - Returns true if both types are specialized from the
index c158255f8062b614aaa7b50cb7a019dadee98be9..7e9998c828107d8f818555ca50eb4ae8797daf9b 100644 (file)
@@ -845,7 +845,24 @@ namespace PR15023 {
   // CHECK-ELIDE-NOTREE: candidate template ignored: deduced conflicting types for parameter 'Args' (<int, int &> vs. <int, int>)
 }
 
+namespace rdar12931988 {
+  namespace A {
+    template<typename T> struct X { };
+  }
+
+  namespace B {
+    template<typename T> struct X { };
+  }
+
+  void foo(A::X<int> &ax, B::X<int> bx) {
+    // CHECK-ELIDE-NOTREE: no viable overloaded '='
+    // CHECK-ELIDE-NOTREE: no known conversion from 'B::X<int>' to 'const rdar12931988::A::X<int>'
+    ax = bx;
+  }
+}
+
 // CHECK-ELIDE-NOTREE: {{[0-9]*}} errors generated.
 // CHECK-NOELIDE-NOTREE: {{[0-9]*}} errors generated.
 // CHECK-ELIDE-TREE: {{[0-9]*}} errors generated.
 // CHECK-NOELIDE-TREE: {{[0-9]*}} errors generated.
+