1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
// RUN: %clang_cc1 -fmodules -std=c++17 -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s
#pragma clang module build A
module A {}
#pragma clang module contents
#pragma clang module begin A
template<typename T> T f(T v) {
v();
return v;
}
inline auto g() {
int n = 0;
return f([=] { return n; });
}
template<typename T> constexpr T f2(T v) {
v();
return v;
}
constexpr auto g2() {
int n = 0;
return f2([=] { return n; });
}
#pragma clang module end
#pragma clang module endbuild
#pragma clang module build B
module B {}
#pragma clang module contents
#pragma clang module begin B
template<typename T> T f(T v) {
v();
return v;
}
inline auto g() {
int n = 0;
return f([=] { return n; });
}
template<typename T> constexpr T f2(T v) {
v();
return v;
}
constexpr auto g2() {
int n = 0;
return f2([=] { return n; });
}
#pragma clang module end
#pragma clang module endbuild
#pragma clang module import A
#pragma clang module import B
// CHECK: define {{.*}}use_g
int use_g() {
return g()();
}
static_assert(g2()() == 0);
|