Clang Project

clang_source_code/test/Modules/merge-lambdas.cpp
1// RUN: %clang_cc1 -std=c++14 -fmodules -verify %s -emit-llvm-only
2// expected-no-diagnostics
3
4#pragma clang module build A
5module A {}
6#pragma clang module contents
7#pragma clang module begin A
8template<typename T> auto f() { return []{}; }
9#pragma clang module end
10#pragma clang module endbuild
11
12#pragma clang module build B
13module B {}
14#pragma clang module contents
15#pragma clang module begin B
16#pragma clang module import A
17inline auto x1() { return f<int>(); }
18inline auto z() { return []{}; }
19inline auto x2() { return z(); }
20#pragma clang module end
21#pragma clang module endbuild
22
23#pragma clang module build C
24module C {}
25#pragma clang module contents
26#pragma clang module begin C
27#pragma clang module import A
28inline auto y1() { return f<int>(); }
29inline auto z() { return []{}; }
30inline auto y2() { return z(); }
31inline auto q() { return []{}; }
32inline auto y3() { return q(); }
33#pragma clang module end
34#pragma clang module endbuild
35
36inline auto q() { return []{}; }
37inline auto x3() { return q(); }
38
39#pragma clang module import B
40#pragma clang module import C
41using T = decltype(x1);
42using T = decltype(y1);
43
44using U = decltype(x2);
45using U = decltype(y2);
46
47using V = decltype(x3);
48using V = decltype(y3);
49
50#pragma clang module import A
51void (*p)() = f<int>();
52