[clang] c2c840b - [Modules] Don't prevent @import from ObjectiveC
Chuanqi Xu via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 27 18:46:16 PST 2023
Author: Chuanqi Xu
Date: 2023-12-28T10:45:47+08:00
New Revision: c2c840bd92cfac155f6205ff7505b109b301d389
URL: https://github.com/llvm/llvm-project/commit/c2c840bd92cfac155f6205ff7505b109b301d389
DIFF: https://github.com/llvm/llvm-project/commit/c2c840bd92cfac155f6205ff7505b109b301d389.diff
LOG: [Modules] Don't prevent @import from ObjectiveC
Previously we forbiden the users to import named modules from clang header
modules. However, due to an oversight, the @import form of Objective C
got involved. This is not want and we fix that in this patch.
Added:
Modified:
clang/lib/Sema/SemaModule.cpp
clang/test/Modules/pr64755.cppm
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index db0cbd5ec6d6ca..ed7f626971f345 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -529,7 +529,8 @@ DeclResult Sema::ActOnModuleImport(SourceLocation StartLoc,
if (!Mod)
return true;
- if (!Mod->isInterfaceOrPartition() && !ModuleName.empty()) {
+ if (!Mod->isInterfaceOrPartition() && !ModuleName.empty() &&
+ !getLangOpts().ObjC) {
Diag(ImportLoc, diag::err_module_import_non_interface_nor_parition)
<< ModuleName;
return true;
diff --git a/clang/test/Modules/pr64755.cppm b/clang/test/Modules/pr64755.cppm
index 75ef843154610d..2d656868eb60bb 100644
--- a/clang/test/Modules/pr64755.cppm
+++ b/clang/test/Modules/pr64755.cppm
@@ -7,6 +7,11 @@
// RUN: %clang_cc1 -std=c++20 %t/use.cpp -fmodule-file=a0=%t/a0.pcm -verify -fsyntax-only
// RUN: %clang_cc1 -std=c++20 %t/use.cpp -fprebuilt-module-path=%t -verify -fsyntax-only
+// RUN: %clang_cc1 -std=c++20 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I%t -fmodule-name=a0 -x objective-c++ -emit-module %t/module.modulemap -o %t/a0.pcm
+// RUN: %clang_cc1 -std=c++20 -x objective-c++ %t/use_obj.cpp -fmodule-file=%t/a0.pcm -verify -fsyntax-only
+// RUN: %clang_cc1 -std=c++20 -x objective-c++ %t/use_obj.cpp -fmodule-file=a0=%t/a0.pcm -verify -fsyntax-only
+// RUN: %clang_cc1 -std=c++20 -x objective-c++ %t/use_obj.cpp -fprebuilt-module-path=%t -verify -fsyntax-only
+
//--- module.modulemap
module a0 { header "a0.h" export * }
@@ -15,3 +20,7 @@ void a0() {}
//--- use.cpp
import a0; // expected-error {{import of module 'a0' imported non C++20 importable modules}}
+
+//--- use_obj.cpp
+// expected-no-diagnostics
+ at import a0;
More information about the cfe-commits
mailing list