Debian Codegraph @

clang/test/Modules/pr125521.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/mod2.cppm -emit-module-interface -o %t/mod2.pcm
6 // RUN: %clang_cc1 -std=c++20 %t/mod1.cppm -emit-module-interface -o %t/mod1.pcm \
7 // RUN: -fmodule-file=Mod2=%t/mod2.pcm
8 // RUN: %clang_cc1 -std=c++20 %t/test.cc -fmodule-file=Mod2=%t/mod2.pcm -fmodule-file=Mod=%t/mod1.pcm \
9 // RUN: -fsyntax-only -verify
10
11 // RUN: %clang_cc1 -std=c++20 %t/mod2.cppm -emit-module-interface -o %t/mod2.pcm
12 // RUN: %clang_cc1 -std=c++20 %t/mod1.cppm -emit-module-interface -o %t/mod1.pcm \
13 // RUN: -fmodule-file=Mod2=%t/mod2.pcm
14 // RUN: %clang_cc1 -std=c++20 %t/mod1.pcm -fmodule-file=Mod2=%t/mod2.pcm -emit-llvm -o - \
15 // RUN: | FileCheck %t/mod1.cppm
16
17 //--- hello.h
18 template <typename V> int get() noexcept {return 0;};
19
20 template <typename T>
21 class List
22 {
23 template <typename V> friend int get() noexcept;
24 };
25
26 //--- mod2.cppm
27 module;
28 #include "hello.h"
29 export module Mod2;
30 export const char *modFn2() {
31 List<int> a;
32 return "hello";
33 }
34
35 //--- mod1.cppm
36 module;
37 #include "hello.h"
38 export module Mod;
39 import Mod2;
40 export extern "C" const char *modFn() {
41 List<int> a;
42 List<double> b;
43 return modFn2();
44 }
45
46 // Fine enough to check it won't crash.
47 // CHECK: define {{.*}}@modFn
48
49 //--- test.cc
50 // expected-no-diagnostics
51 import Mod;
52 import Mod2;
53
54 void test() {
55 modFn();
56 modFn2();
57 }