summaryrefslogtreecommitdiffstats
path: root/clang/test/Preprocessor/feature_tests.c
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-06-13 07:13:28 +0000
committerChris Lattner <sabre@nondot.org>2009-06-13 07:13:28 +0000
commitb6f77af5327f411aa07b81b25b85b016113dace5 (patch)
tree9c1ac15b49f18868282cf540748de30e92ccfcfd /clang/test/Preprocessor/feature_tests.c
parenta5d5c749b1acb6fdbd6f6e6440b316f73e9b876e (diff)
downloadbcm5719-llvm-b6f77af5327f411aa07b81b25b85b016113dace5.tar.gz
bcm5719-llvm-b6f77af5327f411aa07b81b25b85b016113dace5.zip
implement and document a new __has_feature and __has_builtin magic
builtin preprocessor macro. This appears to work with two caveats: 1) builtins are registered in -E mode, and 2) target-specific builtins are unconditionally registered even if they aren't supported by the target (e.g. SSE4 builtin when only SSE1 is enabled). llvm-svn: 73289
Diffstat (limited to 'clang/test/Preprocessor/feature_tests.c')
-rw-r--r--clang/test/Preprocessor/feature_tests.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/clang/test/Preprocessor/feature_tests.c b/clang/test/Preprocessor/feature_tests.c
new file mode 100644
index 00000000000..edca1781922
--- /dev/null
+++ b/clang/test/Preprocessor/feature_tests.c
@@ -0,0 +1,30 @@
+// RUN: clang-cc %s --triple=i686-apple-darwin9
+#ifndef __has_feature
+#error Should have __has_feature
+#endif
+
+
+#if __has_feature(something_we_dont_have)
+#error Bad
+#endif
+
+#if !__has_builtin(__builtin_huge_val) || \
+ !__has_builtin(__builtin_shufflevector) || \
+ !__has_builtin(__builtin_trap) || \
+ !__has_feature(attribute_analyzer_noreturn) || \
+ !__has_feature(attribute_overloadable)
+#error Clang should have these
+#endif
+
+#if __has_builtin(__builtin_insanity)
+#error Clang should not have this
+#endif
+
+
+
+// Make sure we have x86 builtins only (forced with target triple).
+
+#if !__has_builtin(__builtin_ia32_emms) || \
+ __has_builtin(__builtin_altivec_abs_v4sf)
+#error Broken handling of target-specific builtins
+#endif
OpenPOWER on IntegriCloud