class Large { public: int arr[10]; };
class Incomplete;
+/* Using `true_def` in order to account for the fact that if this target
+ * doesn't support __builtin_speculation_safe_value at all everything fails to
+ * substitute. */
#define SPECULATION_ASSERTS \
- MAKE_SPECULATION_ASSERT (int, true) \
+ MAKE_SPECULATION_ASSERT (int, true_def) \
MAKE_SPECULATION_ASSERT (float, false) \
MAKE_SPECULATION_ASSERT (X, false) \
MAKE_SPECULATION_ASSERT (Large, false) \
MAKE_SPECULATION_ASSERT (Incomplete, false) \
- MAKE_SPECULATION_ASSERT (int *, true) \
- MAKE_SPECULATION_ASSERT (long, true)
+ MAKE_SPECULATION_ASSERT (int *, true_def) \
+ MAKE_SPECULATION_ASSERT (long, true_def)
int main() {
SPECULATION_ASSERTS
/* Check that overloaded builtins can be used in templates with SFINAE. */
// { dg-do compile { target c++17 } }
+// { dg-additional-options "-Dtrue_def=true" { target speculation_barrier_defined } }
+// { dg-additional-options "-Dtrue_def=false" { target { ! speculation_barrier_defined } } }
/* Checks performed here:
Various types (some that work, some that don't). */
/* Check that overloaded builtins can be used in templates with SFINAE. */
// { dg-do compile { target c++17 } }
+// { dg-additional-options "-Dtrue_def=true" { target speculation_barrier_defined } }
+// { dg-additional-options "-Dtrue_def=false" { target { ! speculation_barrier_defined } } }
/* Checks performed here:
Optional parameter missing works same as with optional parameter specified. */
}
}]
}
+
+# Return true if a speculation barrier is defined on the target.
+proc check_effective_target_speculation_barrier_defined { } {
+ return [check_no_compiler_messages speculation_barrier_defined assembly {
+ int main (int argc, char **argv) {
+ return __builtin_speculation_safe_value (argc);
+ }
+ }]
+}