| 1 |
/* Check that overloaded builtins can be used in templates with SFINAE. */ |
| 2 |
// { dg-do compile { target c++17 } } |
| 3 |
// { dg-additional-options "-Dtrue_def=true" { target speculation_barrier_defined } } |
| 4 |
// { dg-additional-options "-Dtrue_def=false" { target { ! speculation_barrier_defined } } } |
| 5 |
|
| 6 |
/* Checks performed here: |
| 7 |
Optional parameter missing works same as with optional parameter specified. */ |
| 8 |
#define SFINAE_TYPE_CHECK(PARAMS, SHORTENED_PARAMS, INVALID_PARAMS) \ |
| 9 |
template <typename T, typename = void> \ |
| 10 |
struct is_available : std::false_type {}; \ |
| 11 |
template <typename T> \ |
| 12 |
struct is_available<T, \ |
| 13 |
std::void_t<decltype(__builtin_speculation_safe_value SHORTENED_PARAMS) >> \ |
| 14 |
: std::true_type {}; |
| 15 |
|
| 16 |
/* All types should fail with three arguments. */ |
| 17 |
#define MAKE_SPECULATION_ASSERT(TYPE, SUCCESS) \ |
| 18 |
static_assert(is_available<TYPE>::value == SUCCESS); |
| 19 |
|
| 20 |
#include "builtin-speculation-overloads.def" |
| 21 |
|