| 1 |
// RUN: %clang_cc1 %s -triple=i686-apple-darwin9 -verify -DVERIFY |
| 2 |
// RUN: %clang_cc1 %s -triple=i686-apple-darwin9 -fms-extensions -DMS -verify -DVERIFY |
| 3 |
|
| 4 |
#ifndef __has_feature |
| 5 |
#error Should have __has_feature |
| 6 |
#endif |
| 7 |
|
| 8 |
#if __has_feature(something_we_dont_have) |
| 9 |
#error Bad |
| 10 |
#endif |
| 11 |
|
| 12 |
#if !__has_builtin(__builtin_huge_val) || \ |
| 13 |
!__has_builtin(__builtin_shufflevector) || \ |
| 14 |
!__has_builtin(__builtin_convertvector) || \ |
| 15 |
!__has_builtin(__builtin_trap) || \ |
| 16 |
!__has_builtin(__c11_atomic_init) || \ |
| 17 |
!__has_builtin(__builtin_launder) || \ |
| 18 |
!__has_feature(attribute_analyzer_noreturn) || \ |
| 19 |
!__has_feature(attribute_overloadable) |
| 20 |
#error Clang should have these |
| 21 |
#endif |
| 22 |
|
| 23 |
// These are technically implemented as keywords, but __has_builtin should |
| 24 |
// still return true. |
| 25 |
#if !__has_builtin(__builtin_LINE) || \ |
| 26 |
!__has_builtin(__builtin_FILE) || \ |
| 27 |
!__has_builtin(__builtin_FILE_NAME) || \ |
| 28 |
!__has_builtin(__builtin_FUNCTION) || \ |
| 29 |
!__has_builtin(__builtin_COLUMN) || \ |
| 30 |
!__has_builtin(__array_rank) || \ |
| 31 |
!__has_builtin(__underlying_type) || \ |
| 32 |
!__has_builtin(__is_trivial) || \ |
| 33 |
!__has_builtin(__is_same_as) || \ |
| 34 |
!__has_builtin(__has_unique_object_representations) || \ |
| 35 |
!__has_builtin(__is_trivially_equality_comparable) || \ |
| 36 |
!__has_builtin(__reference_constructs_from_temporary) || \ |
| 37 |
!__has_builtin(__reference_binds_to_temporary) || \ |
| 38 |
!__has_builtin(__reference_converts_from_temporary) |
| 39 |
#error Clang should have these |
| 40 |
#endif |
| 41 |
|
| 42 |
#ifdef MS |
| 43 |
#if !__has_builtin(__builtin_FUNCSIG) |
| 44 |
#error Clang should have this |
| 45 |
#endif |
| 46 |
#elif __has_builtin(__builtin_FUNCSIG) |
| 47 |
#error Clang should not have this without '-fms-extensions' |
| 48 |
#endif |
| 49 |
|
| 50 |
// This is a C-only builtin. |
| 51 |
#if __has_builtin(__builtin_types_compatible_p) |
| 52 |
#error Clang should not have this in C++ mode |
| 53 |
#endif |
| 54 |
|
| 55 |
#if __has_builtin(__builtin_insanity) |
| 56 |
#error Clang should not have this |
| 57 |
#endif |
| 58 |
|
| 59 |
// Check __has_constexpr_builtin |
| 60 |
#if !__has_constexpr_builtin(__builtin_fmax) || \ |
| 61 |
!__has_constexpr_builtin(__builtin_fmin) || \ |
| 62 |
!__has_constexpr_builtin(__builtin_fmaximum_num) || \ |
| 63 |
!__has_constexpr_builtin(__builtin_fminimum_num) |
| 64 |
#error Clang should have these constexpr builtins |
| 65 |
#endif |
| 66 |
|
| 67 |
#if !__has_constexpr_builtin(__builtin_convertvector) |
| 68 |
#error Clang should have these constexpr builtins |
| 69 |
#endif |
| 70 |
|
| 71 |
#if !__has_constexpr_builtin(__builtin_shufflevector) |
| 72 |
#error Clang should have these constexpr builtins |
| 73 |
#endif |
| 74 |
|
| 75 |
#if __has_constexpr_builtin(__builtin_cbrt) |
| 76 |
#error This builtin should not be constexpr in Clang |
| 77 |
#endif |
| 78 |
|
| 79 |
#if __has_constexpr_builtin(__builtin_insanity) |
| 80 |
#error This is not a builtin in Clang |
| 81 |
#endif |
| 82 |
|
| 83 |
// expected-error@+1 {{missing '(' after '__has_constexpr_builtin'}} expected-error@+1 {{expected value}} |
| 84 |
#if __has_constexpr_builtin |
| 85 |
#endif |
| 86 |
|
| 87 |
// expected-error@+1 {{builtin feature check macro requires a parenthesized identifier}} |
| 88 |
#if __has_constexpr_builtin("__builtin_fmax") |
| 89 |
#endif |
| 90 |
|
| 91 |
// expected-error@+1 {{too many arguments}} |
| 92 |
#if __has_constexpr_builtin(__builtin_fmax, __builtin_fmin) |
| 93 |
#endif |