Debian Codegraph @

clang/test/CXX/basic/basic.scope/basic.scope.namespace/p2.cpp

raw
1 // RUN: rm -rf %t
2 // RUN: split-file %s %t
3 // RUN: %clang_cc1 -std=c++2a -I%t -emit-module-interface %t/interface.cppm -o %t.pcm
4 // RUN: %clang_cc1 -std=c++2a -I%t -fmodule-file=A=%t.pcm %t/implA.cppm -verify -fno-modules-error-recovery
5 // RUN: %clang_cc1 -std=c++2a -I%t -fmodule-file=A=%t.pcm %t/implB.cppm -verify -fno-modules-error-recovery
6
7 //--- foo.h
8 #ifndef FOO_H
9 #define FOO_H
10 extern int in_header;
11 #endif
12
13 //--- interface.cppm
14 module;
15 #include "foo.h"
16 // FIXME: The following need to be moved to a header file. The global module
17 // fragment is only permitted to contain preprocessor directives.
18 int global_module_fragment;
19 export module A;
20 export int exported;
21 int not_exported;
22 static int internal;
23
24 module :private;
25 int not_exported_private;
26 static int internal_private;
27
28 //--- implA.cppm
29 module;
30
31 void test_early() {
32 in_header = 1; // expected-error {{use of undeclared identifier 'in_header'}}
33 // expected-note@* {{not visible}}
34
35 global_module_fragment = 1; // expected-error {{use of undeclared identifier 'global_module_fragment'}}
36
37 exported = 1; // expected-error {{use of undeclared identifier 'exported'}}
38
39 not_exported = 1; // expected-error {{use of undeclared identifier 'not_exported'}}
40
41 // FIXME: We need better diagnostic message for static variable.
42 internal = 1; // expected-error {{use of undeclared identifier 'internal'}}
43
44 not_exported_private = 1; // expected-error {{undeclared identifier}}
45
46 internal_private = 1; // expected-error {{undeclared identifier}}
47 }
48
49 module A;
50
51 void test_late() {
52 in_header = 1; // expected-error {{missing '#include "foo.h"'; 'in_header' must be declared before it is used}}
53 // expected-note@* {{not visible}}
54
55 global_module_fragment = 1; // expected-error {{missing '#include'; 'global_module_fragment' must be declared before it is used}}
56
57 exported = 1;
58
59 not_exported = 1;
60
61 internal = 1; // expected-error {{use of undeclared identifier 'internal'}}
62
63 not_exported_private = 1;
64
65 internal_private = 1; // expected-error {{use of undeclared identifier 'internal_private'}}
66 }
67
68 //--- implB.cppm
69 module;
70
71 void test_early() {
72 in_header = 1; // expected-error {{use of undeclared identifier 'in_header'}}
73 // expected-note@* {{not visible}}
74
75 global_module_fragment = 1; // expected-error {{use of undeclared identifier 'global_module_fragment'}}
76
77 exported = 1; // expected-error {{use of undeclared identifier 'exported'}}
78
79 not_exported = 1; // expected-error {{use of undeclared identifier 'not_exported'}}
80
81 // FIXME: We need better diagnostic message for static variable.
82 internal = 1; // expected-error {{use of undeclared identifier 'internal'}}
83
84 not_exported_private = 1; // expected-error {{undeclared identifier}}
85
86 internal_private = 1; // expected-error {{undeclared identifier}}
87 }
88
89 export module B;
90 import A;
91
92 void test_late() {
93 in_header = 1; // expected-error {{missing '#include "foo.h"'; 'in_header' must be declared before it is used}}
94 // expected-note@* {{not visible}}
95
96 global_module_fragment = 1; // expected-error {{missing '#include'; 'global_module_fragment' must be declared before it is used}}
97
98 exported = 1;
99
100 not_exported = 1; // expected-error {{use of undeclared identifier 'not_exported'; did you mean 'exported'?}}
101 // expected-note@* {{'exported' declared here}}
102
103 internal = 1; // expected-error {{use of undeclared identifier 'internal'}}
104
105 not_exported_private = 1;
106 // FIXME: should not be visible here
107 // expected-error@-2 {{undeclared identifier}}
108
109 internal_private = 1; // expected-error {{use of undeclared identifier 'internal_private'}}
110 }