| 1 |
// { dg-additional-options "-fmodules-ts" } |
| 2 |
// { dg-module-cmi !M } |
| 3 |
// Exposures (or not) of TU-local values |
| 4 |
|
| 5 |
export module M; |
| 6 |
|
| 7 |
static void f() {} |
| 8 |
auto& fr = f; // OK |
| 9 |
constexpr auto& fr2 = fr; // { dg-error "initialized to a TU-local value" } |
| 10 |
static constexpr auto fp2 = fr; // OK |
| 11 |
|
| 12 |
struct S { void (&ref)(); } s{ f }; // OK, value is TU-local |
| 13 |
constexpr extern struct W { S& s; } wrap{ s }; // OK, value is not TU-local |
| 14 |
constexpr S s2{ f }; // { dg-error "initialized to a TU-local value" } |
| 15 |
|
| 16 |
constexpr int a = 123; |
| 17 |
static constexpr int b = 456; |
| 18 |
struct X { |
| 19 |
union { |
| 20 |
const int* p[2]; |
| 21 |
}; |
| 22 |
}; |
| 23 |
constexpr X x { &a }; // OK |
| 24 |
constexpr X y { &a, &b }; // { dg-error "initialized to a TU-local value" } |