From 57e7ad5a8fd5a7bddf15e2fede6d2546cc6a2797 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 16 Mar 2020 21:16:35 -0400 Subject: [PATCH] c++: Add test for PR 93901. --- gcc/testsuite/g++.dg/cpp0x/noexcept57.C | 40 +++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/noexcept57.C diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept57.C b/gcc/testsuite/g++.dg/cpp0x/noexcept57.C new file mode 100644 index 00000000000..aca98912701 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept57.C @@ -0,0 +1,40 @@ +// PR c++/93901 +// { dg-do compile { target c++11 } } + +void *operator new (__SIZE_TYPE__, void *p) noexcept { return p; } + +extern void *mem; + +constexpr bool YES = true; + +struct NoexceptTrueCtor { + NoexceptTrueCtor() noexcept(true); +}; +void NoexceptTrueFun() noexcept(true); + +struct NoexceptYesCtor { + NoexceptYesCtor() noexcept(YES); +}; +void NoexceptYesFun() noexcept(YES); + +struct NoexceptOneEqOneCtor { + NoexceptOneEqOneCtor() noexcept(1 == 1); +}; +void NoexceptOneEqOneFun() noexcept(1 == 1); + +struct NoNoexceptCtor { + NoNoexceptCtor(); +}; +void NoNoexceptFun(); + +static_assert(noexcept(new(mem) NoexceptTrueCtor), "2"); // OK +static_assert(noexcept(NoexceptTrueFun()), "3"); // OK + +static_assert(noexcept(new(mem) NoexceptYesCtor), "5"); // fail +static_assert(noexcept(NoexceptYesFun()), "6"); // OK + +static_assert(noexcept(new(mem) NoexceptOneEqOneCtor), "8"); // fail +static_assert(noexcept(NoexceptOneEqOneFun()), "9"); // OK + +static_assert(!noexcept(new(mem) NoNoexceptCtor), "11"); // OK +static_assert(!noexcept(NoNoexceptFun()), "12"); // OK -- 2.30.2