tbaeder created this revision.
tbaeder added a reviewer: rsmith.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The test case otherwise fails an assertion in Diagnostic::getArgKind():

  clang++: 
/home/tbaeder/code/llvm-project/clang/include/clang/Basic/Diagnostic.h:1571: 
clang::DiagnosticsEngine::ArgumentKind clang::Diagnostic::getArgKind(unsigned 
int) const: Assertion `Idx < getNumArgs() && "Argument index out of range!"' 
failed.
  PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash 
backtrace, preprocessed source, and associated run script.
  Stack dump:
  0.    Program arguments: bin/clang++ module_import.cpp -std=c++20 -fmodules 
-fimplicit-module-maps -I. -stdlib=libc++ -fsyntax-only
  1.    module_import.cpp:1:20: current parser token ';'
  
  ...


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116595

Files:
  clang/lib/Sema/SemaModule.cpp
  clang/test/Modules/cxx20-export-import.cpp


Index: clang/test/Modules/cxx20-export-import.cpp
===================================================================
--- /dev/null
+++ clang/test/Modules/cxx20-export-import.cpp
@@ -0,0 +1,3 @@
+
+// RUN: %clang_cc1 -std=c++20 -fmodules -fmodules-cache-path=%t 
-fimplicit-module-maps -I%S/Inputs -stdlib=libc++ -verify %s
+export import dummy; // expected-error {{export declaration can only be used 
within a module interface unit after the module declaration}}
Index: clang/lib/Sema/SemaModule.cpp
===================================================================
--- clang/lib/Sema/SemaModule.cpp
+++ clang/lib/Sema/SemaModule.cpp
@@ -395,7 +395,7 @@
     // [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);
+    Diag(ExportLoc, diag::err_export_not_in_module_interface) << 0;
   }
 
   return Import;


Index: clang/test/Modules/cxx20-export-import.cpp
===================================================================
--- /dev/null
+++ clang/test/Modules/cxx20-export-import.cpp
@@ -0,0 +1,3 @@
+
+// RUN: %clang_cc1 -std=c++20 -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I%S/Inputs -stdlib=libc++ -verify %s
+export import dummy; // expected-error {{export declaration can only be used within a module interface unit after the module declaration}}
Index: clang/lib/Sema/SemaModule.cpp
===================================================================
--- clang/lib/Sema/SemaModule.cpp
+++ clang/lib/Sema/SemaModule.cpp
@@ -395,7 +395,7 @@
     // [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);
+    Diag(ExportLoc, diag::err_export_not_in_module_interface) << 0;
   }
 
   return Import;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to