| 1 |
/* Check that overloaded builtins can be used in templates with SFINAE. */ |
| 2 |
// { dg-do compile { target c++17 } } |
| 3 |
|
| 4 |
/* Checks performed here: |
| 5 |
Invalid parameters with various types (mismatching pointer and non-pointer |
| 6 |
types). */ |
| 7 |
#define SFINAE_TYPE_CHECK(PARAMS, SHORTENED_PARAMS, INVALID_PARAMS) \ |
| 8 |
template <typename T, typename = void> \ |
| 9 |
struct is_available : std::false_type {}; \ |
| 10 |
template <typename T> \ |
| 11 |
struct is_available<T, \ |
| 12 |
std::void_t<decltype(__builtin_speculation_safe_value INVALID_PARAMS) >> \ |
| 13 |
: std::true_type {}; |
| 14 |
|
| 15 |
/* Mismatching pointer/non-pointer typed parameters always fail. */ |
| 16 |
#define MAKE_SPECULATION_ASSERT(TYPE, SUCCESS) \ |
| 17 |
static_assert(is_available<TYPE>::value == false); |
| 18 |
|
| 19 |
#include "builtin-speculation-overloads.def" |