From: Jason Merrill Date: Tue, 10 Mar 2020 20:43:58 +0000 (-0400) Subject: c++: Add tests for PR93922 and PR94041. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b269a014771776f860730874095dffb34839a466;p=gcc.git c++: Add tests for PR93922 and PR94041. --- diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist121.C b/gcc/testsuite/g++.dg/cpp0x/initlist121.C new file mode 100644 index 00000000000..c12006cab1d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist121.C @@ -0,0 +1,31 @@ +// PR c++/93922 +// { dg-do link { target c++11 } } + +template +struct A { + A () {} + template + A (A const &) {} + ~A () {} +}; +int t; +struct B {}; +struct C : B { C (B const &) { if (t) throw 1; } }; +struct S { A x; C y; }; + +A +bar (B *) +{ + return A (); +} + +S * +foo (B *x, B const &y) +{ + return new S {bar (x), y}; +} + +int +main () +{ +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist122.C b/gcc/testsuite/g++.dg/cpp0x/initlist122.C new file mode 100644 index 00000000000..002bc1eaf3c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist122.C @@ -0,0 +1,16 @@ +// PR c++/94041 +// { dg-do run { target c++11 } } + +bool gone; +struct Temp { ~Temp() { gone = true; } }; +struct A{ A() {}; A(const Temp&) noexcept {}; }; +struct B{ ~B() {}; }; +struct Pair{ A a; B b; }; + +void foo(const Pair&) noexcept { if (gone) __builtin_abort(); } + +int main() +{ + foo({A(Temp{}), B()}); + if (!gone) __builtin_abort (); +}