From: Douglas Gregor Date: Thu, 31 Jan 2013 01:08:35 +0000 (+0000) Subject: When comparing two templates in the template differ, consider them the X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1166723df8af0f062c3f6d473d8ae7bb2b64e572;p=clang When comparing two templates in the template differ, consider them the same if they are actually the same; having the same name isn't enough. Fixes . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174013 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ASTDiagnostic.cpp b/lib/AST/ASTDiagnostic.cpp index 514633ab5b..fb3544f03a 100644 --- a/lib/AST/ASTDiagnostic.cpp +++ b/lib/AST/ASTDiagnostic.cpp @@ -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 diff --git a/test/Misc/diag-template-diffing.cpp b/test/Misc/diag-template-diffing.cpp index c158255f80..7e9998c828 100644 --- a/test/Misc/diag-template-diffing.cpp +++ b/test/Misc/diag-template-diffing.cpp @@ -845,7 +845,24 @@ namespace PR15023 { // CHECK-ELIDE-NOTREE: candidate template ignored: deduced conflicting types for parameter 'Args' ( vs. ) } +namespace rdar12931988 { + namespace A { + template struct X { }; + } + + namespace B { + template struct X { }; + } + + void foo(A::X &ax, B::X bx) { + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'B::X' to 'const rdar12931988::A::X' + 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. +