Skip to content

Commit baa5b76

Browse files
committed
[C++20] [Modules] Make module local decls visible to language linkage in the same module
Close #123343 See the issue and the comments in the patch for details.
1 parent 0171e56 commit baa5b76

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

clang/lib/Sema/SemaLookup.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,6 +1624,11 @@ bool Sema::isUsableModule(const Module *M) {
16241624
if (!Current)
16251625
return false;
16261626

1627+
// For implicit global module, the decls in the same modules with the parent
1628+
// module should be visible to the decls in the implicit global module.
1629+
if (Current->isImplicitGlobalModule())
1630+
Current = Current->getTopLevelModule();
1631+
16271632
// If M is the module we're parsing or M and the current module unit lives in
16281633
// the same module, M should be usable.
16291634
//
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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.a.cppm -emit-module-interface -o %t/a.pcm
6+
// RUN: %clang_cc1 -std=c++20 %t/m.b.cppm -fmodule-file=m:a=%t/a.pcm -fsyntax-only -verify
7+
8+
//--- m.a.cppm
9+
export module m:a;
10+
int a;
11+
12+
//--- m.b.cppm
13+
// expected-no-diagnostics
14+
module m:b;
15+
import :a;
16+
extern "C++" int get_a() { return a; }

0 commit comments

Comments
 (0)