summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CodeGenCXX/modules-ts.cppm20
-rw-r--r--clang/test/Parser/cxx-modules-interface.cppm43
-rw-r--r--clang/test/SemaCXX/modules-ts.cppm68
3 files changed, 115 insertions, 16 deletions
diff --git a/clang/test/CodeGenCXX/modules-ts.cppm b/clang/test/CodeGenCXX/modules-ts.cppm
new file mode 100644
index 00000000000..da3bcb2174a
--- /dev/null
+++ b/clang/test/CodeGenCXX/modules-ts.cppm
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fmodules-ts -std=c++1z -triple=x86_64-linux-gnu -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 {
+ // CHECK-LABEL: define i32 @_Z1fv(
+ int f() { return 0; }
+}
+
+// FIXME: Emit global variables and their initializers with this TU.
+// Emit an initialization function that other TUs can call, with guard variable.
+
+// FIXME: Mangle non-exported symbols so they don't collide with
+// non-exported symbols from other modules?
+
+// FIXME: Formally-internal-linkage symbols that are used from an exported
+// symbol need a mangled name and external linkage.
+
+// FIXME: const-qualified variables don't have implicit internal linkage when owned by a module.
diff --git a/clang/test/Parser/cxx-modules-interface.cppm b/clang/test/Parser/cxx-modules-interface.cppm
index 88747714e5c..f7835bd167b 100644
--- a/clang/test/Parser/cxx-modules-interface.cppm
+++ b/clang/test/Parser/cxx-modules-interface.cppm
@@ -1,21 +1,32 @@
-// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -o %t.pcm -verify -DTEST=0
-// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -o %t.pcm -verify -Dmodule=int -DTEST=1
-// RUN: not %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -fmodule-file=%t.pcm -o %t.pcm -DTEST=2 2>&1 | FileCheck %s --check-prefix=CHECK-2
-// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -fmodule-file=%t.pcm -o %t.pcm -verify -Dfoo=bar -DTEST=3
+// 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
-#if TEST == 0
+module foo;
+#ifndef ERRORS
// expected-no-diagnostics
-#endif
+#else
+// expected-error@-4 {{expected module declaration at start of module interface}}
-module foo;
-#if TEST == 1
-// expected-error@-2 {{expected module declaration at start of module interface}}
-#elif TEST == 2
-// CHECK-2: error: redefinition of module 'foo'
-#endif
+// FIXME: support 'export module X;' and 'export { int n; module X; }'
+// FIXME: proclaimed-ownership-declarations?
+
+export {
+ int a;
+ int b;
+}
+export int c;
+
+namespace N {
+ export void f() {}
+}
+
+export struct T {} t;
-int n;
-#if TEST == 3
-// expected-error@-2 {{redefinition of 'n'}}
-// expected-note@-3 {{previous}}
+struct S {
+ export int n; // expected-error {{expected member name or ';'}}
+ export static int n; // expected-error {{expected member name or ';'}}
+};
+void f() {
+ export int n; // expected-error {{expected expression}}
+}
#endif
diff --git a/clang/test/SemaCXX/modules-ts.cppm b/clang/test/SemaCXX/modules-ts.cppm
new file mode 100644
index 00000000000..61e9e43cad0
--- /dev/null
+++ b/clang/test/SemaCXX/modules-ts.cppm
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -o %t.pcm -verify -DTEST=0
+// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -o %t.pcm -verify -Dmodule=int -DTEST=1
+// RUN: not %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -fmodule-file=%t.pcm -o %t.pcm -DTEST=2 2>&1 | FileCheck %s --check-prefix=CHECK-2
+// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -fmodule-file=%t.pcm -o %t.pcm -verify -Dfoo=bar -DTEST=3
+
+#if TEST == 0
+// expected-no-diagnostics
+#endif
+
+module foo;
+#if TEST == 1
+// expected-error@-2 {{expected module declaration at start of module interface}}
+#elif TEST == 2
+// CHECK-2: error: redefinition of module 'foo'
+#endif
+
+static int m; // ok, internal linkage, so no redefinition error
+int n;
+#if TEST == 3
+// expected-error@-2 {{redefinition of '}}
+// expected-note@-3 {{previous}}
+#endif
+
+#if TEST == 0
+export {
+ int a;
+ int b;
+ constexpr int *p = &n;
+}
+export int c;
+
+namespace N {
+ export void f() {}
+}
+
+export struct T {} t;
+#elif TEST == 3
+int use_a = a; // expected-error {{declaration of 'a' must be imported from module 'foo' before it is required}}
+// expected-note@-13 {{previous}}
+
+#undef foo
+import foo;
+
+export {} // expected-error {{export declaration cannot be empty}}
+export { ; }
+export { static_assert(true); }
+
+// FIXME: These diagnostics are not very good.
+export import foo; // expected-error {{expected unqualified-id}}
+export { import foo; } // expected-error {{expected unqualified-id}}
+
+int use_b = b;
+int use_n = n; // FIXME: this should not be visible, because it is not exported
+
+extern int n;
+static_assert(&n == p); // FIXME: these are not the same entity
+#endif
+
+
+#if TEST == 1
+struct S {
+ export int n; // expected-error {{expected member name or ';'}}
+ export static int n; // expected-error {{expected member name or ';'}}
+};
+#endif
+
+// FIXME: Exports of declarations without external linkage are disallowed.
+// Exports of declarations with non-external-linkage types are disallowed.
OpenPOWER on IntegriCloud