Richard Smith | 49cc1cc | 2016-08-18 21:59:42 +0000 | [diff] [blame] | 1 | // RUN: rm -rf %t |
| 2 | // RUN: mkdir -p %t |
Richard Smith | bbcc9f0 | 2016-08-26 00:14:38 +0000 | [diff] [blame] | 3 | // RUN: echo 'module x; int a, b;' > %t/x.cppm |
| 4 | // RUN: echo 'module x.y; int c;' > %t/x.y.cppm |
| 5 | // |
| 6 | // RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %t/x.cppm -o %t/x.pcm |
| 7 | // 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 |
| 8 | // |
| 9 | // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ |
Richard Smith | 964cc53 | 2016-08-19 01:43:06 +0000 | [diff] [blame] | 10 | // RUN: -DTEST=1 -DMODULE_KIND=implementation -DMODULE_NAME=z |
Richard Smith | bbcc9f0 | 2016-08-26 00:14:38 +0000 | [diff] [blame] | 11 | // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ |
Richard Smith | 964cc53 | 2016-08-19 01:43:06 +0000 | [diff] [blame] | 12 | // RUN: -DTEST=2 -DMODULE_KIND=implementation -DMODULE_NAME=x |
Richard Smith | bbcc9f0 | 2016-08-26 00:14:38 +0000 | [diff] [blame] | 13 | // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ |
Richard Smith | 964cc53 | 2016-08-19 01:43:06 +0000 | [diff] [blame] | 14 | // RUN: -DTEST=3 -DMODULE_KIND= -DMODULE_NAME=z |
Richard Smith | bbcc9f0 | 2016-08-26 00:14:38 +0000 | [diff] [blame] | 15 | // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ |
Richard Smith | 964cc53 | 2016-08-19 01:43:06 +0000 | [diff] [blame] | 16 | // RUN: -DTEST=4 -DMODULE_KIND=partition -DMODULE_NAME=z |
Richard Smith | bbcc9f0 | 2016-08-26 00:14:38 +0000 | [diff] [blame] | 17 | // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ |
Richard Smith | 964cc53 | 2016-08-19 01:43:06 +0000 | [diff] [blame] | 18 | // RUN: -DTEST=5 -DMODULE_KIND=elderberry -DMODULE_NAME=z |
Richard Smith | bbcc9f0 | 2016-08-26 00:14:38 +0000 | [diff] [blame] | 19 | // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ |
Richard Smith | 964cc53 | 2016-08-19 01:43:06 +0000 | [diff] [blame] | 20 | // RUN: -DTEST=1 -DMODULE_KIND=implementation -DMODULE_NAME='z [[]]' |
Richard Smith | bbcc9f0 | 2016-08-26 00:14:38 +0000 | [diff] [blame] | 21 | // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ |
Richard Smith | 964cc53 | 2016-08-19 01:43:06 +0000 | [diff] [blame] | 22 | // RUN: -DTEST=6 -DMODULE_KIND=implementation -DMODULE_NAME='z [[fancy]]' |
Richard Smith | bbcc9f0 | 2016-08-26 00:14:38 +0000 | [diff] [blame] | 23 | // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ |
Richard Smith | 964cc53 | 2016-08-19 01:43:06 +0000 | [diff] [blame] | 24 | // RUN: -DTEST=7 -DMODULE_KIND=implementation -DMODULE_NAME='z [[maybe_unused]]' |
Richard Smith | 49cc1cc | 2016-08-18 21:59:42 +0000 | [diff] [blame] | 25 | |
Richard Smith | 964cc53 | 2016-08-19 01:43:06 +0000 | [diff] [blame] | 26 | module MODULE_KIND MODULE_NAME; |
| 27 | #if TEST == 3 |
| 28 | // expected-error@-2 {{'module' declaration found while not building module interface}} |
| 29 | #elif TEST == 4 |
| 30 | // expected-error@-4 {{'module partition' declaration found while not building module interface}} |
| 31 | #elif TEST == 5 |
| 32 | // expected-error@-6 {{unexpected module kind 'elderberry'}} |
| 33 | #elif TEST == 6 |
| 34 | // expected-warning@-8 {{unknown attribute 'fancy' ignored}} |
| 35 | #elif TEST == 7 |
| 36 | // expected-error-re@-10 {{'maybe_unused' attribute cannot be applied to a module{{$}}}} |
| 37 | #endif |
| 38 | |
| 39 | int use_1 = a; |
| 40 | #if TEST != 2 |
Richard Smith | bbcc9f0 | 2016-08-26 00:14:38 +0000 | [diff] [blame] | 41 | // expected-error@-2 {{declaration of 'a' must be imported from module 'x' before it is required}} |
| 42 | // expected-note@x.cppm:1 {{here}} |
Richard Smith | 964cc53 | 2016-08-19 01:43:06 +0000 | [diff] [blame] | 43 | #endif |
Richard Smith | 49cc1cc | 2016-08-18 21:59:42 +0000 | [diff] [blame] | 44 | |
| 45 | import x; |
| 46 | |
| 47 | int use_2 = b; // ok |
| 48 | |
| 49 | import x [[]]; |
| 50 | import x [[foo]]; // expected-warning {{unknown attribute 'foo' ignored}} |
| 51 | import x [[noreturn]]; // expected-error {{'noreturn' attribute cannot be applied to a module import}} |
| 52 | import x [[blarg::noreturn]]; // expected-warning {{unknown attribute 'noreturn' ignored}} |
| 53 | |
| 54 | import x.y; |
| 55 | import x.; // expected-error {{expected a module name after module import}} |
| 56 | import .x; // expected-error {{expected a module name after module import}} |
| 57 | |
| 58 | import blarg; // expected-error {{module 'blarg' not found}} |