Debian Codegraph @

clang/test/CXX/basic/basic.link/p3.cpp

raw
1 // RUN: rm -rf %t
2 // RUN: split-file %s %t
3
4 // RUN: %clang_cc1 -std=c++20 -verify %t/M.cpp
5 // RUN: %clang_cc1 -std=c++20 -verify %t/ImportError1.cpp
6 // RUN: %clang_cc1 -std=c++20 -verify %t/ImportError2.cpp
7
8 //--- M.cpp
9 module;
10
11 struct import { struct inner {}; };
12 struct module { struct inner {}; };
13 constexpr int n = 123;
14
15 export module m; // #1
16 module y = {}; // expected-error {{multiple module declarations}} expected-error 2{{}}
17 // expected-note@#1 {{previous module declaration}}
18
19 ::import x = {};
20 ::module y = {};
21
22 import::inner xi = {};
23 module::inner yi = {};
24
25 namespace N {
26 module a;
27 import b;
28 }
29
30 extern "C++" module cxxm;
31 extern "C++" import cxxi;
32
33 template<typename T> module module_var_template;
34
35 // This is a variable named 'import' that shadows the type 'import' above.
36 struct X {} import;
37
38 //--- ImportError1.cpp
39 module;
40
41 struct import { struct inner {}; };
42 struct module { struct inner {}; };
43
44 constexpr int n = 123;
45
46 export module m; // #1
47
48 import x = {}; // expected-error {{expected ';' after module name}}
49 // expected-error@-1 {{module 'x' not found}}
50
51 //--- ImportError2.cpp
52 module;
53
54 struct module { struct inner {}; };
55
56 constexpr int n = 123;
57
58 export module m; // #1
59
60 struct X;
61 template<int> struct import;
62 template<> struct import<n> {
63 static X y;
64 };
65
66 // This is not valid because the 'import <n>' is a pp-import, even though it
67 // grammatically can't possibly be an import declaration.
68 struct X {} import<n>::y; // expected-error {{'n' file not found}}
69