1 // Tests for module-declaration syntax. 2 // 3 // RUN: rm -rf %t 4 // RUN: mkdir %t 5 // RUN: split-file %s %t 6 // 7 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/x.cppm -o %t/x.pcm 8 // RUN: %clang_cc1 -std=c++20 -emit-module-interface -fmodule-file=x=%t/x.pcm %t/x.y.cppm -o %t/x.y.pcm 9 // 10 // Module implementation for unknown and known module. (The former is ill-formed.) 11 // RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x.y=%t/x.y.pcm -verify -x c++ %t/M.cpp \ 12 // RUN: -DTEST=1 -DEXPORT= -DMODULE_NAME=z 13 // RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x=%t/x.pcm -fmodule-file=x.y=%t/x.y.pcm -verify -x c++ %t/M.cpp \ 14 // RUN: -DTEST=2 -DEXPORT= -DMODULE_NAME=x 15 // 16 // Module interface for unknown and known module. (The latter is ill-formed due to 17 // redefinition.) 18 // RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x.y=%t/x.y.pcm -verify %t/M.cpp \ 19 // RUN: -DTEST=3 -DEXPORT=export -DMODULE_NAME=z 20 // RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x.y=%t/x.y.pcm -verify %t/M.cpp \ 21 // RUN: -DTEST=4 -DEXPORT=export -DMODULE_NAME=x 22 // 23 // Miscellaneous syntax. 24 // RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x.y=%t/x.y.pcm -verify %t/M.cpp \ 25 // RUN: -DTEST=7 -DEXPORT=export -DMODULE_NAME='z elderberry' 26 // RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x.y=%t/x.y.pcm -verify %t/M.cpp \ 27 // RUN: -DTEST=8 -DEXPORT=export -DMODULE_NAME='z [[]]' 28 // RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x.y=%t/x.y.pcm -verify %t/M.cpp \ 29 // RUN: -DTEST=9 -DEXPORT=export -DMODULE_NAME='z [[fancy]]' 30 // RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x.y=%t/x.y.pcm -verify %t/M.cpp \ 31 // RUN: -DTEST=10 -DEXPORT=export -DMODULE_NAME='z [[maybe_unused]]' 32 33 //--- x.cppm 34 export module x; 35 int a, b; 36 37 //--- x.y.cppm 38 export module x.y; 39 int c; 40 41 //--- M.cpp 42 43 EXPORT module MODULE_NAME; 44 #if TEST == 7 45 // expected-error@-2 {{expected ';'}} expected-error@-2 {{a type specifier is required}} 46 #elif TEST == 9 47 // expected-warning@-4 {{unknown attribute 'fancy' ignored}} 48 #elif TEST == 10 49 // expected-error-re@-6 {{'maybe_unused' attribute cannot be applied to a module{{$}}}} 50 #elif TEST == 1 51 // expected-error@-8 {{module 'z' not found}} 52 #else 53 // expected-no-diagnostics 54 #endif 55