diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-08-26 00:14:38 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-08-26 00:14:38 +0000 |
| commit | bbcc9f0462c1b56e0bd6bdd830bd0250ec8ad2d4 (patch) | |
| tree | 707cccea7fa2a04369d734745e2af81e860a1fde /clang/test | |
| parent | 7c5ae7cbc60f1196bd4cde77c68f4b6995596215 (diff) | |
| download | bcm5719-llvm-bbcc9f0462c1b56e0bd6bdd830bd0250ec8ad2d4.tar.gz bcm5719-llvm-bbcc9f0462c1b56e0bd6bdd830bd0250ec8ad2d4.zip | |
C++ Modules TS: add frontend support for building pcm files from module
interface files. At the moment, all declarations (and no macros) are exported,
and 'export' declarations are not supported yet.
llvm-svn: 279794
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/Parser/cxx-modules-import.cpp | 27 | ||||
| -rw-r--r-- | clang/test/Parser/cxx-modules-interface.cppm | 21 | ||||
| -rw-r--r-- | clang/test/lit.cfg | 2 |
3 files changed, 38 insertions, 12 deletions
diff --git a/clang/test/Parser/cxx-modules-import.cpp b/clang/test/Parser/cxx-modules-import.cpp index cd4174eabd0..0600eddecb8 100644 --- a/clang/test/Parser/cxx-modules-import.cpp +++ b/clang/test/Parser/cxx-modules-import.cpp @@ -1,22 +1,26 @@ // RUN: rm -rf %t // RUN: mkdir -p %t -// RUN: echo 'int a, b;' > %t/x.h -// RUN: echo 'module x { header "x.h" module y {} } module z {}' > %t/map -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%S/Inputs -fmodules-cache-path=%t -fmodule-map-file=%t/map -verify %s \ +// RUN: echo 'module x; int a, b;' > %t/x.cppm +// RUN: echo '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: %clang_cc1 -std=c++1z -fmodules-ts -I%S/Inputs -fmodules-cache-path=%t -fmodule-map-file=%t/map -verify %s \ +// 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: %clang_cc1 -std=c++1z -fmodules-ts -I%S/Inputs -fmodules-cache-path=%t -fmodule-map-file=%t/map -verify %s \ +// 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: %clang_cc1 -std=c++1z -fmodules-ts -I%S/Inputs -fmodules-cache-path=%t -fmodule-map-file=%t/map -verify %s \ +// 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: %clang_cc1 -std=c++1z -fmodules-ts -I%S/Inputs -fmodules-cache-path=%t -fmodule-map-file=%t/map -verify %s \ +// 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: %clang_cc1 -std=c++1z -fmodules-ts -I%S/Inputs -fmodules-cache-path=%t -fmodule-map-file=%t/map -verify %s \ +// 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: %clang_cc1 -std=c++1z -fmodules-ts -I%S/Inputs -fmodules-cache-path=%t -fmodule-map-file=%t/map -verify %s \ +// 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: %clang_cc1 -std=c++1z -fmodules-ts -I%S/Inputs -fmodules-cache-path=%t -fmodule-map-file=%t/map -verify %s \ +// 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]]' module MODULE_KIND MODULE_NAME; @@ -34,7 +38,8 @@ module MODULE_KIND MODULE_NAME; int use_1 = a; #if TEST != 2 -// expected-error@-2 {{undeclared}} +// expected-error@-2 {{declaration of 'a' must be imported from module 'x' before it is required}} +// expected-note@x.cppm:1 {{here}} #endif import x; diff --git a/clang/test/Parser/cxx-modules-interface.cppm b/clang/test/Parser/cxx-modules-interface.cppm new file mode 100644 index 00000000000..88747714e5c --- /dev/null +++ b/clang/test/Parser/cxx-modules-interface.cppm @@ -0,0 +1,21 @@ +// 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 + +int n; +#if TEST == 3 +// expected-error@-2 {{redefinition of 'n'}} +// expected-note@-3 {{previous}} +#endif diff --git a/clang/test/lit.cfg b/clang/test/lit.cfg index e7ce8fac7c1..497058b58be 100644 --- a/clang/test/lit.cfg +++ b/clang/test/lit.cfg @@ -44,7 +44,7 @@ else: config.test_format = lit.formats.ShTest(execute_external) # suffixes: A list of file extensions to treat as test files. -config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.S', '.modulemap', '.test', '.rs'] +config.suffixes = ['.c', '.cpp', '.cppm', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.S', '.modulemap', '.test', '.rs'] # excludes: A list of directories to exclude from the testsuite. The 'Inputs' # subdirectories contain auxiliary inputs for various tests in their parent |

