================
@@ -6120,6 +6119,19 @@ ExpectedDecl 
ASTNodeImporter::VisitClassTemplateDecl(ClassTemplateDecl *D) {
           // see ASTTests test ImportExistingFriendClassTemplateDef.
           continue;
         }
+        // When importing a friend, it is possible that multiple declarations
+        // with same name can co-exist in specific cases (if a template 
contains
+        // a friend template and has a specialization). For this case the
+        // declarations should match, except that the "template depth" is
+        // different. No linking of previous declaration is needed in this 
case.
+        // FIXME: This condition may need refinement.
+        if (D->getFriendObjectKind() != Decl::FOK_None &&
+            FoundTemplate->getFriendObjectKind() != Decl::FOK_None &&
+            D->getFriendObjectKind() != FoundTemplate->getFriendObjectKind() &&
+            IsStructuralMatch(D, FoundTemplate, /*Complain=*/false,
+                              /*IgnoreTemplateParmDepth=*/true))
+          continue;
----------------
balazske wrote:

I did not want to modify an already working code part when it is not obvious 
that the change has no effect on the old behavior. In the new case we already 
know that there is no structural match and depth was not ignored, then we can 
check if these match with ignored depth (and this second structural equivalence 
check looks required to not import non-matching friends). We do not need any of 
the actions in the `if` branch at line 6108, only a `continue` (and it is not 
"dependent friend").

https://github.com/llvm/llvm-project/pull/115734
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to