Debian Codegraph @

gcc/testsuite/g++.dg/template/builtin-speculation-overloads5.C

raw
1 /* Check that overloaded builtins still error when not in SFINAE context. */
2 // { dg-do compile { target c++17 } }
3 #include <type_traits>
4
5 /* Checks performed here:
6 Fully specified and invalid function errors before SFINAE happens. */
7 template <typename T, typename = void> struct is_available : std::false_type
8 {
9 };
10
11 /* Should be error here because of the fully specified (and invalid) builtin
12 call. */
13 /* { dg-error "template argument 2 is invalid" "" { target *-*-* } .+5 } */
14 /* { dg-error "template argument 1 is invalid" "" { target *-*-* } .+4 } */
15 /* { dg-error "too few arguments to function" "" { target *-*-* } .+3 } */
16 template <typename T>
17 struct is_available<
18 T, std::void_t<decltype (__builtin_speculation_safe_value ())>>
19 : std::true_type
20 {
21 };
22
23 /* Should be error here because of the fully specified (and invalid) builtin
24 call. */
25 /* { dg-error "template argument 2 is invalid" "" { target *-*-* } .+5 } */
26 /* { dg-error "template argument 1 is invalid" "" { target *-*-* } .+4 } */
27 /* { dg-error "operand type 'float' is incompatible" "" { target *-*-* } .+3 } */
28 template <typename T>
29 struct is_available<
30 T, std::void_t<decltype (__builtin_speculation_safe_value (float()))>>
31 : std::true_type
32 {
33 };