| 1 |
// Test that we handle T{} differently between class non-type template |
| 2 |
// arguments and other expressions in the signature. |
| 3 |
|
| 4 |
// { dg-do compile { target c++20 } } |
| 5 |
// { dg-additional-options -fabi-compat-version=0 } |
| 6 |
|
| 7 |
struct B |
| 8 |
{ |
| 9 |
int i; |
| 10 |
constexpr B(int i): i(i+1) {} |
| 11 |
}; |
| 12 |
|
| 13 |
struct A |
| 14 |
{ |
| 15 |
B b; |
| 16 |
}; |
| 17 |
|
| 18 |
template <class T, class... Ts> T sink(T&&, Ts&&...); |
| 19 |
|
| 20 |
// Here A{1} is mangled as A{1}, the source representation, because expressions |
| 21 |
// involving template parameters are compared by ODR (token-based) equivalence |
| 22 |
// [temp.over.link]. |
| 23 |
// { dg-final { scan-assembler "_Z1fIiEDTcl4sinktl1ALi1EEcvT__EEES1_" } } |
| 24 |
template <class T> |
| 25 |
decltype(sink(A{1},T())) f(T) { return A{1}; } |
| 26 |
int main() { f(42); } |
| 27 |
|
| 28 |
template <auto> struct C { }; |
| 29 |
// Here A{1} is mangled as A{B{2}}, the value representation, because template |
| 30 |
// arguments are compared by value. |
| 31 |
// { dg-final { scan-assembler "_Z1g1CIXtl1Atl1BLi2EEEEE" } } |
| 32 |
void g(C<A{1}>) { } |