diff options
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/readability-delete-null-pointer.cpp')
-rw-r--r-- | clang-tools-extra/test/clang-tidy/readability-delete-null-pointer.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/readability-delete-null-pointer.cpp b/clang-tools-extra/test/clang-tidy/readability-delete-null-pointer.cpp index b46e52a754b..5a7ccae4d52 100644 --- a/clang-tools-extra/test/clang-tidy/readability-delete-null-pointer.cpp +++ b/clang-tools-extra/test/clang-tidy/readability-delete-null-pointer.cpp @@ -3,6 +3,15 @@ #define NULL 0 void f() { + int *ps = 0; + if (ps /**/) // #0 + delete ps; + // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: 'if' statement is unnecessary; deleting null pointer has no effect [readability-delete-null-pointer] + + // CHECK-FIXES: int *ps = 0; + // CHECK-FIXES-NEXT: {{^ }}// #0 + // CHECK-FIXES-NEXT: delete ps; + int *p = 0; // #1 |