diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index a29409461f575..e014500f2114f 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -1586,10 +1586,13 @@ void Sema::FilterLookupForScope(LookupResult &R, DeclContext *Ctx, Scope *S, /// We've determined that \p New is a redeclaration of \p Old. Check that they /// have compatible owning modules. bool Sema::CheckRedeclarationModuleOwnership(NamedDecl *New, NamedDecl *Old) { - // FIXME: The Modules TS is not clear about how friend declarations are - // to be treated. It's not meaningful to have different owning modules for - // linkage in redeclarations of the same entity, so for now allow the - // redeclaration and change the owning modules to match. + // [module.interface]p7: + // A declaration is attached to a module as follows: + // - If the declaration is a non-dependent friend declaration that nominates a + // function with a declarator-id that is a qualified-id or template-id or that + // nominates a class other than with an elaborated-type-specifier with neither + // a nested-name-specifier nor a simple-template-id, it is attached to the + // module to which the friend is attached ([basic.link]). if (New->getFriendObjectKind() && Old->getOwningModuleForLinkage() != New->getOwningModuleForLinkage()) { New->setLocalOwningModule(Old->getOwningModule());