| 1 |
// { dg-additional-options "-fmodules-ts -Wtemplate-names-tu-local" } |
| 2 |
// Non-ODR usages of const variables currently are erroneously |
| 3 |
// reported in templates and constexpr functions; this test |
| 4 |
// XFAILS them until we can implement a fix. |
| 5 |
|
| 6 |
export module M; |
| 7 |
|
| 8 |
namespace { struct internal_t {}; }; |
| 9 |
static const int value = 123; |
| 10 |
static const int& ref = 456; |
| 11 |
static const internal_t internal {}; |
| 12 |
|
| 13 |
constexpr void f(int) {} |
| 14 |
|
| 15 |
export constexpr |
| 16 |
void no_odr_use_cexpr() { // { dg-bogus "TU-local" "" { xfail *-*-* } } |
| 17 |
int x = value; |
| 18 |
int y = ref; |
| 19 |
int z = (internal, 0); |
| 20 |
|
| 21 |
value; |
| 22 |
bool b = value < value; |
| 23 |
f(value); |
| 24 |
} |
| 25 |
|
| 26 |
export template <typename T> |
| 27 |
void no_odr_use_templ() { // { dg-bogus "TU-local" "" { xfail *-*-* } } |
| 28 |
int x = value; |
| 29 |
int y = ref; |
| 30 |
int z = (internal, 0); |
| 31 |
|
| 32 |
value; |
| 33 |
bool b = value < value; |
| 34 |
f(value); |
| 35 |
} |