From bed888242662c2327b32b91a03635e079ad5667e Mon Sep 17 00:00:00 2001 From: Leonard Chan Date: Fri, 26 Feb 2021 11:13:42 -0800 Subject: [PATCH] [scudo][test] Disable -Wfree-nonheap-object As of 4f395db86b5cc11bb56853323d3cb1d4b6db5a0b which contains updates to -Wfree-nonheap-object, a line in this test will trigger the warning. This particular line is ok though since it's meant to test a free on a bad pointer. Differential Revision: https://reviews.llvm.org/D97516 --- compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp b/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp index e01ac38..e8872a15 100644 --- a/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp +++ b/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp @@ -42,8 +42,19 @@ TEST(ScudoWrappersCTest, Malloc) { EXPECT_NE(P, nullptr); EXPECT_LE(Size, malloc_usable_size(P)); EXPECT_EQ(reinterpret_cast(P) % FIRST_32_SECOND_64(8U, 16U), 0U); + + // An update to this warning in Clang now triggers in this line, but it's ok + // because the check is expecting a bad pointer and should fail. +#if defined(__has_warning) && __has_warning("-Wfree-nonheap-object") +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wfree-nonheap-object" +#endif EXPECT_DEATH( free(reinterpret_cast(reinterpret_cast(P) | 1U)), ""); +#if defined(__has_warning) && __has_warning("-Wfree-nonheap-object") +#pragma GCC diagnostic pop +#endif + free(P); EXPECT_DEATH(free(P), ""); -- 2.7.4