61 lines · cpp
1// Tests for module-declaration syntax.2//3// RUN: rm -rf %t4// RUN: mkdir %t5// RUN: split-file %s %t6//7// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/x.cppm -o %t/x.pcm8// RUN: %clang_cc1 -std=c++20 -emit-module-interface -fmodule-file=x=%t/x.pcm %t/x.y.cppm -o %t/x.y.pcm9//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/z_impl.cppm12// 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/x_impl.cppm13//14// Module interface for unknown and known module. (The latter is ill-formed due to15// redefinition.)16// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x.y=%t/x.y.pcm -verify %t/z_interface.cppm17// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x.y=%t/x.y.pcm -verify %t/x_interface.cppm18//19// Miscellaneous syntax.20// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x.y=%t/x.y.pcm -verify %t/invalid_module_name.cppm21// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x.y=%t/x.y.pcm -verify %t/empty_attribute.cppm22// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x.y=%t/x.y.pcm -verify %t/fancy_attribute.cppm23// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x.y=%t/x.y.pcm -verify %t/maybe_unused_attribute.cppm24 25//--- x.cppm26export module x;27int a, b;28 29//--- x.y.cppm30export module x.y;31int c;32 33//--- z_impl.cppm34module z; // expected-error {{module 'z' not found}}35 36//--- x_impl.cppm37// expected-no-diagnostics38module x;39 40//--- z_interface.cppm41// expected-no-diagnostics42export module z;43 44//--- x_interface.cppm45// expected-no-diagnostics46export module x;47 48//--- invalid_module_name.cppm49export module z elderberry; // expected-error {{expected ';'}} \50 // expected-error {{a type specifier is required}}51 52//--- empty_attribute.cppm53// expected-no-diagnostics54export module z [[]];55 56//--- fancy_attribute.cppm57export module z [[fancy]]; // expected-warning {{unknown attribute 'fancy' ignored}}58 59//--- maybe_unused_attribute.cppm60export module z [[maybe_unused]]; // expected-error-re {{'maybe_unused' attribute cannot be applied to a module{{$}}}}61