1
- // RUN: %clang_cc1 -std=c++2a -verify %s
2
- // RUN: %clang_cc1 -std=c++2a -verify %s -DIMPORT_ERROR=1
3
- // RUN: %clang_cc1 -std=c++2a -verify %s -DIMPORT_ERROR=2
1
+ // RUN: rm -rf %t
2
+ // RUN: split-file %s %t
4
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
5
9
module ;
6
10
7
- #if IMPORT_ERROR != 2
8
11
struct import { struct inner {}; };
9
- #endif
10
12
struct module { struct inner {}; };
11
-
12
13
constexpr int n = 123 ;
13
14
14
15
export module m; // #1
15
-
16
- // Import errors are fatal, so we test them in isolation.
17
- #if IMPORT_ERROR == 1
18
- import x = {}; // expected-error {{expected ';' after module name}}
19
- // expected-error@-1 {{module 'x' not found}}
20
-
21
- #elif IMPORT_ERROR == 2
22
- struct X ;
23
- template <int > struct import ;
24
- template <> struct import <n> {
25
- static X y;
26
- };
27
-
28
- // This is not valid because the 'import <n>' is a pp-import, even though it
29
- // grammatically can't possibly be an import declaration.
30
- struct X {} import <n>::y; // expected-error {{'n' file not found}}
31
-
32
- #else
33
16
module y = {}; // expected-error {{multiple module declarations}} expected-error 2{{}}
34
17
// expected-note@#1 {{previous module declaration}}
35
18
@@ -51,4 +34,36 @@ template<typename T> module module_var_template;
51
34
52
35
// This is a variable named 'import' that shadows the type 'import' above.
53
36
struct X {} import ;
54
- #endif
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
+
0 commit comments