1 // RUN: %clang_cc1 %s -triple=i686-apple-darwin9 2 // RUN: %clang_cc1 %s -E -triple=i686-apple-darwin9 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) || \ 15 !__has_builtin(__c11_atomic_init) || \ 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 25 #if !__has_feature(__attribute_deprecated_with_message__) 26 #error Feature name in double underscores does not work 27 #endif 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 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 55