Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Preprocessor / feature_tests.cpp
blob00421d74e6282a4f372e70e9457dec1a70ae5a0b
1 // RUN: %clang_cc1 %s -triple=i686-apple-darwin9 -verify -DVERIFY
2 // RUN: %clang_cc1 %s -triple=i686-apple-darwin9 -fms-extensions -DMS -verify -DVERIFY
4 #ifndef __has_feature
5 #error Should have __has_feature
6 #endif
8 #if __has_feature(something_we_dont_have)
9 #error Bad
10 #endif
12 #if !__has_builtin(__builtin_huge_val) || \
13 !__has_builtin(__builtin_shufflevector) || \
14 !__has_builtin(__builtin_convertvector) || \
15 !__has_builtin(__builtin_trap) || \
16 !__has_builtin(__c11_atomic_init) || \
17 !__has_builtin(__builtin_launder) || \
18 !__has_feature(attribute_analyzer_noreturn) || \
19 !__has_feature(attribute_overloadable)
20 #error Clang should have these
21 #endif
23 // These are technically implemented as keywords, but __has_builtin should
24 // still return true.
25 #if !__has_builtin(__builtin_LINE) || \
26 !__has_builtin(__builtin_FILE) || \
27 !__has_builtin(__builtin_FILE_NAME) || \
28 !__has_builtin(__builtin_FUNCTION) || \
29 !__has_builtin(__builtin_COLUMN) || \
30 !__has_builtin(__array_rank) || \
31 !__has_builtin(__underlying_type) || \
32 !__has_builtin(__is_trivial) || \
33 !__has_builtin(__is_same_as) || \
34 !__has_builtin(__has_unique_object_representations)
35 #error Clang should have these
36 #endif
38 #ifdef MS
39 #if !__has_builtin(__builtin_FUNCSIG)
40 #error Clang should have this
41 #endif
42 #elif __has_builtin(__builtin_FUNCSIG)
43 #error Clang should not have this without '-fms-extensions'
44 #endif
46 // This is a C-only builtin.
47 #if __has_builtin(__builtin_types_compatible_p)
48 #error Clang should not have this in C++ mode
49 #endif
51 #if __has_builtin(__builtin_insanity)
52 #error Clang should not have this
53 #endif
55 // Check __has_constexpr_builtin
56 #if !__has_constexpr_builtin(__builtin_fmax) || \
57 !__has_constexpr_builtin(__builtin_fmin)
58 #error Clang should have these constexpr builtins
59 #endif
61 #if __has_constexpr_builtin(__builtin_cbrt)
62 #error This builtin should not be constexpr in Clang
63 #endif
65 #if __has_constexpr_builtin(__builtin_insanity)
66 #error This is not a builtin in Clang
67 #endif
69 // expected-error@+1 {{missing '(' after '__has_constexpr_builtin'}} expected-error@+1 {{expected value}}
70 #if __has_constexpr_builtin
71 #endif
73 // expected-error@+1 {{builtin feature check macro requires a parenthesized identifier}}
74 #if __has_constexpr_builtin("__builtin_fmax")
75 #endif
77 // expected-error@+1 {{too many arguments}}
78 #if __has_constexpr_builtin(__builtin_fmax, __builtin_fmin)
79 #endif