ChuanqiXu updated this revision to Diff 395789.
ChuanqiXu added a comment.

Rebased


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116098/new/

https://reviews.llvm.org/D116098

Files:
  clang/lib/Sema/SemaModule.cpp
  clang/test/Modules/module-transtive-instantiation.cpp


Index: clang/test/Modules/module-transtive-instantiation.cpp
===================================================================
--- clang/test/Modules/module-transtive-instantiation.cpp
+++ clang/test/Modules/module-transtive-instantiation.cpp
@@ -3,11 +3,9 @@
 // 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() {
-    // 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}}
+    return bar<int>();
 }
Index: clang/lib/Sema/SemaModule.cpp
===================================================================
--- clang/lib/Sema/SemaModule.cpp
+++ clang/lib/Sema/SemaModule.cpp
@@ -387,6 +387,8 @@
   if (!ModuleScopes.empty() && ModuleScopes.back().ModuleInterface) {
     if (ExportLoc.isValid() || getEnclosingExportDecl(Import))
       getCurrentModule()->Exports.emplace_back(Mod, false);
+    else
+      getCurrentModule()->Imports.insert(Mod);
   } else if (ExportLoc.isValid()) {
     Diag(ExportLoc, diag::err_export_not_in_module_interface);
   }


Index: clang/test/Modules/module-transtive-instantiation.cpp
===================================================================
--- clang/test/Modules/module-transtive-instantiation.cpp
+++ clang/test/Modules/module-transtive-instantiation.cpp
@@ -3,11 +3,9 @@
 // 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() {
-    // 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}}
+    return bar<int>();
 }
Index: clang/lib/Sema/SemaModule.cpp
===================================================================
--- clang/lib/Sema/SemaModule.cpp
+++ clang/lib/Sema/SemaModule.cpp
@@ -387,6 +387,8 @@
   if (!ModuleScopes.empty() && ModuleScopes.back().ModuleInterface) {
     if (ExportLoc.isValid() || getEnclosingExportDecl(Import))
       getCurrentModule()->Exports.emplace_back(Mod, false);
+    else
+      getCurrentModule()->Imports.insert(Mod);
   } else if (ExportLoc.isValid()) {
     Diag(ExportLoc, diag::err_export_not_in_module_interface);
   }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to