3 // RUN: split-file %s %t
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
51 module module; // expected-error {{'module' is an invalid name for a module}}
54 module import; // expected-error {{'import' is an invalid name for a module}}
57 module _Test; // loud-warning {{'_Test' is a reserved name for a module}} \
58 // expected-error {{module '_Test' not found}}
61 module __test; // loud-warning {{'__test' is a reserved name for a module}} \
62 // expected-error {{module '__test' not found}}
65 module te__st; // loud-warning {{'te__st' is a reserved name for a module}} \
66 // expected-error {{module 'te__st' not found}}
69 module std; // loud-warning {{'std' is a reserved name for a module}} \
70 // expected-error {{module 'std' not found}}
73 module std.foo; // loud-warning {{'std' is a reserved name for a module}} \
74 // expected-error {{module 'std.foo' not found}}
77 module std0; // loud-warning {{'std0' is a reserved name for a module}} \
78 // expected-error {{module 'std0' not found}}
81 module std1000000; // loud-warning {{'std1000000' is a reserved name for a module}} \
82 // expected-error {{module 'std1000000' not found}}
85 export module module; // expected-error {{'module' is an invalid name for a module}}
88 export module import; // expected-error {{'import' is an invalid name for a module}}
92 // expected-no-diagnostics
94 export module _Test; // loud-warning {{'_Test' is a reserved name for a module}}
98 // expected-no-diagnostics
100 export module __test; // loud-warning {{'__test' is a reserved name for a module}}
105 // expected-no-diagnostics
107 export module te__st; // loud-warning {{'te__st' is a reserved name for a module}}
112 // expected-no-diagnostics
114 export module std; // loud-warning {{'std' is a reserved name for a module}}
120 // expected-no-diagnostics
122 export module std.foo;// loud-warning {{'std' is a reserved name for a module}}
126 // expected-no-diagnostics
128 export module std0; // loud-warning {{'std0' is a reserved name for a module}}
130 //--- std1000000.cppm
132 // expected-no-diagnostics
134 export module std1000000; // loud-warning {{'std1000000' is a reserved name for a module}}
136 //--- should_diag._Test.cppm
138 // expected-no-diagnostics
140 export module should_diag._Test; // loud-warning {{'_Test' is a reserved name for a module}}
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
146 export module module; // expected-error {{'module' is an invalid name for a module}}
148 //--- system._Test.import.cppm
149 # 34 "reserved-names-1.cpp" 1 3
150 export module _Test.import; // expected-error {{'import' is an invalid name for a module}}
153 // We can still use a reserved name on imoport.
154 import std; // expected-error {{module 'std' not found}}