diff options
author | Brad King <brad.king@kitware.com> | 2019-09-20 14:09:00 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-09-20 14:15:35 (GMT) |
commit | 3c060ae6ca01464d507d6c7b6cef38639084418f (patch) | |
tree | a391bb1cbebc2996e4fcc19b400234567bf09a87 | |
parent | 7cf36407be6c8d5206b4c005e099519ce24f1350 (diff) | |
parent | 1d0d4167cfa53ac85658998980c28e29d0ab537a (diff) | |
download | CMake-3c060ae6ca01464d507d6c7b6cef38639084418f.zip CMake-3c060ae6ca01464d507d6c7b6cef38639084418f.tar.gz CMake-3c060ae6ca01464d507d6c7b6cef38639084418f.tar.bz2 |
Merge topic 'null-warning'
1d0d4167cf TestDriver: Fix -Wzero-as-null-pointer-constant warnings
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Brad King <brad.king@kitware.com>
Merge-request: !3824
-rw-r--r-- | Templates/TestDriver.cxx.in | 20 |
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; |