Richard Smith | 645386c | 2017-04-22 00:47:53 +0000 | [diff] [blame] | 1 | // Tests for module-declaration syntax. |
| 2 | // |
| 3 | // RUN: rm -rf %t |
| 4 | // RUN: mkdir -p %t |
| 5 | // RUN: echo 'export module x; int a, b;' > %t/x.cppm |
| 6 | // RUN: echo 'export module x.y; int c;' > %t/x.y.cppm |
| 7 | // |
| 8 | // RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %t/x.cppm -o %t/x.pcm |
| 9 | // 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 |
| 10 | // |
| 11 | // Module implementation for unknown and known module. (The former is ill-formed.) |
Richard Smith | 645386c | 2017-04-22 00:47:53 +0000 | [diff] [blame] | 12 | // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ |
| 13 | // RUN: -DTEST=1 -DEXPORT= -DPARTITION= -DMODULE_NAME=z |
| 14 | // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ |
| 15 | // RUN: -DTEST=2 -DEXPORT= -DPARTITION= -DMODULE_NAME=x |
| 16 | // |
| 17 | // Module interface for unknown and known module. (The latter is ill-formed due to |
| 18 | // redefinition.) |
| 19 | // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ |
| 20 | // RUN: -DTEST=3 -DEXPORT=export -DPARTITION= -DMODULE_NAME=z |
| 21 | // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ |
| 22 | // RUN: -DTEST=4 -DEXPORT=export -DPARTITION= -DMODULE_NAME=x |
| 23 | // |
| 24 | // Defining a module partition. |
| 25 | // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ |
| 26 | // RUN: -DTEST=5 -DEXPORT=export -DPARTITION=partition -DMODULE_NAME=z |
| 27 | // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ |
| 28 | // RUN: -DTEST=6 -DEXPORT= -DPARTITION=partition -DMODULE_NAME=z |
| 29 | // |
| 30 | // Miscellaneous syntax. |
| 31 | // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ |
| 32 | // RUN: -DTEST=7 -DEXPORT= -DPARTITION=elderberry -DMODULE_NAME=z |
| 33 | // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ |
Richard Smith | d97d35e | 2017-10-10 22:35:27 +0000 | [diff] [blame] | 34 | // RUN: -DTEST=8 -DEXPORT=export -DPARTITION= -DMODULE_NAME='z [[]]' |
Richard Smith | 645386c | 2017-04-22 00:47:53 +0000 | [diff] [blame] | 35 | // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ |
Richard Smith | d97d35e | 2017-10-10 22:35:27 +0000 | [diff] [blame] | 36 | // RUN: -DTEST=9 -DEXPORT=export -DPARTITION= -DMODULE_NAME='z [[fancy]]' |
Richard Smith | 645386c | 2017-04-22 00:47:53 +0000 | [diff] [blame] | 37 | // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ |
Richard Smith | d97d35e | 2017-10-10 22:35:27 +0000 | [diff] [blame] | 38 | // RUN: -DTEST=10 -DEXPORT=export -DPARTITION= -DMODULE_NAME='z [[maybe_unused]]' |
Richard Smith | 645386c | 2017-04-22 00:47:53 +0000 | [diff] [blame] | 39 | |
| 40 | EXPORT module PARTITION MODULE_NAME; |
| 41 | #if TEST == 4 |
| 42 | // expected-error@-2 {{redefinition of module 'x'}} |
Boris Kolpackov | b83213e | 2017-08-31 06:18:08 +0000 | [diff] [blame] | 43 | // expected-note-re@module-declaration.cpp:* {{loaded from '{{.*[/\\]}}x.pcm'}} |
Richard Smith | 645386c | 2017-04-22 00:47:53 +0000 | [diff] [blame] | 44 | #elif TEST == 6 |
| 45 | // expected-error@-5 {{module partition must be declared 'export'}} |
| 46 | #elif TEST == 7 |
Richard Smith | d97d35e | 2017-10-10 22:35:27 +0000 | [diff] [blame] | 47 | // expected-error@-7 {{expected ';'}} expected-error@-7 {{requires a type specifier}} expected-error@-7 {{definition of module 'elderberry' is not available}} |
Richard Smith | 645386c | 2017-04-22 00:47:53 +0000 | [diff] [blame] | 48 | #elif TEST == 9 |
| 49 | // expected-warning@-9 {{unknown attribute 'fancy' ignored}} |
| 50 | #elif TEST == 10 |
| 51 | // expected-error-re@-11 {{'maybe_unused' attribute cannot be applied to a module{{$}}}} |
Richard Smith | d97d35e | 2017-10-10 22:35:27 +0000 | [diff] [blame] | 52 | #elif TEST == 1 |
| 53 | // expected-error@-13 {{definition of module 'z' is not available}} |
Richard Smith | 645386c | 2017-04-22 00:47:53 +0000 | [diff] [blame] | 54 | #else |
| 55 | // expected-no-diagnostics |
| 56 | #endif |