From: Jason Merrill Date: Tue, 17 Mar 2020 01:16:35 +0000 (-0400) Subject: c++: Add test for PR 93901. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=57e7ad5a8fd5a7bddf15e2fede6d2546cc6a2797;p=gcc.git c++: Add test for PR 93901. --- 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