1 // RUN: %clang_cc1 %s -triple=i686-apple-darwin9 -target-cpu pentium4 -verify -DVERIFY
2 // RUN: %clang_cc1 %s -E -triple=i686-apple-darwin9 -target-cpu pentium4
3 // RUN: %clang_cc1 %s -triple=i686-apple-darwin9 -target-cpu pentium4 -fms-extensions -DMS -verify -DVERIFY
4 // RUN: %clang_cc1 %s -E -triple=i686-apple-darwin9 -target-cpu pentium4 -fms-extensions -DMS
6 #error Should have __has_feature
10 #if __has_feature(something_we_dont_have)
14 #if !__has_builtin(__builtin_huge_val) || \
15 !__has_builtin(__builtin_shufflevector) || \
16 !__has_builtin(__builtin_convertvector) || \
17 !__has_builtin(__builtin_trap) || \
18 !__has_builtin(__c11_atomic_init) || \
19 !__has_builtin(__builtin_launder) || \
20 !__has_feature(attribute_analyzer_noreturn) || \
21 !__has_feature(attribute_overloadable)
22 #error Clang should have these
25 // These are technically implemented as keywords, but __has_builtin should
27 #if !__has_builtin(__builtin_LINE) || \
28 !__has_builtin(__builtin_FILE) || \
29 !__has_builtin(__builtin_FILE_NAME) || \
30 !__has_builtin(__builtin_FUNCTION) || \
31 !__has_builtin(__builtin_COLUMN) || \
32 !__has_builtin(__builtin_types_compatible_p)
33 #error Clang should have these
37 #if !__has_builtin(__builtin_FUNCSIG)
38 #error Clang should have this
40 #elif __has_builtin(__builtin_FUNCSIG)
41 #error Clang should not have this without '-fms-extensions'
44 // These are C++-only builtins.
45 #if __has_builtin(__array_rank) || \
46 __has_builtin(__underlying_type) || \
47 __has_builtin(__is_trivial)
48 #error Clang should not have these in C mode
51 #if __has_builtin(__builtin_insanity)
52 #error Clang should not have this
55 #if !__has_feature(__attribute_deprecated_with_message__)
56 #error Feature name in double underscores does not work
59 // Make sure we have x86 builtins only (forced with target triple).
61 #if !__has_builtin(__builtin_ia32_emms) || \
62 __has_builtin(__builtin_altivec_abs_v4sf)
63 #error Broken handling of target-specific builtins
66 // Macro expansion does not occur in the parameter to __has_builtin,
67 // __has_feature, etc. (as is also expected behaviour for ordinary
68 // macros), so the following should not expand:
70 #define MY_ALIAS_BUILTIN __c11_atomic_init
71 #define MY_ALIAS_FEATURE attribute_overloadable
73 #if __has_builtin(MY_ALIAS_BUILTIN) || __has_feature(MY_ALIAS_FEATURE)
74 #error Alias expansion not allowed
77 // But deferring should expand:
79 #define HAS_BUILTIN(X) __has_builtin(X)
80 #define HAS_FEATURE(X) __has_feature(X)
82 #if !HAS_BUILTIN(MY_ALIAS_BUILTIN) || !HAS_FEATURE(MY_ALIAS_FEATURE)
83 #error Expansion should have occurred
87 // expected-error@+1 {{builtin feature check macro requires a parenthesized identifier}}
88 #if __has_feature('x')
91 // The following are not identifiers:
92 _Static_assert(!__is_identifier("string"), "oops");
93 _Static_assert(!__is_identifier('c'), "oops");
94 _Static_assert(!__is_identifier(123), "oops");
95 _Static_assert(!__is_identifier(int), "oops");
98 _Static_assert(__is_identifier(abc
/* comment */), "oops");
99 _Static_assert(__is_identifier
/* comment */ (xyz
), "oops");
101 // expected-error@+1 {{too few arguments}}
102 #if __is_identifier()
105 // expected-error@+1 {{too many arguments}}
106 #if __is_identifier(,())
109 // expected-error@+1 {{missing ')' after 'abc'}}
110 #if __is_identifier(abc xyz) // expected-note {{to match this '('}}
113 // expected-error@+1 {{missing ')' after 'abc'}}
114 #if __is_identifier(abc()) // expected-note {{to match this '('}}
117 // expected-error@+1 {{missing ')' after '.'}}
118 #if __is_identifier(.abc) // expected-note {{to match this '('}}
121 // expected-error@+1 {{nested parentheses not permitted in '__is_identifier'}}
122 #if __is_identifier((abc))
125 // expected-error@+1 {{missing '(' after '__is_identifier'}} expected-error@+1 {{expected value}}
129 // expected-error@+1 {{unterminated}} expected-error@+1 {{expected value}}