| 1 |
// PR c++/97518 |
| 2 |
// { dg-do compile { target c++17 } } |
| 3 |
// { dg-options "-fdiagnostics-show-caret" } |
| 4 |
|
| 5 |
template <typename T, typename U> struct is_same { static constexpr bool value = false; }; |
| 6 |
template <typename T> struct is_same<T, T> { static constexpr bool value = true; }; |
| 7 |
|
| 8 |
/* { dg-begin-multiline-output "" } |
| 9 |
f(0, 1.3); |
| 10 |
~^~~~~~~~ |
| 11 |
{ dg-end-multiline-output "" } */ |
| 12 |
|
| 13 |
template <typename T, typename U> |
| 14 |
void f(T, U) |
| 15 |
{ |
| 16 |
static_assert(is_same<T, T>::value && is_same<T, U>::value); // { dg-error "56:static assertion failed" } |
| 17 |
/* { dg-begin-multiline-output "" } |
| 18 |
static_assert(is_same<T, T>::value && is_same<T, U>::value); |
| 19 |
^~~~~ |
| 20 |
{ dg-end-multiline-output "" } */ |
| 21 |
// { dg-message ".is_same<int, double>::value. evaluates to false" "" { target *-*-* } .-5 } |
| 22 |
static_assert(is_same<U, T>::value && is_same<U, U>::value); // { dg-error "32:static assertion failed" } |
| 23 |
/* { dg-begin-multiline-output "" } |
| 24 |
static_assert(is_same<U, T>::value && is_same<U, U>::value); |
| 25 |
^~~~~ |
| 26 |
{ dg-end-multiline-output "" } */ |
| 27 |
// { dg-message ".is_same<double, int>::value. evaluates to false" "" { target *-*-* } .-5 } |
| 28 |
static_assert(is_same<U, U>::value |
| 29 |
&& is_same<U, T>::value // { dg-error "35:static assertion failed" } |
| 30 |
&& is_same<T, T>::value); |
| 31 |
/* { dg-begin-multiline-output "" } |
| 32 |
&& is_same<U, T>::value |
| 33 |
^~~~~ |
| 34 |
{ dg-end-multiline-output "" } */ |
| 35 |
// { dg-message ".is_same<double, int>::value. evaluates to false" "" { target *-*-* } .-6 } |
| 36 |
} |
| 37 |
|
| 38 |
void g() |
| 39 |
{ |
| 40 |
f(0, 1.3); // { dg-message " required from here" } |
| 41 |
} |