summaryrefslogtreecommitdiffstats
path: root/Tests/CompileFeatures
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/CompileFeatures')
-rw-r--r--Tests/CompileFeatures/CMakeLists.txt32
-rw-r--r--Tests/CompileFeatures/genex_test.c38
2 files changed, 70 insertions, 0 deletions
diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt
index 38c44c8..3ba1e0a 100644
--- a/Tests/CompileFeatures/CMakeLists.txt
+++ b/Tests/CompileFeatures/CMakeLists.txt
@@ -164,6 +164,38 @@ if (CMAKE_C_COMPILE_FEATURES)
)
endif()
endif()
+
+ add_executable(CompileFeaturesGenex_C genex_test.c)
+ set_property(TARGET CompileFeaturesGenex_C PROPERTY C_STANDARD 11)
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6)
+ list(APPEND expected_defs
+ EXPECT_C_STATIC_ASSERT=1
+ )
+ else()
+ list(APPEND expected_defs
+ EXPECT_C_STATIC_ASSERT=0
+ )
+ endif()
+ elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang"
+ OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
+ list(APPEND expected_defs
+ EXPECT_C_STATIC_ASSERT=1
+ )
+ endif()
+
+ list(APPEND expected_defs
+ EXPECT_C_FUNCTION_PROTOTYPES=1
+ EXPECT_C_RESTRICT=1
+ )
+
+ target_compile_definitions(CompileFeaturesGenex_C PRIVATE
+ HAVE_C_FUNCTION_PROTOTYPES=$<COMPILE_FEATURES:c_function_prototypes>
+ HAVE_C_RESTRICT=$<COMPILE_FEATURES:c_restrict>
+ HAVE_C_STATIC_ASSERT=$<COMPILE_FEATURES:c_static_assert>
+ ${expected_defs}
+ )
endif()
if (CMAKE_CXX_COMPILE_FEATURES)
diff --git a/Tests/CompileFeatures/genex_test.c b/Tests/CompileFeatures/genex_test.c
new file mode 100644
index 0000000..b1215bd
--- /dev/null
+++ b/Tests/CompileFeatures/genex_test.c
@@ -0,0 +1,38 @@
+#ifndef EXPECT_C_STATIC_ASSERT
+# error EXPECT_C_STATIC_ASSERT not defined
+#endif
+#ifndef EXPECT_C_FUNCTION_PROTOTYPES
+# error EXPECT_C_FUNCTION_PROTOTYPES not defined
+#endif
+#ifndef EXPECT_C_RESTRICT
+# error EXPECT_C_RESTRICT not defined
+#endif
+
+#if !EXPECT_C_STATIC_ASSERT
+#if EXPECT_C_STATIC_ASSERT
+#error "Expect c_static_assert feature"
+#endif
+#else
+#if !EXPECT_C_STATIC_ASSERT
+#error "Expect no c_static_assert feature"
+#endif
+#endif
+
+#if !EXPECT_C_FUNCTION_PROTOTYPES
+# error Expect c_function_prototypes support
+#endif
+
+#if !EXPECT_C_RESTRICT
+# if EXPECT_C_RESTRICT
+# error Expect c_restrict support
+# endif
+#else
+# if !EXPECT_C_RESTRICT
+# error Expect no c_restrict support
+# endif
+#endif
+
+int main()
+{
+
+}