| 1 |
// RUN: %clang_cc1 -std=c++14 -fmodules -verify %s -emit-llvm-only |
| 2 |
// expected-no-diagnostics |
| 3 |
|
| 4 |
#pragma clang module build A |
| 5 |
module A {} |
| 6 |
#pragma clang module contents |
| 7 |
#pragma clang module begin A |
| 8 |
template<typename T> auto f() { return []{}; } |
| 9 |
#pragma clang module end |
| 10 |
#pragma clang module endbuild |
| 11 |
|
| 12 |
#pragma clang module build B |
| 13 |
module B {} |
| 14 |
#pragma clang module contents |
| 15 |
#pragma clang module begin B |
| 16 |
#pragma clang module import A |
| 17 |
inline auto x1() { return f<int>(); } |
| 18 |
inline auto z() { return []{}; } |
| 19 |
inline auto x2() { return z(); } |
| 20 |
|
| 21 |
struct Function { |
| 22 |
template<typename T> |
| 23 |
Function(T t) : p(new T((T&&)t)) {} |
| 24 |
|
| 25 |
void *p; |
| 26 |
}; |
| 27 |
|
| 28 |
struct Outer { |
| 29 |
struct Inner { |
| 30 |
Inner() {} |
| 31 |
Function f = []{}; |
| 32 |
}; |
| 33 |
Outer(Inner = Inner()); |
| 34 |
}; |
| 35 |
|
| 36 |
inline void use_nested_1() { Outer o; } |
| 37 |
#pragma clang module end |
| 38 |
#pragma clang module endbuild |
| 39 |
|
| 40 |
#pragma clang module build C |
| 41 |
module C {} |
| 42 |
#pragma clang module contents |
| 43 |
#pragma clang module begin C |
| 44 |
#pragma clang module import A |
| 45 |
inline auto y1() { return f<int>(); } |
| 46 |
inline auto z() { return []{}; } |
| 47 |
inline auto y2() { return z(); } |
| 48 |
inline auto q() { return []{}; } |
| 49 |
inline auto y3() { return q(); } |
| 50 |
|
| 51 |
struct Function { |
| 52 |
template<typename T> |
| 53 |
Function(T t) : p(new T((T&&)t)) {} |
| 54 |
|
| 55 |
void *p; |
| 56 |
}; |
| 57 |
|
| 58 |
struct Outer { |
| 59 |
struct Inner { |
| 60 |
Inner() {} |
| 61 |
Function f = []{}; |
| 62 |
}; |
| 63 |
Outer(Inner = Inner()); |
| 64 |
}; |
| 65 |
|
| 66 |
inline void use_nested_2() { Outer o; } |
| 67 |
#pragma clang module end |
| 68 |
#pragma clang module endbuild |
| 69 |
|
| 70 |
inline auto q() { return []{}; } |
| 71 |
inline auto x3() { return q(); } |
| 72 |
|
| 73 |
#pragma clang module import B |
| 74 |
#pragma clang module import C |
| 75 |
using T = decltype(x1); |
| 76 |
using T = decltype(y1); |
| 77 |
|
| 78 |
using U = decltype(x2); |
| 79 |
using U = decltype(y2); |
| 80 |
|
| 81 |
using V = decltype(x3); |
| 82 |
using V = decltype(y3); |
| 83 |
|
| 84 |
#pragma clang module import A |
| 85 |
void (*p)() = f<int>(); |
| 86 |
|
| 87 |
void use_nested() { |
| 88 |
use_nested_1(); |
| 89 |
use_nested_2(); |
| 90 |
} |