165 lines · plain
1// RUN: rm -rf %t2// RUN: mkdir -p %t3// RUN: split-file %s %t4 5// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/module.cpp6// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -Wno-reserved-module-identifier %t/module.cpp7// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/import.cpp8// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -Wno-reserved-module-identifier %t/import.cpp9// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/_Test.cpp10// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -DNODIAGNOSTICS -Wno-reserved-module-identifier %t/_Test.cpp11// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/__test.cpp12// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -DNODIAGNOSTICS -Wno-reserved-module-identifier %t/__test.cpp13// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/te__st.cpp14// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -DNODIAGNOSTICS -Wno-reserved-module-identifier %t/te__st.cpp15// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/std.cpp16// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -Wno-reserved-module-identifier %t/std.cpp17// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/std.foo.cpp18// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -Wno-reserved-module-identifier %t/std.foo.cpp19// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/std0.cpp20// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -Wno-reserved-module-identifier %t/std0.cpp21// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/std1000000.cpp22// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -Wno-reserved-module-identifier %t/std1000000.cpp23// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/module.cppm24// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -Wno-reserved-module-identifier %t/module.cppm25// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/import.cppm26// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -Wno-reserved-module-identifier %t/import.cppm27// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/_Test.cppm28// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -DNODIAGNOSTICS -Wno-reserved-module-identifier %t/_Test.cppm29// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/__test.cppm30// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -DNODIAGNOSTICS -Wno-reserved-module-identifier %t/__test.cppm31// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/te__st.cppm32// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -DNODIAGNOSTICS -Wno-reserved-module-identifier %t/te__st.cppm33// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/std.cppm34// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -DNODIAGNOSTICS -Wno-reserved-module-identifier %t/std.cppm35// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/std.foo.cppm36// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -DNODIAGNOSTICS -Wno-reserved-module-identifier %t/std.foo.cppm37// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/std0.cppm38// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -DNODIAGNOSTICS -Wno-reserved-module-identifier %t/std0.cppm39// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/std1000000.cppm40// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -DNODIAGNOSTICS -Wno-reserved-module-identifier %t/std1000000.cppm41// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/should_diag._Test.cppm42// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -DNODIAGNOSTICS -Wno-reserved-module-identifier %t/should_diag._Test.cppm43// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/system-module.cppm44// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -Wno-reserved-module-identifier %t/system-module.cppm45// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/system._Test.import.cppm46// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -Wno-reserved-module-identifier %t/system._Test.import.cppm47// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,loud %t/user.cpp48// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected -Wno-reserved-module-identifier %t/user.cpp49 50//--- module.cpp51module module; // expected-error {{'module' is an invalid name for a module}}52 53//--- import.cpp54module import; // expected-error {{'import' is an invalid name for a module}}55 56//--- _Test.cpp57module _Test; // loud-warning {{'_Test' is a reserved name for a module}} \58 // expected-error {{module '_Test' not found}}59 60//--- __test.cpp61module __test; // loud-warning {{'__test' is a reserved name for a module}} \62 // expected-error {{module '__test' not found}}63 64//--- te__st.cpp65module te__st; // loud-warning {{'te__st' is a reserved name for a module}} \66 // expected-error {{module 'te__st' not found}}67 68//--- std.cpp69module std; // loud-warning {{'std' is a reserved name for a module}} \70 // expected-error {{module 'std' not found}}71 72//--- std.foo.cpp73module std.foo; // loud-warning {{'std' is a reserved name for a module}} \74 // expected-error {{module 'std.foo' not found}}75 76//--- std0.cpp77module std0; // loud-warning {{'std0' is a reserved name for a module}} \78 // expected-error {{module 'std0' not found}}79 80//--- std1000000.cpp81module std1000000; // loud-warning {{'std1000000' is a reserved name for a module}} \82 // expected-error {{module 'std1000000' not found}}83 84//--- module.cppm85export module module; // expected-error {{'module' is an invalid name for a module}}86 87//--- import.cppm88export module import; // expected-error {{'import' is an invalid name for a module}}89 90//--- _Test.cppm91module;92#ifdef NODIAGNOSTICS93// expected-no-diagnostics94#endif95export module _Test; // loud-warning {{'_Test' is a reserved name for a module}}96 97//--- __test.cppm98module;99#ifdef NODIAGNOSTICS100// expected-no-diagnostics101#endif102export module __test; // loud-warning {{'__test' is a reserved name for a module}}103export int a = 43;104 105//--- te__st.cppm106module;107#ifdef NODIAGNOSTICS108// expected-no-diagnostics109#endif110export module te__st; // loud-warning {{'te__st' is a reserved name for a module}}111export int a = 43;112 113//--- std.cppm114module;115#ifdef NODIAGNOSTICS116// expected-no-diagnostics117#endif118export module std; // loud-warning {{'std' is a reserved name for a module}}119 120export int a = 43;121 122//--- std.foo.cppm123module;124#ifdef NODIAGNOSTICS125// expected-no-diagnostics126#endif127export module std.foo;// loud-warning {{'std' is a reserved name for a module}}128 129//--- std0.cppm130module;131#ifdef NODIAGNOSTICS132// expected-no-diagnostics133#endif134export module std0; // loud-warning {{'std0' is a reserved name for a module}}135 136//--- std1000000.cppm137module;138#ifdef NODIAGNOSTICS139// expected-no-diagnostics140#endif141export module std1000000; // loud-warning {{'std1000000' is a reserved name for a module}}142 143//--- should_diag._Test.cppm144module;145#ifdef NODIAGNOSTICS146// expected-no-diagnostics147#endif148export module should_diag._Test; // loud-warning {{'_Test' is a reserved name for a module}}149 150//--- system-module.cppm151module; // expected-error {{missing 'module' declaration at end of global module fragment introduced here}}152// Show that being in a system header doesn't save you from diagnostics about153// use of an invalid module-name identifier.154# 34 "reserved-names-1.cpp" 1 3155export module module; // expected-error {{'module' is an invalid name for a module}}156 157//--- system._Test.import.cppm158module; // expected-error {{missing 'module' declaration at end of global module fragment introduced here}}159# 34 "reserved-names-1.cpp" 1 3160export module _Test.import; // expected-error {{'import' is an invalid name for a module}}161 162//--- user.cpp163// We can still use a reserved name on imoport.164import std; // expected-error {{module 'std' not found}}165