| 1 |
// PR c++/71675 - __atomic_compare_exchange_n returns wrong type for typed enum |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
|
| 4 |
template <class T> |
| 5 |
void sink (T); |
| 6 |
|
| 7 |
bool sink (bool); |
| 8 |
|
| 9 |
template <class T> |
| 10 |
bool test () |
| 11 |
{ |
| 12 |
enum class E: T { }; |
| 13 |
static E e; |
| 14 |
|
| 15 |
return sink (__atomic_compare_exchange_n (&e, &e, e, false, 0, 0)); |
| 16 |
} |
| 17 |
|
| 18 |
void tests () |
| 19 |
{ |
| 20 |
// __atomic_compare_exchange_n would fail to return bool when |
| 21 |
// its arguments were one of the three character types. |
| 22 |
test<char>(); |
| 23 |
test<signed char>(); |
| 24 |
test<unsigned char>(); |
| 25 |
|
| 26 |
test<short>(); |
| 27 |
test<unsigned short>(); |
| 28 |
|
| 29 |
test<int>(); |
| 30 |
test<unsigned int>(); |
| 31 |
|
| 32 |
test<long>(); |
| 33 |
test<unsigned long>(); |
| 34 |
|
| 35 |
test<long long>(); |
| 36 |
test<unsigned long long>(); |
| 37 |
} |