| 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/z_impl.cppm |
| 12 |
// 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.cppm |
| 13 |
// |
| 14 |
// Module interface for unknown and known module. (The latter is ill-formed due to |
| 15 |
// redefinition.) |
| 16 |
// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x.y=%t/x.y.pcm -verify %t/z_interface.cppm |
| 17 |
// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x.y=%t/x.y.pcm -verify %t/x_interface.cppm |
| 18 |
// |
| 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.cppm |
| 21 |
// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x.y=%t/x.y.pcm -verify %t/empty_attribute.cppm |
| 22 |
// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x.y=%t/x.y.pcm -verify %t/fancy_attribute.cppm |
| 23 |
// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x.y=%t/x.y.pcm -verify %t/maybe_unused_attribute.cppm |
| 24 |
|
| 25 |
//--- x.cppm |
| 26 |
export module x; |
| 27 |
int a, b; |
| 28 |
|
| 29 |
//--- x.y.cppm |
| 30 |
export module x.y; |
| 31 |
int c; |
| 32 |
|
| 33 |
//--- z_impl.cppm |
| 34 |
module z; // expected-error {{module 'z' not found}} |
| 35 |
|
| 36 |
//--- x_impl.cppm |
| 37 |
// expected-no-diagnostics |
| 38 |
module x; |
| 39 |
|
| 40 |
//--- z_interface.cppm |
| 41 |
// expected-no-diagnostics |
| 42 |
export module z; |
| 43 |
|
| 44 |
//--- x_interface.cppm |
| 45 |
// expected-no-diagnostics |
| 46 |
export module x; |
| 47 |
|
| 48 |
//--- invalid_module_name.cppm |
| 49 |
export module z elderberry; // expected-error {{expected ';'}} \ |
| 50 |
// expected-error {{a type specifier is required}} |
| 51 |
|
| 52 |
//--- empty_attribute.cppm |
| 53 |
// expected-no-diagnostics |
| 54 |
export module z [[]]; |
| 55 |
|
| 56 |
//--- fancy_attribute.cppm |
| 57 |
export module z [[fancy]]; // expected-warning {{unknown attribute 'fancy' ignored}} |
| 58 |
|
| 59 |
//--- maybe_unused_attribute.cppm |
| 60 |
export module z [[maybe_unused]]; // expected-error-re {{'maybe_unused' attribute cannot be applied to a module{{$}}}} |