diff options
author | Hamza Sood <hamza_sood@me.com> | 2017-11-21 09:42:42 +0000 |
---|---|---|
committer | Hamza Sood <hamza_sood@me.com> | 2017-11-21 09:42:42 +0000 |
commit | 81fe14e4c32c76de0f4e5d670eedbfc6bccab75c (patch) | |
tree | 1d6c6157f07e1bee64b10ca0f93dfbb6a80f9750 /clang/test | |
parent | 519ea284af84f77fea8ffdc9d9041b91ba8b49ee (diff) | |
download | bcm5719-llvm-81fe14e4c32c76de0f4e5d670eedbfc6bccab75c.tar.gz bcm5719-llvm-81fe14e4c32c76de0f4e5d670eedbfc6bccab75c.zip |
[Modules TS] Added module re-export support.
This implements [dcl.modules.export] from the C++ Modules TS, which lets a module re-export another module with the "export import" syntax.
Differential Revision: https://reviews.llvm.org/D40270
llvm-svn: 318744
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.export/p1.cpp | 40 | ||||
-rw-r--r-- | clang/test/SemaCXX/modules-ts.cppm | 4 |
2 files changed, 40 insertions, 4 deletions
diff --git a/clang/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.export/p1.cpp b/clang/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.export/p1.cpp new file mode 100644 index 00000000000..ab8c690441c --- /dev/null +++ b/clang/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.export/p1.cpp @@ -0,0 +1,40 @@ +// RUN: rm -rf %t +// RUN: mkdir -p %t +// +// RUN: echo 'export module a; export class A{};' | %clang_cc1 -x c++ -fmodules-ts -emit-module-interface - -o %t/a.pcm +// RUN: echo 'export module b; export class B{};' | %clang_cc1 -x c++ -fmodules-ts -emit-module-interface - -o %t/b.pcm +// RUN: echo 'export module c; export class C{};' | %clang_cc1 -x c++ -fmodules-ts -emit-module-interface - -o %t/c.pcm +// +// RUN: %clang_cc1 -fmodules-ts -fprebuilt-module-path=%t -emit-module-interface %s -o %t/aggregate.internal.pcm -DAGGREGATE_INTERNAL +// RUN: %clang_cc1 -fmodules-ts -fprebuilt-module-path=%t -emit-module-interface %s -o %t/aggregate.pcm -DAGGREGATE +// +// RUN: %clang_cc1 -fmodules-ts -fprebuilt-module-path=%t %s -verify -DTEST +// expected-no-diagnostics + + +#ifdef AGGREGATE_INTERNAL +export module aggregate.internal; +export import a; +export { + import b; + import c; +} +#endif + + +// Export the above aggregate module. +// This is done to ensure that re-exports are transitive. +#ifdef AGGREGATE +export module aggregate; +export import aggregate.internal; +#endif + + +// For the actual test, just try using the classes from the exported modules +// and hope that they're accessible. +#ifdef TEST +import aggregate; +A a; +B b; +C c; +#endif diff --git a/clang/test/SemaCXX/modules-ts.cppm b/clang/test/SemaCXX/modules-ts.cppm index f64a4c0ab41..c07ee82e313 100644 --- a/clang/test/SemaCXX/modules-ts.cppm +++ b/clang/test/SemaCXX/modules-ts.cppm @@ -52,10 +52,6 @@ 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 |