File: reserved-names-1.cpp

package info (click to toggle)
llvm-toolchain-16 1%3A16.0.6-15~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,634,792 kB
  • sloc: cpp: 6,179,261; ansic: 1,216,205; asm: 741,319; python: 196,614; objc: 75,325; f90: 49,640; lisp: 32,396; pascal: 12,286; sh: 9,394; perl: 7,442; ml: 5,494; awk: 3,523; makefile: 2,723; javascript: 1,206; xml: 886; fortran: 581; cs: 573
file content (45 lines) | stat: -rw-r--r-- 3,499 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s

// expected-note@1 15{{add 'module;' to the start of the file to introduce a global module fragment}}

module std;    // expected-error {{'std' is a reserved name for a module}}
module _Test;  // expected-error {{'_Test' is a reserved name for a module}} \
                  expected-error {{module declaration must occur at the start of the translation unit}}
module module; // expected-error {{'module' is an invalid name for a module}} \
                  expected-error {{module declaration must occur at the start of the translation unit}}
module std0;   // expected-error {{'std0' is a reserved name for a module}} \
                  expected-error {{module declaration must occur at the start of the translation unit}}

export module module; // expected-error {{'module' is an invalid name for a module}} \
                         expected-error {{module declaration must occur at the start of the translation unit}}
export module import; // expected-error {{'import' is an invalid name for a module}} \
                         expected-error {{module declaration must occur at the start of the translation unit}}
export module _Test;  // expected-error {{'_Test' is a reserved name for a module}} \
                         expected-error {{module declaration must occur at the start of the translation unit}}
export module __test; // expected-error {{'__test' is a reserved name for a module}} \
                         expected-error {{module declaration must occur at the start of the translation unit}}
export module te__st; // expected-error {{'te__st' is a reserved name for a module}} \
                         expected-error {{module declaration must occur at the start of the translation unit}}
export module std;    // expected-error {{'std' is a reserved name for a module}} \
                         expected-error {{module declaration must occur at the start of the translation unit}}
export module std.foo;// expected-error {{'std' is a reserved name for a module}} \
                         expected-error {{module declaration must occur at the start of the translation unit}}
export module std0;   // expected-error {{'std0' is a reserved name for a module}} \
                         expected-error {{module declaration must occur at the start of the translation unit}}
export module std1000000; // expected-error {{'std1000000' is a reserved name for a module}} \
                         expected-error {{module declaration must occur at the start of the translation unit}}
export module should_fail._Test; // expected-error {{'_Test' is a reserved name for a module}} \
                                    expected-error {{module declaration must occur at the start of the translation unit}}

// Show that being in a system header doesn't save you from diagnostics about
// use of an invalid module-name identifier.
# 34 "reserved-names-1.cpp" 1 3
export module module;       // expected-error {{'module' is an invalid name for a module}} \
                               expected-error {{module declaration must occur at the start of the translation unit}}

export module _Test.import; // expected-error {{'import' is an invalid name for a module}} \
                               expected-error {{module declaration must occur at the start of the translation unit}}
# 39 "reserved-names-1.cpp" 2 3

// We can still use a reserved name on imoport.
import std; // expected-error {{module 'std' not found}}