diff options
Diffstat (limited to 'clang-tools-extra/test/cpp11-migrate/UseNullptr/basic.cpp')
-rw-r--r-- | clang-tools-extra/test/cpp11-migrate/UseNullptr/basic.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/clang-tools-extra/test/cpp11-migrate/UseNullptr/basic.cpp b/clang-tools-extra/test/cpp11-migrate/UseNullptr/basic.cpp index a0d93b13004..c9dc404b8a3 100644 --- a/clang-tools-extra/test/cpp11-migrate/UseNullptr/basic.cpp +++ b/clang-tools-extra/test/cpp11-migrate/UseNullptr/basic.cpp @@ -178,3 +178,29 @@ int test_function_return6() { return g_null; // CHECK: return g_null; } + +// Test function-like macros where the parameter to the macro (expression) +// results in a nullptr. +void __dummy_assert_fail() {} + +void test_function_like_macro1() { + // This tests that the CastSequenceVisitor is working properly. +#define my_assert(expr) \ + ((expr) ? static_cast<void>(expr) : __dummy_assert_fail()) + + int *p; + my_assert(p != 0); + // CHECK: my_assert(p != nullptr); +#undef my_assert +} + +void test_function_like_macro2() { + // This tests that the implicit cast is working properly. +#define my_macro(expr) \ + (expr) + + int *p; + my_macro(p != 0); + // CHECK: my_macro(p != nullptr); +#undef my_macro +} |