xref: /llvm-project/clang/test/Modules/pr90259.cppm (revision 38067c50a9459caed2892e38b2ae5026a8bff8e2)
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/mod1.cppm -emit-reduced-module-interface -o %t/mod-mod1.pcm
6// RUN: %clang_cc1 -std=c++20 %t/mod.cppm -fprebuilt-module-path=%t  \
7// RUN:     -emit-reduced-module-interface -o %t/mod.pcm
8// RUN: %clang_cc1 -std=c++20 %t/use.cpp -fprebuilt-module-path=%t -verify -fsyntax-only
9
10//--- mod1.cppm
11export module mod:mod1;
12namespace {
13    int abc = 43;
14}
15namespace mod {
16    static int def = 44;
17}
18export int f() {
19    return abc + mod::def;
20}
21
22//--- mod.cppm
23// expected-no-diagnostics
24export module mod;
25import :mod1;
26
27namespace {
28    double abc = 43.0;
29}
30
31namespace mod {
32    static double def = 44.0;
33}
34
35export double func() {
36    return (double)f() + abc + mod::def;
37}
38
39//--- use.cpp
40// expected-no-diagnostics
41import mod;
42double use() {
43    return func();
44}
45