[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Preprocessor / feature_tests.cpp
blob848f219339724872a9a416e2b840866dccfceb52
1 // RUN: %clang_cc1 %s -triple=i686-apple-darwin9 -verify -DVERIFY
3 #ifndef __has_feature
4 #error Should have __has_feature
5 #endif
7 #if __has_feature(something_we_dont_have)
8 #error Bad
9 #endif
11 #if !__has_builtin(__builtin_huge_val) || \
12 !__has_builtin(__builtin_shufflevector) || \
13 !__has_builtin(__builtin_convertvector) || \
14 !__has_builtin(__builtin_trap) || \
15 !__has_builtin(__c11_atomic_init) || \
16 !__has_builtin(__builtin_launder) || \
17 !__has_feature(attribute_analyzer_noreturn) || \
18 !__has_feature(attribute_overloadable)
19 #error Clang should have these
20 #endif
22 // These are technically implemented as keywords, but __has_builtin should
23 // still return true.
24 #if !__has_builtin(__builtin_LINE) || \
25 !__has_builtin(__builtin_FILE) || \
26 !__has_builtin(__builtin_FUNCTION) || \
27 !__has_builtin(__builtin_COLUMN) || \
28 !__has_builtin(__array_rank) || \
29 !__has_builtin(__underlying_type) || \
30 !__has_builtin(__is_trivial) || \
31 !__has_builtin(__is_same_as) || \
32 !__has_builtin(__has_unique_object_representations)
33 #error Clang should have these
34 #endif
36 // This is a C-only builtin.
37 #if __has_builtin(__builtin_types_compatible_p)
38 #error Clang should not have this in C++ mode
39 #endif
41 #if __has_builtin(__builtin_insanity)
42 #error Clang should not have this
43 #endif
45 // Check __has_constexpr_builtin
46 #if !__has_constexpr_builtin(__builtin_fmax) || \
47 !__has_constexpr_builtin(__builtin_fmin)
48 #error Clang should have these constexpr builtins
49 #endif
51 #if __has_constexpr_builtin(__builtin_cbrt)
52 #error This builtin should not be constexpr in Clang
53 #endif
55 #if __has_constexpr_builtin(__builtin_insanity)
56 #error This is not a builtin in Clang
57 #endif
59 // expected-error@+1 {{missing '(' after '__has_constexpr_builtin'}} expected-error@+1 {{expected value}}
60 #if __has_constexpr_builtin
61 #endif
63 // expected-error@+1 {{builtin feature check macro requires a parenthesized identifier}}
64 #if __has_constexpr_builtin("__builtin_fmax")
65 #endif
67 // expected-error@+1 {{too many arguments}}
68 #if __has_constexpr_builtin(__builtin_fmax, __builtin_fmin)
69 #endif