diff options
author | Chuanqi Xu <yedeng.yd@linux.alibaba.com> | 2023-12-28 10:43:25 +0800 |
---|---|---|
committer | Chuanqi Xu <yedeng.yd@linux.alibaba.com> | 2023-12-28 10:45:47 +0800 |
commit | c2c840bd92cfac155f6205ff7505b109b301d389 (patch) | |
tree | 39c11dab523e63f245ca874b91cac4da84955253 | |
parent | 3081bacb606dd21943b295e3d0d01ed14cf25839 (diff) | |
download | llvm-c2c840bd92cfac155f6205ff7505b109b301d389.zip llvm-c2c840bd92cfac155f6205ff7505b109b301d389.tar.gz llvm-c2c840bd92cfac155f6205ff7505b109b301d389.tar.bz2 |
[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.
-rw-r--r-- | clang/lib/Sema/SemaModule.cpp | 3 | ||||
-rw-r--r-- | clang/test/Modules/pr64755.cppm | 9 |
2 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp index db0cbd5..ed7f626 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 75ef843..2d65686 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 +@import a0; |