File tree Expand file tree Collapse file tree 4 files changed +28
-24
lines changed Expand file tree Collapse file tree 4 files changed +28
-24
lines changed Original file line number Diff line number Diff line change @@ -835,10 +835,7 @@ class alignas(8) Decl {
835
835
836
836
// / Get the module that owns this declaration for linkage purposes.
837
837
// / There only ever is such a standard C++ module.
838
- // /
839
- // / \param IgnoreLinkage Ignore the linkage of the entity; assume that
840
- // / all declarations in a global module fragment are unowned.
841
- Module *getOwningModuleForLinkage (bool IgnoreLinkage = false ) const ;
838
+ Module *getOwningModuleForLinkage () const ;
842
839
843
840
// / Determine whether this declaration is definitely visible to name lookup,
844
841
// / independent of whether the owning module is visible.
Original file line number Diff line number Diff line change @@ -1614,7 +1614,7 @@ LinkageInfo LinkageComputer::getDeclLinkageAndVisibility(const NamedDecl *D) {
1614
1614
: CK);
1615
1615
}
1616
1616
1617
- Module *Decl::getOwningModuleForLinkage (bool IgnoreLinkage ) const {
1617
+ Module *Decl::getOwningModuleForLinkage () const {
1618
1618
if (isa<NamespaceDecl>(this ))
1619
1619
// Namespaces never have module linkage. It is the entities within them
1620
1620
// that [may] do.
@@ -1637,24 +1637,9 @@ Module *Decl::getOwningModuleForLinkage(bool IgnoreLinkage) const {
1637
1637
1638
1638
case Module::ModuleHeaderUnit:
1639
1639
case Module::ExplicitGlobalModuleFragment:
1640
- case Module::ImplicitGlobalModuleFragment: {
1641
- // External linkage declarations in the global module have no owning module
1642
- // for linkage purposes. But internal linkage declarations in the global
1643
- // module fragment of a particular module are owned by that module for
1644
- // linkage purposes.
1645
- // FIXME: p1815 removes the need for this distinction -- there are no
1646
- // internal linkage declarations that need to be referred to from outside
1647
- // this TU.
1648
- if (IgnoreLinkage)
1649
- return nullptr ;
1650
- bool InternalLinkage;
1651
- if (auto *ND = dyn_cast<NamedDecl>(this ))
1652
- InternalLinkage = !ND->hasExternalFormalLinkage ();
1653
- else
1654
- InternalLinkage = isInAnonymousNamespace ();
1655
- return InternalLinkage ? M->Kind == Module::ModuleHeaderUnit ? M : M->Parent
1656
- : nullptr ;
1657
- }
1640
+ case Module::ImplicitGlobalModuleFragment:
1641
+ // The global module shouldn't change the linkage.
1642
+ return nullptr ;
1658
1643
1659
1644
case Module::PrivateModuleFragment:
1660
1645
// The private module fragment is part of its containing module for linkage
Original file line number Diff line number Diff line change @@ -5965,7 +5965,7 @@ RedeclarationKind Sema::forRedeclarationInCurContext() const {
5965
5965
// anything that is not visible. We don't need to check linkage here; if
5966
5966
// the context has internal linkage, redeclaration lookup won't find things
5967
5967
// from other TUs, and we can't safely compute linkage yet in general.
5968
- if (cast<Decl>(CurContext)->getOwningModuleForLinkage (/* IgnoreLinkage */ true ))
5968
+ if (cast<Decl>(CurContext)->getOwningModuleForLinkage ())
5969
5969
return RedeclarationKind::ForVisibleRedeclaration;
5970
5970
return RedeclarationKind::ForExternalRedeclaration;
5971
5971
}
Original file line number Diff line number Diff line change
1
+ // RUN: rm -rf %t
2
+ // RUN: split-file %s %t
3
+ // RUN: cd %t
4
+ //
5
+ // RUN: %clang_cc1 -std=c++20 %t/m.cppm -fsyntax-only -verify
6
+
7
+ // --- foo.h
8
+
9
+ template <typename ... U>
10
+ static void foo (U...) noexcept ;
11
+
12
+ class A {
13
+ template <typename ... U>
14
+ friend void foo (U...) noexcept ;
15
+ };
16
+
17
+ // --- m.cppm
18
+ // expected-no-diagnostics
19
+ module ;
20
+ #include " foo.h"
21
+ export module m;
22
+ export using ::A;
You can’t perform that action at this time.
0 commit comments