Debian Codegraph @

clang/test/Modules/pr131058.cppm

raw
1 // RUN: rm -rf %t
2 // RUN: mkdir -p %t
3 // RUN: split-file %s %t
4 //
5 // RUN: %clang_cc1 -std=c++20 %t/M.cppm -emit-module-interface -o %t/M.pcm
6 // RUN: %clang_cc1 -std=c++20 %t/use.cpp -fsyntax-only -verify -fprebuilt-module-path=%t
7
8 // RUN: %clang_cc1 -std=c++20 %t/M.cppm -emit-reduced-module-interface -o %t/M.pcm
9 // RUN: %clang_cc1 -std=c++20 %t/use.cpp -fsyntax-only -verify -fprebuilt-module-path=%t
10
11 // RUN: %clang_cc1 -std=c++20 %t/M0.cppm -emit-module-interface -o %t/M.pcm
12 // RUN: %clang_cc1 -std=c++20 %t/use.cpp -fsyntax-only -verify -fprebuilt-module-path=%t -DMODULE_LOCAL
13 // RUN: %clang_cc1 -std=c++20 %t/M0.cpp -fsyntax-only -verify -fprebuilt-module-path=%t
14
15 // RUN: %clang_cc1 -std=c++20 %t/M0.cppm -emit-reduced-module-interface -o %t/M.pcm
16 // RUN: %clang_cc1 -std=c++20 %t/use.cpp -fsyntax-only -verify -fprebuilt-module-path=%t -DMODULE_LOCAL
17 // RUN: %clang_cc1 -std=c++20 %t/M0.cpp -fsyntax-only -verify -fprebuilt-module-path=%t
18
19 // RUN: %clang_cc1 -std=c++20 %t/M2.cppm -emit-module-interface -o %t/M.pcm
20 // RUN: %clang_cc1 -std=c++20 %t/use.cpp -fsyntax-only -verify -fprebuilt-module-path=%t
21
22 // RUN: %clang_cc1 -std=c++20 %t/M2.cppm -emit-reduced-module-interface -o %t/M.pcm
23 // RUN: %clang_cc1 -std=c++20 %t/use.cpp -fsyntax-only -verify -fprebuilt-module-path=%t
24
25 // RUN: %clang_cc1 -std=c++20 %t/M3.cppm -emit-reduced-module-interface -o %t/M.pcm
26 // RUN: %clang_cc1 -std=c++20 %t/use2.cpp -fsyntax-only -verify -fprebuilt-module-path=%t
27
28 //--- enum.h
29 enum { SomeName, };
30
31 //--- M.cppm
32 module;
33 #include "enum.h"
34 export module M;
35 export auto e = SomeName;
36
37 //--- M0.cppm
38 export module M;
39 enum { SomeName, };
40 export auto e = SomeName;
41
42 //--- M0.cpp
43 // expected-no-diagnostics
44 module M;
45 auto a = SomeName;
46
47 //--- use.cpp
48 import M;
49 auto a = SomeName; // expected-error {{use of undeclared identifier 'SomeName'}}
50 auto b = decltype(e)::SomeName;
51
52 //--- enum1.h
53 extern "C++" {
54 enum { SomeName, };
55 }
56
57 //--- M2.cppm
58 module;
59 #include "enum1.h"
60 export module M;
61 export auto e = SomeName;
62
63 //--- enums.h
64 namespace nn {
65 enum E { Value };
66 enum E2 { VisibleEnum };
67 enum AlwaysVisibleEnums { UnconditionallyVisible };
68 }
69
70 //--- M3.cppm
71 module;
72 #include "enums.h"
73 export module M;
74 export namespace nn {
75 using nn::E2::VisibleEnum;
76 using nn::AlwaysVisibleEnums;
77 }
78 auto e1 = nn::Value;
79 auto e2 = nn::VisibleEnum;
80
81 //--- use2.cpp
82 import M;
83 auto e = nn::Value1; // expected-error {{no member named 'Value1' in namespace 'nn'}}
84 auto e2 = nn::VisibleEnum;
85 auto e3 = nn::UnconditionallyVisible;