1- // RUN: %check_clang_tidy %s modernize-use-nullptr %t -- -- -Wno-non-literal-null-conversion
1+ // RUN: %check_clang_tidy %s modernize-use-nullptr %t -- -- \
2+ // RUN: -target x86_64-linux-gnu -Wno-non-literal-null-conversion -fno-delayed-template-parsing
3+ // RUN: %check_clang_tidy %s -check-suffixes=,WINDOWS modernize-use-nullptr %t -- -- \
4+ // RUN: -target x86_64-windows-msvc -Wno-non-literal-null-conversion -fno-delayed-template-parsing
25
36const unsigned int g_null = 0 ;
47#define NULL 0
@@ -59,8 +62,6 @@ int *Foo::m_p2 = NULL;
5962// CHECK-FIXES: int *Foo::m_p2 = nullptr;
6063
6164// FIXME: all these DISABLED-* cases should trigger the warning.
62- // Some of them do work, but only on Linux, not on Windows.
63- #if 0
6465template <typename T>
6566struct Bar {
6667 Bar (T *p) : m_p(p) {
@@ -69,12 +70,12 @@ struct Bar {
6970 // DISABLED-CHECK-FIXES: m_p = static_cast<T*>(nullptr);
7071
7172 m_p = static_cast <T*>(reinterpret_cast <int *>((void *)NULL ));
72- // DISABLED- CHECK-MESSAGES: :[[@LINE-1]]:27: warning: use nullptr
73- // DISABLED- CHECK-FIXES: m_p = static_cast<T*>(nullptr);
73+ // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: use nullptr
74+ // CHECK-FIXES: m_p = static_cast<T*>(nullptr);
7475
7576 T *p2 = static_cast <T*>(reinterpret_cast <int *>((void *)NULL ));
76- // DISABLED- CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use nullptr
77- // DISABLED- CHECK-FIXES: T *p2 = static_cast<T*>(nullptr);
77+ // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use nullptr
78+ // CHECK-FIXES: T *p2 = static_cast<T*>(nullptr);
7879
7980 m_p = NULL ;
8081 // DISABLED-CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use nullptr
@@ -88,7 +89,6 @@ struct Bar {
8889
8990 T *m_p;
9091};
91- #endif
9292
9393struct Baz {
9494 Baz () : i(0 ) {}
@@ -199,14 +199,12 @@ void *test_parentheses_explicit_cast_sequence1() {
199199 // CHECK-FIXES: return(static_cast<void*>(nullptr));
200200}
201201
202- // FIXME: this case triggers the warning on Windows but not on Linux.
203- #if 0
202+ // FIXME: make the warning trigger on Linux too.
204203void *test_parentheses_explicit_cast_sequence2 () {
205204 return (static_cast <void *>(reinterpret_cast <int *>((float *)int (0 .f ))));
206- // DISABLED- CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use nullptr
207- // DISABLED- CHECK-FIXES: return(static_cast<void*>(nullptr));
205+ // CHECK-MESSAGES-WINDOWS : :[[@LINE-1]]:29: warning: use nullptr
206+ // CHECK-FIXES-WINDOWS : return(static_cast<void*>(nullptr));
208207}
209- #endif
210208
211209// Test explicit cast expressions resulting in nullptr.
212210struct Bam {
0 commit comments