Author: Chuanqi Xu Date: 2023-03-03T11:15:29+08:00 New Revision: 5828692f70bc5f92fad9ed21a1844044924680aa
URL: https://github.com/llvm/llvm-project/commit/5828692f70bc5f92fad9ed21a1844044924680aa DIFF: https://github.com/llvm/llvm-project/commit/5828692f70bc5f92fad9ed21a1844044924680aa.diff LOG: [C++20] [Modules] Make TheImplicitGlobalModuleFragment and TheExportedImplicitGlobalModuleFragment to be useable modules The unexported language linkage become unvisible to the current module unit after the previous commit bf52ead24ca4. This patch fixes the issue. Added: clang/test/Modules/use-extern-language-linkage.cppm Modified: clang/lib/Sema/SemaDeclCXX.cpp clang/lib/Sema/SemaLookup.cpp Removed: ################################################################################ diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index ae8b8d62bcf3b..21c02b7ba4aa1 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -16388,7 +16388,8 @@ Decl *Sema::ActOnFinishLinkageSpecification(Scope *S, // LinkageSpec isn't in the module created by itself. So we don't // need to pop it. if (getLangOpts().CPlusPlusModules && getCurrentModule() && - getCurrentModule()->isGlobalModule() && getCurrentModule()->Parent) + getCurrentModule()->isImplicitGlobalModule() && + getCurrentModule()->Parent) PopImplicitGlobalModuleFragment(); PopDeclContext(); diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index aeeb49005ed1a..09a38571762d5 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -1579,7 +1579,8 @@ bool Sema::isUsableModule(const Module *M) { // [module.global.frag]p1: // The global module fragment can be used to provide declarations that are // attached to the global module and usable within the module unit. - if (M == TheGlobalModuleFragment || + if (M == TheGlobalModuleFragment || M == TheImplicitGlobalModuleFragment || + M == TheExportedImplicitGlobalModuleFragment || // If M is the module we're parsing, it should be usable. This covers the // private module fragment. The private module fragment is usable only if // it is within the current module unit. And it must be the current diff --git a/clang/test/Modules/use-extern-language-linkage.cppm b/clang/test/Modules/use-extern-language-linkage.cppm new file mode 100644 index 0000000000000..bfaa6297abba8 --- /dev/null +++ b/clang/test/Modules/use-extern-language-linkage.cppm @@ -0,0 +1,25 @@ +// RUN: rm -rf %t +// RUN: mkdir -p %t +// RUN: split-file %s %t +// +// RUN: %clang_cc1 -std=c++20 %t/a.cppm -fsyntax-only -verify + +//--- foo.h +extern "C++" void c_func(); + +//--- a.cppm +// expected-no-diagnostics +module; +#include "foo.h" +export module a; +export extern "C++" void foo() {} +extern "C++" void bar() {} +export extern "C" void foo_c() {} +extern "C" void bar_c() {} +export void a() { + foo(); + bar(); + foo_c(); + bar_c(); + c_func(); +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits