From b269a014771776f860730874095dffb34839a466 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 10 Mar 2020 16:43:58 -0400 Subject: [PATCH] c++: Add tests for PR93922 and PR94041. --- gcc/testsuite/g++.dg/cpp0x/initlist121.C | 31 ++++++++++++++++++++++++ gcc/testsuite/g++.dg/cpp0x/initlist122.C | 16 ++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/initlist121.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/initlist122.C 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 (); +} -- 2.30.2