blob: 19d80468ab3f624b018093c8f624dce8e70276e4 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 %s -triple=i686-apple-darwin9
2// RUN: %clang_cc1 %s -E -triple=i686-apple-darwin9
Chris Lattner148772a2009-06-13 07:13:28 +00003#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 Smithfafbf062012-04-11 17:55:32 +000015 !__has_builtin(__c11_atomic_init) || \
Chris Lattner148772a2009-06-13 07:13:28 +000016 !__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 Smith5297d712012-02-25 10:41:10 +000025#if !__has_feature(__attribute_deprecated_with_message__)
26#error Feature name in double underscores does not work
27#endif
Chris Lattner148772a2009-06-13 07:13:28 +000028
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 Gibbs3f03b582012-11-17 19:18:27 +000035
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