1// RUN: rm -rf %t 2// RUN: mkdir -p %t 3// RUN: split-file %s %t 4 5// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/module.cpp 6// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -Wno-reserved-module-identifier %t/module.cpp 7// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/import.cpp 8// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -Wno-reserved-module-identifier %t/import.cpp 9// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/_Test.cpp 10// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -DNODIAGNOSTICS -Wno-reserved-module-identifier %t/_Test.cpp 11// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/__test.cpp 12// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -DNODIAGNOSTICS -Wno-reserved-module-identifier %t/__test.cpp 13// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/te__st.cpp 14// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -DNODIAGNOSTICS -Wno-reserved-module-identifier %t/te__st.cpp 15// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/std.cpp 16// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -Wno-reserved-module-identifier %t/std.cpp 17// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/std.foo.cpp 18// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -Wno-reserved-module-identifier %t/std.foo.cpp 19// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/std0.cpp 20// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -Wno-reserved-module-identifier %t/std0.cpp 21// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/std1000000.cpp 22// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -Wno-reserved-module-identifier %t/std1000000.cpp 23// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/module.cppm 24// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -Wno-reserved-module-identifier %t/module.cppm 25// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/import.cppm 26// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -Wno-reserved-module-identifier %t/import.cppm 27// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/_Test.cppm 28// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -DNODIAGNOSTICS -Wno-reserved-module-identifier %t/_Test.cppm 29// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/__test.cppm 30// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -DNODIAGNOSTICS -Wno-reserved-module-identifier %t/__test.cppm 31// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/te__st.cppm 32// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -DNODIAGNOSTICS -Wno-reserved-module-identifier %t/te__st.cppm 33// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/std.cppm 34// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -DNODIAGNOSTICS -Wno-reserved-module-identifier %t/std.cppm 35// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/std.foo.cppm 36// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -DNODIAGNOSTICS -Wno-reserved-module-identifier %t/std.foo.cppm 37// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/std0.cppm 38// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -DNODIAGNOSTICS -Wno-reserved-module-identifier %t/std0.cppm 39// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/std1000000.cppm 40// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -DNODIAGNOSTICS -Wno-reserved-module-identifier %t/std1000000.cppm 41// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/should_diag._Test.cppm 42// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -DNODIAGNOSTICS -Wno-reserved-module-identifier %t/should_diag._Test.cppm 43// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/system-module.cppm 44// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -Wno-reserved-module-identifier %t/system-module.cppm 45// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/system._Test.import.cppm 46// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -Wno-reserved-module-identifier %t/system._Test.import.cppm 47// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/user.cpp 48// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -Wno-reserved-module-identifier %t/user.cpp 49 50//--- module.cpp 51module module; // expected-error {{'module' is an invalid name for a module}} 52 53//--- import.cpp 54module import; // expected-error {{'import' is an invalid name for a module}} 55 56//--- _Test.cpp 57module _Test; // loud-warning {{'_Test' is a reserved name for a module}} \ 58 // expected-error {{module '_Test' not found}} 59 60//--- __test.cpp 61module __test; // loud-warning {{'__test' is a reserved name for a module}} \ 62 // expected-error {{module '__test' not found}} 63 64//--- te__st.cpp 65module te__st; // loud-warning {{'te__st' is a reserved name for a module}} \ 66 // expected-error {{module 'te__st' not found}} 67 68//--- std.cpp 69module std; // loud-warning {{'std' is a reserved name for a module}} \ 70 // expected-error {{module 'std' not found}} 71 72//--- std.foo.cpp 73module std.foo; // loud-warning {{'std' is a reserved name for a module}} \ 74 // expected-error {{module 'std.foo' not found}} 75 76//--- std0.cpp 77module std0; // loud-warning {{'std0' is a reserved name for a module}} \ 78 // expected-error {{module 'std0' not found}} 79 80//--- std1000000.cpp 81module std1000000; // loud-warning {{'std1000000' is a reserved name for a module}} \ 82 // expected-error {{module 'std1000000' not found}} 83 84//--- module.cppm 85export module module; // expected-error {{'module' is an invalid name for a module}} 86 87//--- import.cppm 88export module import; // expected-error {{'import' is an invalid name for a module}} 89 90//--- _Test.cppm 91#ifdef NODIAGNOSTICS 92// expected-no-diagnostics 93#endif 94export module _Test; // loud-warning {{'_Test' is a reserved name for a module}} 95 96//--- __test.cppm 97#ifdef NODIAGNOSTICS 98// expected-no-diagnostics 99#endif 100export module __test; // loud-warning {{'__test' is a reserved name for a module}} 101export int a = 43; 102 103//--- te__st.cppm 104#ifdef NODIAGNOSTICS 105// expected-no-diagnostics 106#endif 107export module te__st; // loud-warning {{'te__st' is a reserved name for a module}} 108export int a = 43; 109 110//--- std.cppm 111#ifdef NODIAGNOSTICS 112// expected-no-diagnostics 113#endif 114export module std; // loud-warning {{'std' is a reserved name for a module}} 115 116export int a = 43; 117 118//--- std.foo.cppm 119#ifdef NODIAGNOSTICS 120// expected-no-diagnostics 121#endif 122export module std.foo;// loud-warning {{'std' is a reserved name for a module}} 123 124//--- std0.cppm 125#ifdef NODIAGNOSTICS 126// expected-no-diagnostics 127#endif 128export module std0; // loud-warning {{'std0' is a reserved name for a module}} 129 130//--- std1000000.cppm 131#ifdef NODIAGNOSTICS 132// expected-no-diagnostics 133#endif 134export module std1000000; // loud-warning {{'std1000000' is a reserved name for a module}} 135 136//--- should_diag._Test.cppm 137#ifdef NODIAGNOSTICS 138// expected-no-diagnostics 139#endif 140export module should_diag._Test; // loud-warning {{'_Test' is a reserved name for a module}} 141 142//--- system-module.cppm 143// Show that being in a system header doesn't save you from diagnostics about 144// use of an invalid module-name identifier. 145# 34 "reserved-names-1.cpp" 1 3 146export module module; // expected-error {{'module' is an invalid name for a module}} 147 148//--- system._Test.import.cppm 149# 34 "reserved-names-1.cpp" 1 3 150export module _Test.import; // expected-error {{'import' is an invalid name for a module}} 151 152//--- user.cpp 153// We can still use a reserved name on imoport. 154import std; // expected-error {{module 'std' not found}} 155