Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -triple=i686-apple-darwin9 |
| 2 | // RUN: %clang_cc1 %s -E -triple=i686-apple-darwin9 |
Chris Lattner | 148772a | 2009-06-13 07:13:28 +0000 | [diff] [blame] | 3 | #ifndef __has_feature |
| 4 | #error Should have __has_feature |
| 5 | #endif |
| 6 | |
| 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_trap) || \ |
Richard Smith | fafbf06 | 2012-04-11 17:55:32 +0000 | [diff] [blame] | 15 | !__has_builtin(__c11_atomic_init) || \ |
Chris Lattner | 148772a | 2009-06-13 07:13:28 +0000 | [diff] [blame] | 16 | !__has_feature(attribute_analyzer_noreturn) || \ |
| 17 | !__has_feature(attribute_overloadable) |
| 18 | #error Clang should have these |
| 19 | #endif |
| 20 | |
| 21 | #if __has_builtin(__builtin_insanity) |
| 22 | #error Clang should not have this |
| 23 | #endif |
| 24 | |
Richard Smith | 5297d71 | 2012-02-25 10:41:10 +0000 | [diff] [blame] | 25 | #if !__has_feature(__attribute_deprecated_with_message__) |
| 26 | #error Feature name in double underscores does not work |
| 27 | #endif |
Chris Lattner | 148772a | 2009-06-13 07:13:28 +0000 | [diff] [blame] | 28 | |
| 29 | // Make sure we have x86 builtins only (forced with target triple). |
| 30 | |
| 31 | #if !__has_builtin(__builtin_ia32_emms) || \ |
| 32 | __has_builtin(__builtin_altivec_abs_v4sf) |
| 33 | #error Broken handling of target-specific builtins |
| 34 | #endif |
Andy Gibbs | 3f03b58 | 2012-11-17 19:18:27 +0000 | [diff] [blame] | 35 | |
| 36 | // Macro expansion does not occur in the parameter to __has_builtin, |
| 37 | // __has_feature, etc. (as is also expected behaviour for ordinary |
| 38 | // macros), so the following should not expand: |
| 39 | |
| 40 | #define MY_ALIAS_BUILTIN __c11_atomic_init |
| 41 | #define MY_ALIAS_FEATURE attribute_overloadable |
| 42 | |
| 43 | #if __has_builtin(MY_ALIAS_BUILTIN) || __has_feature(MY_ALIAS_FEATURE) |
| 44 | #error Alias expansion not allowed |
| 45 | #endif |
| 46 | |
| 47 | // But deferring should expand: |
| 48 | |
| 49 | #define HAS_BUILTIN(X) __has_builtin(X) |
| 50 | #define HAS_FEATURE(X) __has_feature(X) |
| 51 | |
| 52 | #if !HAS_BUILTIN(MY_ALIAS_BUILTIN) || !HAS_FEATURE(MY_ALIAS_FEATURE) |
| 53 | #error Expansion should have occurred |
| 54 | #endif |