From 684facbb43ea0eccc6a579d2373781b422522d2d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Martin=20Storsj=C3=B6?= Date: Wed, 24 May 2023 07:45:51 +0000 Subject: [PATCH] [libcxx] [test] Fix the new alloc tests for Windows Use ASSERT_WITH_OPERATOR_NEW_FALLBACKS where relevant to waive the known cases where operator new isn't overridden as expected, in MinGW DLL configurations. Clarify the reason for why the fallback in new.delete.array/new.size_align_nothrow.replace.indirect doesn't work as expected, which can be considered a vcruntime bug. Differential Revision: https://reviews.llvm.org/D151304 --- .../new.delete.array/new.size_align.replace.indirect.pass.cpp | 9 +++------ .../new.size_align_nothrow.replace.indirect.pass.cpp | 5 +---- .../new.delete.array/new.size_nothrow.replace.indirect.pass.cpp | 4 +++- .../new.size_align_nothrow.replace.indirect.pass.cpp | 5 +---- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align.replace.indirect.pass.cpp b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align.replace.indirect.pass.cpp index 283bc35..64d987e 100644 --- a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align.replace.indirect.pass.cpp +++ b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align.replace.indirect.pass.cpp @@ -22,9 +22,6 @@ // nor does the dynamic library shipped with z/OS. // UNSUPPORTED: target={{.+}}-zos{{.*}} -// TODO: Investigate why this fails on MinGW-shared -// UNSUPPORTED: target={{.+}}-windows-gnu - #include #include #include @@ -58,11 +55,11 @@ int main(int, char**) { { new_called = delete_called = 0; OverAligned* x = new OverAligned[3]; - assert(static_cast(x) == DummyData); - assert(new_called == 1); + ASSERT_WITH_OPERATOR_NEW_FALLBACKS(static_cast(x) == DummyData); + ASSERT_WITH_OPERATOR_NEW_FALLBACKS(new_called == 1); delete[] x; - assert(delete_called == 1); + ASSERT_WITH_OPERATOR_NEW_FALLBACKS(delete_called == 1); } // Test with a type that is right on the verge of being overaligned diff --git a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align_nothrow.replace.indirect.pass.cpp b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align_nothrow.replace.indirect.pass.cpp index 52f207e..a621289 100644 --- a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align_nothrow.replace.indirect.pass.cpp +++ b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align_nothrow.replace.indirect.pass.cpp @@ -23,9 +23,6 @@ // nor does the dynamic library shipped with z/OS. // UNSUPPORTED: target={{.+}}-zos{{.*}} -// TODO: Investigate why this fails on MinGW-shared -// UNSUPPORTED: target={{.+}}-windows-gnu - #include #include #include @@ -58,7 +55,7 @@ int main(int, char**) { { new_called = delete_called = 0; OverAligned* x = new (std::nothrow) OverAligned[3]; - assert(static_cast(x) == DummyData); + ASSERT_WITH_OPERATOR_NEW_FALLBACKS(static_cast(x) == DummyData); ASSERT_WITH_OPERATOR_NEW_FALLBACKS(new_called == 1); delete[] x; diff --git a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_nothrow.replace.indirect.pass.cpp b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_nothrow.replace.indirect.pass.cpp index ae4c3fc..8ad0292 100644 --- a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_nothrow.replace.indirect.pass.cpp +++ b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_nothrow.replace.indirect.pass.cpp @@ -14,7 +14,9 @@ // XFAIL: libcpp-no-vcruntime // XFAIL: LIBCXX-AIX-FIXME -// TODO: Investigate why this fails on Windows +// MSVC/vcruntime falls back from the nothrow array new to the nothrow +// scalar new, instead of falling back on the throwing array new. +// https://developercommunity.visualstudio.com/t/vcruntime-nothrow-array-operator-new-fal/10373274 // XFAIL: target={{.+}}-windows-msvc #include diff --git a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.size_align_nothrow.replace.indirect.pass.cpp b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.size_align_nothrow.replace.indirect.pass.cpp index 31fa927..3cbb5aa 100644 --- a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.size_align_nothrow.replace.indirect.pass.cpp +++ b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.size_align_nothrow.replace.indirect.pass.cpp @@ -22,9 +22,6 @@ // nor does the dynamic library shipped with z/OS. // UNSUPPORTED: target={{.+}}-zos{{.*}} -// TODO: Investigate why this fails on MinGW-shared -// UNSUPPORTED: target={{.+}}-windows-gnu - #include #include #include @@ -57,7 +54,7 @@ int main(int, char**) { { new_called = delete_called = 0; OverAligned* x = new (std::nothrow) OverAligned; - assert(static_cast(x) == DummyData); + ASSERT_WITH_OPERATOR_NEW_FALLBACKS(static_cast(x) == DummyData); ASSERT_WITH_OPERATOR_NEW_FALLBACKS(new_called == 1); delete x; -- 2.7.4