summaryrefslogtreecommitdiffstats
path: root/Tests/CompileFeatures
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2015-01-03 14:09:53 (GMT)
committerStephen Kelly <steveire@gmail.com>2015-01-03 14:14:52 (GMT)
commitc13656e7173a517961349a5fe20ce0f727d37568 (patch)
tree0462c0bcb7ea8e827efef61bd6f1b02275282d12 /Tests/CompileFeatures
parent3e34e8331a72f227248a235595e3cfeabf65312e (diff)
downloadCMake-c13656e7173a517961349a5fe20ce0f727d37568.zip
CMake-c13656e7173a517961349a5fe20ce0f727d37568.tar.gz
CMake-c13656e7173a517961349a5fe20ce0f727d37568.tar.bz2
Features: Test nullptr as a side-effect activation of static_assert.
Because not all compilers under test support the existing 'activation features', add another test to ensure that compilers which support both static_assert and nullptr behave as expected in this test.
Diffstat (limited to 'Tests/CompileFeatures')
-rw-r--r--Tests/CompileFeatures/CMakeLists.txt15
-rw-r--r--Tests/CompileFeatures/genex_test.cpp11
2 files changed, 23 insertions, 3 deletions
diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt
index aca1791..832f68b 100644
--- a/Tests/CompileFeatures/CMakeLists.txt
+++ b/Tests/CompileFeatures/CMakeLists.txt
@@ -124,15 +124,24 @@ if (CMAKE_CXX_COMPILE_FEATURES)
add_executable(CompileFeaturesGenex genex_test.cpp)
set_property(TARGET CompileFeaturesGenex PROPERTY CXX_STANDARD 11)
- target_compile_definitions(CompileFeaturesGenex PRIVATE HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override>)
+ target_compile_definitions(CompileFeaturesGenex PRIVATE
+ HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override>
+ HAVE_NULLPTR=$<COMPILE_FEATURES:cxx_nullptr>
+ )
add_executable(CompileFeaturesGenex2 genex_test.cpp)
target_compile_features(CompileFeaturesGenex2 PRIVATE cxx_static_assert)
- target_compile_definitions(CompileFeaturesGenex2 PRIVATE HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override>)
+ target_compile_definitions(CompileFeaturesGenex2 PRIVATE
+ HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override>
+ HAVE_NULLPTR=$<COMPILE_FEATURES:cxx_nullptr>
+ )
add_library(static_assert_iface INTERFACE)
target_compile_features(static_assert_iface INTERFACE cxx_static_assert)
add_executable(CompileFeaturesGenex3 genex_test.cpp)
target_link_libraries(CompileFeaturesGenex3 PRIVATE static_assert_iface)
- target_compile_definitions(CompileFeaturesGenex3 PRIVATE HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override>)
+ target_compile_definitions(CompileFeaturesGenex3 PRIVATE
+ HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override>
+ HAVE_NULLPTR=$<COMPILE_FEATURES:cxx_nullptr>
+ )
endif()
diff --git a/Tests/CompileFeatures/genex_test.cpp b/Tests/CompileFeatures/genex_test.cpp
index 46b1942..f667cc4 100644
--- a/Tests/CompileFeatures/genex_test.cpp
+++ b/Tests/CompileFeatures/genex_test.cpp
@@ -17,6 +17,17 @@ struct B final : A
#endif
+#if !HAVE_NULLPTR
+#error "Expect nullptr feature"
+#else
+
+const char* getString()
+{
+ return nullptr;
+}
+
+#endif
+
int main()
{