summaryrefslogtreecommitdiffstats
path: root/Templates/TestDriver.cxx.in
diff options
context:
space:
mode:
authorSean McBride <sean@rogue-research.com>2019-09-16 23:08:43 (GMT)
committerBrad King <brad.king@kitware.com>2019-09-18 18:05:39 (GMT)
commit1d0d4167cfa53ac85658998980c28e29d0ab537a (patch)
tree106543c0de064890efb613f952a41715a9e0f619 /Templates/TestDriver.cxx.in
parent45b7d5284e11cb34885b756bee8dedeb94fc16cb (diff)
downloadCMake-1d0d4167cfa53ac85658998980c28e29d0ab537a.zip
CMake-1d0d4167cfa53ac85658998980c28e29d0ab537a.tar.gz
CMake-1d0d4167cfa53ac85658998980c28e29d0ab537a.tar.bz2
TestDriver: Fix -Wzero-as-null-pointer-constant warnings
Diffstat (limited to 'Templates/TestDriver.cxx.in')
-rw-r--r--Templates/TestDriver.cxx.in20
1 files changed, 13 insertions, 7 deletions
diff --git a/Templates/TestDriver.cxx.in b/Templates/TestDriver.cxx.in
index c58ef71..ad8bfb0 100644
--- a/Templates/TestDriver.cxx.in
+++ b/Templates/TestDriver.cxx.in
@@ -13,9 +13,15 @@
@CMAKE_FORWARD_DECLARE_TESTS@
#ifdef __cplusplus
-#define CM_CAST(TYPE, EXPR) static_cast<TYPE>(EXPR)
+# define CM_CAST(TYPE, EXPR) static_cast<TYPE>(EXPR)
+# if __cplusplus >= 201103L
+# define CM_NULL nullptr
+# else
+# define CM_NULL NULL
+# endif
#else
-#define CM_CAST(TYPE, EXPR) (TYPE)(EXPR)
+# define CM_CAST(TYPE, EXPR) (TYPE)(EXPR)
+# define CM_NULL NULL
#endif
/* Create map. */
@@ -29,7 +35,7 @@ typedef struct /* NOLINT */
static functionMapEntry cmakeGeneratedFunctionMapEntries[] = {
@CMAKE_FUNCTION_TABLE_ENTIRES@
- { NULL, NULL } /* NOLINT */
+ { CM_NULL, CM_NULL } /* NOLINT */
};
static const int NumTests = CM_CAST(int,
@@ -45,8 +51,8 @@ static char* lowercase(const char* string)
stringSize = CM_CAST(size_t, strlen(string) + 1);
new_string = CM_CAST(char*, malloc(sizeof(char) * stringSize));
- if (new_string == NULL) { /* NOLINT */
- return NULL; /* NOLINT */
+ if (new_string == CM_NULL) { /* NOLINT */
+ return CM_NULL; /* NOLINT */
}
strcpy(new_string, string);
for (p = new_string; *p != 0; ++p) {
@@ -86,7 +92,7 @@ int main(int ac, char* av[])
av++;
}
partial_match = 0;
- arg = NULL; /* NOLINT */
+ arg = CM_NULL; /* NOLINT */
/* If partial match is requested. */
if (testToRun == -1 && ac > 1) {
partial_match = (strcmp(av[1], "-R") == 0) ? 1 : 0;
@@ -100,7 +106,7 @@ int main(int ac, char* av[])
}
for (i = 0; i < NumTests && testToRun == -1; ++i) {
char *test_name = lowercase(cmakeGeneratedFunctionMapEntries[i].name);
- if (partial_match != 0 && strstr(test_name, arg) != NULL) { /* NOLINT */
+ if (partial_match != 0 && strstr(test_name, arg) != CM_NULL) { /* NOLINT */
testToRun = i;
ac -= 2;
av += 2;