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.) 12 // FIXME: TEST=1 should fail because we don't have an interface for module z. 13 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ 14 // RUN: -DTEST=1 -DEXPORT= -DPARTITION= -DMODULE_NAME=z 15 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ 16 // RUN: -DTEST=2 -DEXPORT= -DPARTITION= -DMODULE_NAME=x 17 // 18 // Module interface for unknown and known module. (The latter is ill-formed due to 19 // redefinition.) 20 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ 21 // RUN: -DTEST=3 -DEXPORT=export -DPARTITION= -DMODULE_NAME=z 22 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ 23 // RUN: -DTEST=4 -DEXPORT=export -DPARTITION= -DMODULE_NAME=x 24 // 25 // Defining a module partition. 26 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ 27 // RUN: -DTEST=5 -DEXPORT=export -DPARTITION=partition -DMODULE_NAME=z 28 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ 29 // RUN: -DTEST=6 -DEXPORT= -DPARTITION=partition -DMODULE_NAME=z 30 // 31 // Miscellaneous syntax. 32 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ 33 // RUN: -DTEST=7 -DEXPORT= -DPARTITION=elderberry -DMODULE_NAME=z 34 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ 35 // RUN: -DTEST=8 -DEXPORT= -DPARTITION= -DMODULE_NAME='z [[]]' 36 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ 37 // RUN: -DTEST=9 -DEXPORT= -DPARTITION= -DMODULE_NAME='z [[fancy]]' 38 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ 39 // RUN: -DTEST=10 -DEXPORT= -DPARTITION= -DMODULE_NAME='z [[maybe_unused]]' 40 41 EXPORT module PARTITION MODULE_NAME; 42 #if TEST == 4 43 // expected-error@-2 {{redefinition of module 'x'}} 44 // [email protected]:* {{loaded from '{{.*[/\\]}}x.pcm'}} 45 #elif TEST == 6 46 // expected-error@-5 {{module partition must be declared 'export'}} 47 #elif TEST == 7 48 // expected-error@-7 {{expected ';'}} expected-error@-7 {{requires a type specifier}} 49 #elif TEST == 9 50 // expected-warning@-9 {{unknown attribute 'fancy' ignored}} 51 #elif TEST == 10 52 // expected-error-re@-11 {{'maybe_unused' attribute cannot be applied to a module{{$}}}} 53 #else 54 // expected-no-diagnostics 55 #endif 56