Skip to content

Commit c2c840b

Browse files
committed
[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.
1 parent 3081bac commit c2c840b

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

clang/lib/Sema/SemaModule.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,8 @@ DeclResult Sema::ActOnModuleImport(SourceLocation StartLoc,
529529
if (!Mod)
530530
return true;
531531

532-
if (!Mod->isInterfaceOrPartition() && !ModuleName.empty()) {
532+
if (!Mod->isInterfaceOrPartition() && !ModuleName.empty() &&
533+
!getLangOpts().ObjC) {
533534
Diag(ImportLoc, diag::err_module_import_non_interface_nor_parition)
534535
<< ModuleName;
535536
return true;

clang/test/Modules/pr64755.cppm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
// RUN: %clang_cc1 -std=c++20 %t/use.cpp -fmodule-file=a0=%t/a0.pcm -verify -fsyntax-only
88
// RUN: %clang_cc1 -std=c++20 %t/use.cpp -fprebuilt-module-path=%t -verify -fsyntax-only
99

10+
// 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
11+
// RUN: %clang_cc1 -std=c++20 -x objective-c++ %t/use_obj.cpp -fmodule-file=%t/a0.pcm -verify -fsyntax-only
12+
// RUN: %clang_cc1 -std=c++20 -x objective-c++ %t/use_obj.cpp -fmodule-file=a0=%t/a0.pcm -verify -fsyntax-only
13+
// RUN: %clang_cc1 -std=c++20 -x objective-c++ %t/use_obj.cpp -fprebuilt-module-path=%t -verify -fsyntax-only
14+
1015
//--- module.modulemap
1116
module a0 { header "a0.h" export * }
1217

@@ -15,3 +20,7 @@ void a0() {}
1520

1621
//--- use.cpp
1722
import a0; // expected-error {{import of module 'a0' imported non C++20 importable modules}}
23+
24+
//--- use_obj.cpp
25+
// expected-no-diagnostics
26+
@import a0;

0 commit comments

Comments
 (0)