summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRolf Eike Beer <eike@sf-mail.de>2018-03-19 20:52:40 (GMT)
committerRolf Eike Beer <eike@sf-mail.de>2018-03-20 21:01:48 (GMT)
commitdc863592bce3f4cda927c55a550af661a0663513 (patch)
treefeef78c922221ce00f19fb84f8c14f4fa2e37b75
parent1c3bbda2f2920f416304086ece139ba1b50015ea (diff)
downloadCMake-dc863592bce3f4cda927c55a550af661a0663513.zip
CMake-dc863592bce3f4cda927c55a550af661a0663513.tar.gz
CMake-dc863592bce3f4cda927c55a550af661a0663513.tar.bz2
WCDH: use better fallback value for nullptr with old gcc versions
GCC supports the __null builtin basically forever (since at least 2.95), which behaves very much like nullptr later does. Use this instead of plain "0" as fallback value, otherwise passing the define to functions annotated with __attribute__((sentinel)) will result in a compiler warning.
-rw-r--r--Modules/WriteCompilerDetectionHeader.cmake13
1 files changed, 12 insertions, 1 deletions
diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake
index e7f9912..675df84 100644
--- a/Modules/WriteCompilerDetectionHeader.cmake
+++ b/Modules/WriteCompilerDetectionHeader.cmake
@@ -557,7 +557,18 @@ template<> struct ${prefix_arg}StaticAssert<true>{};
# endif
\n")
endif()
- _simpledefine(cxx_nullptr NULLPTR nullptr 0)
+ if (feature STREQUAL cxx_nullptr)
+ set(def_value "${prefix_arg}_NULLPTR")
+ string(APPEND file_content "
+# if defined(${def_name}) && ${def_name}
+# define ${def_value} nullptr
+# elif ${prefix_arg}_COMPILER_IS_GNU
+# define ${def_value} __null
+# else
+# define ${def_value} 0
+# endif
+\n")
+ endif()
if (feature STREQUAL cxx_thread_local)
set(def_value "${prefix_arg}_THREAD_LOCAL")
string(APPEND file_content "