P0629R0: Switch to latest proposal for distinguishing module interface from implementation.
This switches from the prototype syntax in P0273R0 ('module' and 'module
implementation') to the consensus syntax 'export module' and 'module'.
In passing, drop the "module declaration must be first" enforcement, since EWG
seems to have changed its mind on that.
llvm-svn: 301056
diff --git a/clang/test/CodeGenCXX/modules-ts.cppm b/clang/test/CodeGenCXX/modules-ts.cppm
index 90f6b53..d1552d9 100644
--- a/clang/test/CodeGenCXX/modules-ts.cppm
+++ b/clang/test/CodeGenCXX/modules-ts.cppm
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -fmodules-ts -std=c++1z -triple=x86_64-linux-gnu -fmodules-codegen -emit-module-interface %s -o %t.pcm
 // RUN: %clang_cc1 -fmodules-ts -std=c++1z -triple=x86_64-linux-gnu %t.pcm -emit-llvm -o - | FileCheck %s
 
-module FooBar;
+export module FooBar;
 
 export {
   // CHECK-LABEL: define i32 @_Z1fv(
diff --git a/clang/test/Driver/modules-ts.cpp b/clang/test/Driver/modules-ts.cpp
index fd33914..3847b71 100644
--- a/clang/test/Driver/modules-ts.cpp
+++ b/clang/test/Driver/modules-ts.cpp
@@ -1,6 +1,6 @@
 // Check compiling a module interface to a .pcm file.
 //
-// RUN: %clang -fmodules-ts -x c++-module --precompile %s -Dimplementation= -o %t.pcm -v 2>&1 | FileCheck %s --check-prefix=CHECK-PRECOMPILE
+// RUN: %clang -fmodules-ts -x c++-module --precompile %s -o %t.pcm -v 2>&1 | FileCheck %s --check-prefix=CHECK-PRECOMPILE
 //
 // CHECK-PRECOMPILE: -cc1 {{.*}} -emit-module-interface
 // CHECK-PRECOMPILE-SAME: -o {{.*}}.pcm
@@ -18,7 +18,7 @@
 
 // Check use of a .pcm file in another compilation.
 //
-// RUN: %clang -fmodules-ts -fmodule-file=%t.pcm %s -c -o %t.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-USE
+// RUN: %clang -fmodules-ts -fmodule-file=%t.pcm -Dexport= %s -c -o %t.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-USE
 //
 // CHECK-USE: -cc1
 // CHECK-USE-SAME: -emit-obj
@@ -28,11 +28,11 @@
 
 // Check combining precompile and compile steps works.
 //
-// RUN: %clang -fmodules-ts -x c++-module %s -Dimplementation= -c -o %t.pcm.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-PRECOMPILE --check-prefix=CHECK-COMPILE
+// RUN: %clang -fmodules-ts -x c++-module %s -c -o %t.pcm.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-PRECOMPILE --check-prefix=CHECK-COMPILE
 
 // Check that .cppm is treated as a module implicitly.
 // RUN: cp %s %t.cppm
-// RUN: %clang -fmodules-ts --precompile %t.cppm -Dimplementation= -o %t.pcm -v 2>&1 | FileCheck %s --check-prefix=CHECK-PRECOMPILE
+// RUN: %clang -fmodules-ts --precompile %t.cppm -o %t.pcm -v 2>&1 | FileCheck %s --check-prefix=CHECK-PRECOMPILE
 
-// Note, we use -Dimplementation= to make this a valid module interface unit when building the interface.
-module implementation foo;
+// Note, we use -Dexport= to make this a module implementation unit when building the implementation.
+export module foo;
diff --git a/clang/test/Parser/cxx-modules-import.cpp b/clang/test/Parser/cxx-modules-import.cpp
index 0600edd..98c4838 100644
--- a/clang/test/Parser/cxx-modules-import.cpp
+++ b/clang/test/Parser/cxx-modules-import.cpp
@@ -1,39 +1,41 @@
 // RUN: rm -rf %t
 // RUN: mkdir -p %t
-// RUN: echo 'module x; int a, b;' > %t/x.cppm
-// RUN: echo 'module x.y; int c;' > %t/x.y.cppm
+// RUN: echo 'export module x; int a, b;' > %t/x.cppm
+// RUN: echo 'export module x.y; int c;' > %t/x.y.cppm
 //
 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %t/x.cppm -o %t/x.pcm
 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface -fmodule-file=%t/x.pcm %t/x.y.cppm -o %t/x.y.pcm
 //
 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \
-// RUN:            -DTEST=1 -DMODULE_KIND=implementation -DMODULE_NAME=z
+// RUN:            -DTEST=1 -DEXPORT= -DPARTITION= -DMODULE_NAME=z
 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \
-// RUN:            -DTEST=2 -DMODULE_KIND=implementation -DMODULE_NAME=x
+// RUN:            -DTEST=2 -DEXPORT= -DPARTITION= -DMODULE_NAME=x
 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \
-// RUN:            -DTEST=3 -DMODULE_KIND= -DMODULE_NAME=z
+// RUN:            -DTEST=3 -DEXPORT=export -DPARTITION= -DMODULE_NAME=z
 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \
-// RUN:            -DTEST=4 -DMODULE_KIND=partition -DMODULE_NAME=z
+// RUN:            -DTEST=4 -DEXPORT=export -DPARTITION=partition -DMODULE_NAME=z
 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \
-// RUN:            -DTEST=5 -DMODULE_KIND=elderberry -DMODULE_NAME=z
+// RUN:            -DTEST=5 -DEXPORT= -DPARTITION=elderberry -DMODULE_NAME=z
 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \
-// RUN:            -DTEST=1 -DMODULE_KIND=implementation -DMODULE_NAME='z [[]]'
+// RUN:            -DTEST=1 -DEXPORT= -DPARTITION= -DMODULE_NAME='z [[]]'
 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \
-// RUN:            -DTEST=6 -DMODULE_KIND=implementation -DMODULE_NAME='z [[fancy]]'
+// RUN:            -DTEST=6 -DEXPORT= -DPARTITION= -DMODULE_NAME='z [[fancy]]'
 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \
-// RUN:            -DTEST=7 -DMODULE_KIND=implementation -DMODULE_NAME='z [[maybe_unused]]'
+// RUN:            -DTEST=7 -DEXPORT= -DPARTITION= -DMODULE_NAME='z [[maybe_unused]]'
+// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \
+// RUN:            -DTEST=8 -DEXPORT= -DPARTITION=partition -DMODULE_NAME=z
 
-module MODULE_KIND MODULE_NAME;
-#if TEST == 3
-// expected-error@-2 {{'module' declaration found while not building module interface}}
-#elif TEST == 4
-// expected-error@-4 {{'module partition' declaration found while not building module interface}}
+EXPORT module PARTITION MODULE_NAME;
+#if TEST == 3 || TEST == 4
+// ok, building object code for module interface
 #elif TEST == 5
-// expected-error@-6 {{unexpected module kind 'elderberry'}}
+// expected-error@-4 {{expected ';'}} expected-error@-4 {{requires a type specifier}}
 #elif TEST == 6
-// expected-warning@-8 {{unknown attribute 'fancy' ignored}}
+// expected-warning@-6 {{unknown attribute 'fancy' ignored}}
 #elif TEST == 7
-// expected-error-re@-10 {{'maybe_unused' attribute cannot be applied to a module{{$}}}}
+// expected-error-re@-8 {{'maybe_unused' attribute cannot be applied to a module{{$}}}}
+#elif TEST == 8
+// expected-error@-10 {{module partition must be declared 'export'}}
 #endif
 
 int use_1 = a;
@@ -52,7 +54,7 @@
 import x [[blarg::noreturn]]; // expected-warning {{unknown attribute 'noreturn' ignored}}
 
 import x.y;
-import x.; // expected-error {{expected a module name after module import}}
-import .x; // expected-error {{expected a module name after module import}}
+import x.; // expected-error {{expected a module name after 'import'}}
+import .x; // expected-error {{expected a module name after 'import'}}
 
 import blarg; // expected-error {{module 'blarg' not found}}
diff --git a/clang/test/Parser/cxx-modules-interface.cppm b/clang/test/Parser/cxx-modules-interface.cppm
index f7835bd..628b854 100644
--- a/clang/test/Parser/cxx-modules-interface.cppm
+++ b/clang/test/Parser/cxx-modules-interface.cppm
@@ -1,13 +1,13 @@
 // RUN:     %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -o %t.pcm -verify
 // RUN:     %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -o %t.pcm -verify -Dmodule=int -DERRORS
 
-module foo;
+export module foo;
 #ifndef ERRORS
 // expected-no-diagnostics
 #else
-// expected-error@-4 {{expected module declaration at start of module interface}}
+// FIXME: diagnose 'export' declaration in non-module
+// FIXME: diagnose missing module-declaration when building module interface
 
-// FIXME: support 'export module X;' and 'export { int n; module X; }'
 // FIXME: proclaimed-ownership-declarations?
 
 export {
diff --git a/clang/test/SemaCXX/modules-ts.cppm b/clang/test/SemaCXX/modules-ts.cppm
index 71c09d3..109a1f4 100644
--- a/clang/test/SemaCXX/modules-ts.cppm
+++ b/clang/test/SemaCXX/modules-ts.cppm
@@ -7,9 +7,9 @@
 // expected-no-diagnostics
 #endif
 
-module foo;
+export module foo;
 #if TEST == 1
-// expected-error@-2 {{expected module declaration at start of module interface}}
+// FIXME: diagnose export outside of module interface unit
 #elif TEST == 2
 // CHECK-2: error: redefinition of module 'foo'
 #endif