Author: Chuanqi Xu Date: 2021-12-23T21:10:07+08:00 New Revision: 1e2c31c66be79b6ca6aeb42fc2835017935b8b27
URL: https://github.com/llvm/llvm-project/commit/1e2c31c66be79b6ca6aeb42fc2835017935b8b27 DIFF: https://github.com/llvm/llvm-project/commit/1e2c31c66be79b6ca6aeb42fc2835017935b8b27.diff LOG: Revert "[C++20] [Coroutines] Mark imported module as imported if not exported" This reverts commit 368318bcce66d9fef420fc34cca361b79d80cee5. The title is not right. It should be a patch about modules instead of coroutines. Added: Modified: clang/lib/Sema/SemaModule.cpp clang/test/Modules/module-transtive-instantiation.cpp Removed: ################################################################################ diff --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp index a4b9f3c242c1c..f497199badc10 100644 --- a/clang/lib/Sema/SemaModule.cpp +++ b/clang/lib/Sema/SemaModule.cpp @@ -383,18 +383,11 @@ DeclResult Sema::ActOnModuleImport(SourceLocation StartLoc, if (!ModuleScopes.empty()) Context.addModuleInitializer(ModuleScopes.back().Module, Import); + // Re-export the module if needed. if (!ModuleScopes.empty() && ModuleScopes.back().ModuleInterface) { - // Re-export the module if the imported module is exported. - // Note that we don't need to add re-exported module to Imports field - // since `Exports` implies the module is imported already. if (ExportLoc.isValid() || getEnclosingExportDecl(Import)) getCurrentModule()->Exports.emplace_back(Mod, false); - else - getCurrentModule()->Imports.insert(Mod); } else if (ExportLoc.isValid()) { - // [module.interface]p1: - // An export-declaration shall inhabit a namespace scope and appear in the - // purview of a module interface unit. Diag(ExportLoc, diag::err_export_not_in_module_interface); } diff --git a/clang/test/Modules/module-transtive-instantiation.cpp b/clang/test/Modules/module-transtive-instantiation.cpp index b44f0bbfdf399..2c5c7ead8ad53 100644 --- a/clang/test/Modules/module-transtive-instantiation.cpp +++ b/clang/test/Modules/module-transtive-instantiation.cpp @@ -3,9 +3,11 @@ // RUN: %clang_cc1 -std=c++20 %S/Inputs/module-transtive-instantiation/Templ.cppm -emit-module-interface -o %t/Templ.pcm // RUN: %clang_cc1 -std=c++20 %S/Inputs/module-transtive-instantiation/bar.cppm -emit-module-interface -fprebuilt-module-path=%t -o %t/bar.pcm // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %s -fsyntax-only -verify -// expected-no-diagnostics import bar; int foo() { - return bar<int>(); + // FIXME: It shouldn't be an error. Since the `G` is already imported in bar. + return bar<int>(); // expected-error@Inputs/module-transtive-instantiation/bar.cppm:5 {{definition of 'G' must be imported from module 'Templ' before it is required}} + // expected-note@-1 {{in instantiation of function template specialization 'bar<int>' requested here}} + // expected-note@Inputs/module-transtive-instantiation/Templ.cppm:3 {{definition here is not reachable}} } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits