]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Library-side tests for parenthesized aggregate init
authorVille Voutilainen <ville.voutilainen@gmail.com>
Sat, 22 Feb 2020 20:40:26 +0000 (22:40 +0200)
committerVille Voutilainen <ville.voutilainen@gmail.com>
Tue, 31 Mar 2020 14:07:52 +0000 (17:07 +0300)
PR c++/92878
PR c++/92947

* testsuite/20_util/allocator_traits/members/92878_92947.cc: New.
* testsuite/20_util/any/assign/92878_92947.cc: Likewise.
* testsuite/20_util/any/cons/92878_92947.cc: Likewise.
* testsuite/20_util/is_constructible/92878_92947.cc: Likewise.
* testsuite/20_util/optional/assignment/92878_92947.cc: Likewise.
* testsuite/20_util/optional/cons/92878_92947.cc: Likewise.
* testsuite/20_util/pair/cons/92878_92947.cc: Likewise.
* testsuite/20_util/shared_ptr/creation/92878_92947.cc: Likewise.
* testsuite/20_util/specialized_algorithms/construct_at/92878_92947.cc:
Likewise.
* testsuite/20_util/unique_ptr/creation/92878_92947.cc: Likewise.
* testsuite/20_util/uses_allocator/92878_92947.cc: Likewise.
* testsuite/20_util/variant/92878_92947.cc: Likewise.
* testsuite/23_containers/deque/modifiers/emplace/92878_92947.cc:
Likewise.
* testsuite/23_containers/forward_list/modifiers/92878_92947.cc:
Likewise.
* testsuite/23_containers/list/modifiers/emplace/92878_92947.cc:
Likewise.
* testsuite/23_containers/map/modifiers/emplace/92878_92947.cc:
Likewise.
* testsuite/23_containers/multimap/modifiers/emplace/92878_92947.cc:
Likewise.
* testsuite/23_containers/multiset/modifiers/emplace/92878_92947.cc:
Likewise.
* testsuite/23_containers/priority_queue/92878_92947.cc: Likewise.
* testsuite/23_containers/queue/92878_92947.cc: Likewise.
* testsuite/23_containers/set/modifiers/emplace/92878_92947.cc:
Likewise.
* testsuite/23_containers/stack/92878_92947.cc: Likewise.
* testsuite/23_containers/unordered_map/modifiers/92878_92947.cc:
Likewise.
* testsuite/23_containers/unordered_multimap/modifiers/92878_92947.cc:
Likewise.
* testsuite/23_containers/unordered_multiset/modifiers/92878_92947.cc:
Likewise.
* testsuite/23_containers/unordered_set/modifiers/92878_92947.cc:
Likewise.
* testsuite/23_containers/vector/modifiers/emplace/92878_92947.cc:
Likewise.

28 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/testsuite/20_util/allocator_traits/members/92878_92947.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/any/assign/92878_92947.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/any/cons/92878_92947.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/is_constructible/92878_92947.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/optional/assignment/92878_92947.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/optional/cons/92878_92947.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/pair/cons/92878_92947.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/shared_ptr/creation/92878_92947.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/specialized_algorithms/construct_at/92878_92947.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/unique_ptr/creation/92878_92947.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/uses_allocator/92878_92947.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/variant/92878_92947.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/deque/modifiers/emplace/92878_92947.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/forward_list/modifiers/92878_92947.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/list/modifiers/emplace/92878_92947.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/map/modifiers/emplace/92878_92947.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/multimap/modifiers/emplace/92878_92947.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/multiset/modifiers/emplace/92878_92947.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/priority_queue/92878_92947.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/queue/92878_92947.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/set/modifiers/emplace/92878_92947.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/stack/92878_92947.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_map/modifiers/92878_92947.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_multimap/modifiers/92878_92947.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_multiset/modifiers/92878_92947.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_set/modifiers/92878_92947.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/vector/modifiers/emplace/92878_92947.cc [new file with mode: 0644]

index 912bab28691dbe865d2da0d51965eb72da1e304a..beaf61b9d2bcc0ca970c3eeb625d1740797f24a3 100644 (file)
@@ -1,3 +1,51 @@
+2020-03-31  Ville Voutilainen  <ville.voutilainen@gmail.com>
+
+       Library-side tests for parenthesized aggregate init
+
+       PR c++/92878
+       PR c++/92947
+
+       * testsuite/20_util/allocator_traits/members/92878_92947.cc: New.
+       * testsuite/20_util/any/assign/92878_92947.cc: Likewise.
+       * testsuite/20_util/any/cons/92878_92947.cc: Likewise.
+       * testsuite/20_util/is_constructible/92878_92947.cc: Likewise.
+       * testsuite/20_util/optional/assignment/92878_92947.cc: Likewise.
+       * testsuite/20_util/optional/cons/92878_92947.cc: Likewise.
+       * testsuite/20_util/pair/cons/92878_92947.cc: Likewise.
+       * testsuite/20_util/shared_ptr/creation/92878_92947.cc: Likewise.
+       * testsuite/20_util/specialized_algorithms/construct_at/92878_92947.cc:
+       Likewise.
+       * testsuite/20_util/unique_ptr/creation/92878_92947.cc: Likewise.
+       * testsuite/20_util/uses_allocator/92878_92947.cc: Likewise.
+       * testsuite/20_util/variant/92878_92947.cc: Likewise.
+       * testsuite/23_containers/deque/modifiers/emplace/92878_92947.cc:
+       Likewise.
+       * testsuite/23_containers/forward_list/modifiers/92878_92947.cc:
+       Likewise.
+       * testsuite/23_containers/list/modifiers/emplace/92878_92947.cc:
+       Likewise.
+       * testsuite/23_containers/map/modifiers/emplace/92878_92947.cc:
+       Likewise.
+       * testsuite/23_containers/multimap/modifiers/emplace/92878_92947.cc:
+       Likewise.
+       * testsuite/23_containers/multiset/modifiers/emplace/92878_92947.cc:
+       Likewise.
+       * testsuite/23_containers/priority_queue/92878_92947.cc: Likewise.
+       * testsuite/23_containers/queue/92878_92947.cc: Likewise.
+       * testsuite/23_containers/set/modifiers/emplace/92878_92947.cc:
+       Likewise.
+       * testsuite/23_containers/stack/92878_92947.cc: Likewise.
+       * testsuite/23_containers/unordered_map/modifiers/92878_92947.cc:
+       Likewise.
+       * testsuite/23_containers/unordered_multimap/modifiers/92878_92947.cc:
+       Likewise.
+       * testsuite/23_containers/unordered_multiset/modifiers/92878_92947.cc:
+       Likewise.
+       * testsuite/23_containers/unordered_set/modifiers/92878_92947.cc:
+       Likewise.
+       * testsuite/23_containers/vector/modifiers/emplace/92878_92947.cc:
+       Likewise.
+
 2020-03-28  Jonathan Wakely  <jwakely@redhat.com>
 
        * testsuite/20_util/is_constructible/value-2.cc: Fix test to account
diff --git a/libstdc++-v3/testsuite/20_util/allocator_traits/members/92878_92947.cc b/libstdc++-v3/testsuite/20_util/allocator_traits/members/92878_92947.cc
new file mode 100644 (file)
index 0000000..f84d0f7
--- /dev/null
@@ -0,0 +1,51 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct aggressive_aggregate
+{
+    int a;
+    int b;
+};
+
+void test01()
+{
+  aggressive_aggregate x;
+  std::allocator<aggressive_aggregate> a;
+  using traits = std::allocator_traits<std::allocator<aggressive_aggregate>>;
+  traits::destroy(a, &x);
+  traits::construct(a, &x, 1, 2);   
+  VERIFY(x.a == 1);
+  VERIFY(x.b == 2);
+  traits::destroy(a, &x);
+  traits::construct(a, &x, 1);   
+  VERIFY(x.a == 1);
+  VERIFY(x.b == 0);
+  traits::destroy(a, &x);
+  traits::construct(a, &x);   
+  VERIFY(x.a == 0);
+  VERIFY(x.b == 0);
+}
+
+int main()
+{
+  test01();
+}
diff --git a/libstdc++-v3/testsuite/20_util/any/assign/92878_92947.cc b/libstdc++-v3/testsuite/20_util/any/assign/92878_92947.cc
new file mode 100644 (file)
index 0000000..49f05ee
--- /dev/null
@@ -0,0 +1,46 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <any>
+#include <testsuite_hooks.h>
+
+struct aggressive_aggregate
+{
+    int a;
+    int b;
+};
+
+void test01()
+{
+  std::any x;
+  x.emplace<aggressive_aggregate>(1, 2);
+  VERIFY(std::any_cast<aggressive_aggregate>(x).a == 1);
+  VERIFY(std::any_cast<aggressive_aggregate>(x).b == 2);
+  x.emplace<aggressive_aggregate>(1);
+  VERIFY(std::any_cast<aggressive_aggregate>(x).a == 1);
+  VERIFY(std::any_cast<aggressive_aggregate>(x).b == 0);
+  x.emplace<aggressive_aggregate>();
+  VERIFY(std::any_cast<aggressive_aggregate>(x).a == 0);
+  VERIFY(std::any_cast<aggressive_aggregate>(x).b == 0);
+}
+
+int main()
+{
+  test01();
+}
diff --git a/libstdc++-v3/testsuite/20_util/any/cons/92878_92947.cc b/libstdc++-v3/testsuite/20_util/any/cons/92878_92947.cc
new file mode 100644 (file)
index 0000000..fa8aa2f
--- /dev/null
@@ -0,0 +1,46 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <any>
+#include <testsuite_hooks.h>
+
+struct aggressive_aggregate
+{
+    int a;
+    int b;
+};
+
+void test01()
+{
+  std::any x{std::in_place_type<aggressive_aggregate>, 1, 2};
+  VERIFY(std::any_cast<aggressive_aggregate>(x).a == 1);
+  VERIFY(std::any_cast<aggressive_aggregate>(x).b == 2);
+  std::any y{std::in_place_type<aggressive_aggregate>, 1};
+  VERIFY(std::any_cast<aggressive_aggregate>(y).a == 1);
+  VERIFY(std::any_cast<aggressive_aggregate>(y).b == 0);
+  std::any z{std::in_place_type<aggressive_aggregate>};
+  VERIFY(std::any_cast<aggressive_aggregate>(z).a == 0);
+  VERIFY(std::any_cast<aggressive_aggregate>(z).b == 0);
+}
+
+int main()
+{
+  test01();
+}
diff --git a/libstdc++-v3/testsuite/20_util/is_constructible/92878_92947.cc b/libstdc++-v3/testsuite/20_util/is_constructible/92878_92947.cc
new file mode 100644 (file)
index 0000000..567f9be
--- /dev/null
@@ -0,0 +1,49 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <type_traits>
+
+struct aggressive_aggregate
+{
+    int a;
+    int b;
+};
+
+struct vicious_variation
+{
+    int a;
+    int b = 42;
+};
+
+void test01()
+{
+  static_assert(std::is_constructible_v<aggressive_aggregate, int, int>);
+  static_assert(std::is_constructible_v<aggressive_aggregate, int>);
+  static_assert(std::is_constructible_v<aggressive_aggregate>);
+  static_assert(std::is_default_constructible_v<aggressive_aggregate>);
+  static_assert(std::is_trivially_default_constructible_v<
+               aggressive_aggregate>);
+  static_assert(std::is_constructible_v<vicious_variation, int, int>);
+  static_assert(std::is_constructible_v<vicious_variation, int>);
+  static_assert(std::is_constructible_v<vicious_variation>);
+  static_assert(std::is_default_constructible_v<vicious_variation>);
+  static_assert(!std::is_trivially_default_constructible_v<
+               vicious_variation>);
+}
diff --git a/libstdc++-v3/testsuite/20_util/optional/assignment/92878_92947.cc b/libstdc++-v3/testsuite/20_util/optional/assignment/92878_92947.cc
new file mode 100644 (file)
index 0000000..a5b74a2
--- /dev/null
@@ -0,0 +1,47 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <optional>
+#include <testsuite_hooks.h>
+
+struct aggressive_aggregate
+{
+    int a;
+    int b;
+};
+
+void test01()
+{
+  std::optional<aggressive_aggregate> x;
+  x.emplace(1, 2);
+  VERIFY(x->a == 1);
+  VERIFY(x->b == 2);
+  x.emplace(1);
+  VERIFY(x->a == 1);
+  VERIFY(x->b == 0);
+  x.emplace();
+  VERIFY(x->a == 0);
+  VERIFY(x->b == 0);
+}
+
+int main()
+{
+  test01();
+}
diff --git a/libstdc++-v3/testsuite/20_util/optional/cons/92878_92947.cc b/libstdc++-v3/testsuite/20_util/optional/cons/92878_92947.cc
new file mode 100644 (file)
index 0000000..52941e7
--- /dev/null
@@ -0,0 +1,46 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <optional>
+#include <testsuite_hooks.h>
+
+struct aggressive_aggregate
+{
+    int a;
+    int b;
+};
+
+void test01()
+{
+  std::optional<aggressive_aggregate> x{std::in_place, 1, 2};
+  VERIFY(x->a == 1);
+  VERIFY(x->b == 2);
+  std::optional<aggressive_aggregate> y{std::in_place, 1};
+  VERIFY(y->a == 1);
+  VERIFY(y->b == 0);
+  std::optional<aggressive_aggregate> z{std::in_place};
+  VERIFY(z->a == 0);
+  VERIFY(z->b == 0);
+}
+
+int main()
+{
+  test01();
+}
diff --git a/libstdc++-v3/testsuite/20_util/pair/cons/92878_92947.cc b/libstdc++-v3/testsuite/20_util/pair/cons/92878_92947.cc
new file mode 100644 (file)
index 0000000..ebc4e43
--- /dev/null
@@ -0,0 +1,49 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct aggressive_aggregate
+{
+    int a;
+    int b;
+};
+
+void test01()
+{
+  std::pair<aggressive_aggregate, int> x{std::piecewise_construct,
+                                        std::tuple{1, 2}, std::tuple{42}};
+  VERIFY(x.first.a == 1);
+  VERIFY(x.first.b == 2);
+  std::pair<aggressive_aggregate, int> y{std::piecewise_construct,
+                                        std::tuple{1}, std::tuple{42}};
+  VERIFY(y.first.a == 1);
+  VERIFY(y.first.b == 0);
+  std::pair<aggressive_aggregate, int> z{std::piecewise_construct,
+                                        std::tuple{}, std::tuple{42}};
+  VERIFY(z.first.a == 0);
+  VERIFY(z.first.b == 0);
+}
+
+int main()
+{
+  test01();
+}
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/creation/92878_92947.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/creation/92878_92947.cc
new file mode 100644 (file)
index 0000000..81a9382
--- /dev/null
@@ -0,0 +1,46 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct aggressive_aggregate
+{
+    int a;
+    int b;
+};
+
+void test01()
+{
+  auto x = std::make_shared<aggressive_aggregate>(1, 2);
+  VERIFY(x->a == 1);
+  VERIFY(x->b == 2);
+  auto y = std::make_shared<aggressive_aggregate>(1);
+  VERIFY(y->a == 1);
+  VERIFY(y->b == 0);
+  auto z = std::make_shared<aggressive_aggregate>();
+  VERIFY(z->a == 0);
+  VERIFY(z->b == 0);
+}
+
+int main()
+{
+  test01();
+}
diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/construct_at/92878_92947.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/construct_at/92878_92947.cc
new file mode 100644 (file)
index 0000000..ac22cef
--- /dev/null
@@ -0,0 +1,50 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct aggressive_aggregate
+{
+    int a;
+    int b;
+};
+
+void test01()
+{
+  aggressive_aggregate x;
+  std::destroy_at(&x);
+  std::construct_at(&x, 1, 2);   
+  VERIFY(x.a == 1);
+  VERIFY(x.b == 2);
+  std::destroy_at(&x);
+  std::construct_at(&x, 1);   
+  VERIFY(x.a == 1);
+  VERIFY(x.b == 0);
+  std::destroy_at(&x);
+  std::construct_at(&x);   
+  VERIFY(x.a == 0);
+  VERIFY(x.b == 0);
+}
+
+int main()
+{
+  test01();
+}
diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/creation/92878_92947.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/creation/92878_92947.cc
new file mode 100644 (file)
index 0000000..f84e735
--- /dev/null
@@ -0,0 +1,46 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct aggressive_aggregate
+{
+    int a;
+    int b;
+};
+
+void test01()
+{
+  auto x = std::make_unique<aggressive_aggregate>(1, 2);
+  VERIFY(x->a == 1);
+  VERIFY(x->b == 2);
+  auto y = std::make_unique<aggressive_aggregate>(1);
+  VERIFY(y->a == 1);
+  VERIFY(y->b == 0);
+  auto z = std::make_unique<aggressive_aggregate>();
+  VERIFY(z->a == 0);
+  VERIFY(z->b == 0);
+}
+
+int main()
+{
+  test01();
+}
diff --git a/libstdc++-v3/testsuite/20_util/uses_allocator/92878_92947.cc b/libstdc++-v3/testsuite/20_util/uses_allocator/92878_92947.cc
new file mode 100644 (file)
index 0000000..196d0a0
--- /dev/null
@@ -0,0 +1,67 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+struct aggressive_aggregate
+{
+    int a;
+    int b;
+};
+
+void test_make_obj_using_allocator()
+{
+  std::allocator<aggressive_aggregate> a;
+  auto x =
+    std::make_obj_using_allocator<aggressive_aggregate>(a, 1, 2);
+  VERIFY(x.a == 1);
+  VERIFY(x.b == 2);
+  x = std::make_obj_using_allocator<aggressive_aggregate>(a, 1);
+  VERIFY(x.a == 1);
+  VERIFY(x.b == 0);
+  x = std::make_obj_using_allocator<aggressive_aggregate>(a);
+  VERIFY(x.a == 0);
+  VERIFY(x.b == 0);
+}
+
+void test_uninitialized_construct_using_allocator()
+{
+  std::allocator<aggressive_aggregate> a;
+  aggressive_aggregate x;
+  std::destroy_at(&x);
+  std::uninitialized_construct_using_allocator(&x, a, 1, 2);
+  VERIFY(x.a == 1);
+  VERIFY(x.b == 2);
+  std::destroy_at(&x);
+  std::uninitialized_construct_using_allocator(&x, a, 1);
+  VERIFY(x.a == 1);
+  VERIFY(x.b == 0);
+  std::destroy_at(&x);
+  std::uninitialized_construct_using_allocator(&x, a);
+  VERIFY(x.a == 0);
+  VERIFY(x.b == 0);
+}
+
+int main()
+{
+  test_make_obj_using_allocator();
+  test_uninitialized_construct_using_allocator();
+}
diff --git a/libstdc++-v3/testsuite/20_util/variant/92878_92947.cc b/libstdc++-v3/testsuite/20_util/variant/92878_92947.cc
new file mode 100644 (file)
index 0000000..48bad9f
--- /dev/null
@@ -0,0 +1,91 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <variant>
+#include <testsuite_hooks.h>
+
+struct aggressive_aggregate
+{
+    int a;
+    int b;
+};
+
+struct dumbo
+{
+  dumbo() = delete;
+};
+
+void test_emplace()
+{
+  std::variant<aggressive_aggregate, dumbo> x;
+  x.emplace<aggressive_aggregate>(1, 2);
+  VERIFY(x.index() == 0);
+  VERIFY(std::get<0>(x).a == 1);
+  VERIFY(std::get<0>(x).b == 2);
+  x.emplace<aggressive_aggregate>(1);
+  VERIFY(x.index() == 0);
+  VERIFY(std::get<0>(x).a == 1);
+  VERIFY(std::get<0>(x).b == 0);
+  x.emplace<aggressive_aggregate>();
+  VERIFY(x.index() == 0);
+  VERIFY(std::get<0>(x).a == 0);
+  VERIFY(std::get<0>(x).b == 0);
+}
+
+void test_in_place_type_construct()
+{
+  using Var = std::variant<aggressive_aggregate, dumbo>;
+  Var x{std::in_place_type<aggressive_aggregate>, 1,2};
+  VERIFY(x.index() == 0);
+  VERIFY(std::get<0>(x).a == 1);
+  VERIFY(std::get<0>(x).b == 2);
+  Var y{std::in_place_type<aggressive_aggregate>, 1};
+  VERIFY(y.index() == 0);
+  VERIFY(std::get<0>(y).a == 1);
+  VERIFY(std::get<0>(y).b == 0);
+  Var z{std::in_place_type<aggressive_aggregate>};
+  VERIFY(z.index() == 0);
+  VERIFY(std::get<0>(z).a == 0);
+  VERIFY(std::get<0>(z).b == 0);
+}
+
+void test_in_place_index_construct()
+{
+  using Var = std::variant<aggressive_aggregate, dumbo>;
+  Var x{std::in_place_index<0>, 1,2};
+  VERIFY(x.index() == 0);
+  VERIFY(std::get<0>(x).a == 1);
+  VERIFY(std::get<0>(x).b == 2);
+  Var y{std::in_place_index<0>, 1};
+  VERIFY(y.index() == 0);
+  VERIFY(std::get<0>(y).a == 1);
+  VERIFY(std::get<0>(y).b == 0);
+  Var z{std::in_place_index<0>};
+  VERIFY(z.index() == 0);
+  VERIFY(std::get<0>(z).a == 0);
+  VERIFY(std::get<0>(z).b == 0);
+}
+
+int main()
+{
+  test_emplace();
+  test_in_place_type_construct();
+  test_in_place_index_construct();
+}
diff --git a/libstdc++-v3/testsuite/23_containers/deque/modifiers/emplace/92878_92947.cc b/libstdc++-v3/testsuite/23_containers/deque/modifiers/emplace/92878_92947.cc
new file mode 100644 (file)
index 0000000..3dc75db
--- /dev/null
@@ -0,0 +1,62 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <deque>
+#include <testsuite_hooks.h>
+
+struct aggressive_aggregate
+{
+    int a;
+    int b;
+};
+
+void test_emplace_front()
+{
+  std::deque<aggressive_aggregate> x;
+  x.emplace_front(1, 2);
+  VERIFY(x.front().a == 1);
+  VERIFY(x.front().b == 2);
+  x.emplace_front(1);
+  VERIFY(x.front().a == 1);
+  VERIFY(x.front().b == 0);
+  x.emplace_front();
+  VERIFY(x.front().a == 0);
+  VERIFY(x.front().b == 0);
+}
+
+void test_emplace_back()
+{
+  std::deque<aggressive_aggregate> x;
+  x.emplace_back(1, 2);
+  VERIFY(x.back().a == 1);
+  VERIFY(x.back().b == 2);
+  x.emplace_back(1);
+  VERIFY(x.back().a == 1);
+  VERIFY(x.back().b == 0);
+  x.emplace_back();
+  VERIFY(x.back().a == 0);
+  VERIFY(x.back().b == 0);
+}
+
+int main()
+{
+  test_emplace_front();
+  test_emplace_back();
+}
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/92878_92947.cc b/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/92878_92947.cc
new file mode 100644 (file)
index 0000000..874b9f5
--- /dev/null
@@ -0,0 +1,62 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <forward_list>
+#include <testsuite_hooks.h>
+
+struct aggressive_aggregate
+{
+    int a;
+    int b;
+};
+
+void test_emplace_front()
+{
+  std::forward_list<aggressive_aggregate> x;
+  x.emplace_front(1, 2);
+  VERIFY(x.front().a == 1);
+  VERIFY(x.front().b == 2);
+  x.emplace_front(1);
+  VERIFY(x.front().a == 1);
+  VERIFY(x.front().b == 0);
+  x.emplace_front();
+  VERIFY(x.front().a == 0);
+  VERIFY(x.front().b == 0);
+}
+
+void test_emplace_after()
+{
+  std::forward_list<aggressive_aggregate> x{{42, 666}};
+  auto y = x.emplace_after(x.begin(), 1, 2);
+  VERIFY(y->a == 1);
+  VERIFY(y->b == 2);
+  y = x.emplace_after(x.begin(), 1);
+  VERIFY(y->a == 1);
+  VERIFY(y->b == 0);
+  y = x.emplace_after(x.begin());
+  VERIFY(y->a == 0);
+  VERIFY(y->b == 0);
+}
+
+int main()
+{
+  test_emplace_front();
+  test_emplace_after();
+}
diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/emplace/92878_92947.cc b/libstdc++-v3/testsuite/23_containers/list/modifiers/emplace/92878_92947.cc
new file mode 100644 (file)
index 0000000..eb1e9f3
--- /dev/null
@@ -0,0 +1,78 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <list>
+#include <testsuite_hooks.h>
+
+struct aggressive_aggregate
+{
+    int a;
+    int b;
+};
+
+void test_emplace_front()
+{
+  std::list<aggressive_aggregate> x;
+  x.emplace_front(1, 2);
+  VERIFY(x.front().a == 1);
+  VERIFY(x.front().b == 2);
+  x.emplace_front(1);
+  VERIFY(x.front().a == 1);
+  VERIFY(x.front().b == 0);
+  x.emplace_front();
+  VERIFY(x.front().a == 0);
+  VERIFY(x.front().b == 0);
+}
+
+void test_emplace_back()
+{
+  std::list<aggressive_aggregate> x;
+  x.emplace_back(1, 2);
+  VERIFY(x.back().a == 1);
+  VERIFY(x.back().b == 2);
+  x.emplace_back(1);
+  VERIFY(x.back().a == 1);
+  VERIFY(x.back().b == 0);
+  x.emplace_back();
+  VERIFY(x.back().a == 0);
+  VERIFY(x.back().b == 0);
+}
+
+void test_emplace()
+{
+  std::list<aggressive_aggregate> x{{42, 666}};
+  auto y = x.emplace(x.begin(), 1, 2);
+  VERIFY(y->a == 1);
+  VERIFY(y->b == 2);
+  y = x.emplace(x.begin(), 1);
+  VERIFY(y->a == 1);
+  VERIFY(y->b == 0);
+  y = x.emplace(x.begin());
+  VERIFY(y->a == 0);
+  VERIFY(y->b == 0);
+}
+
+
+int main()
+{
+  test_emplace_front();
+  test_emplace_back();
+  test_emplace();
+}
diff --git a/libstdc++-v3/testsuite/23_containers/map/modifiers/emplace/92878_92947.cc b/libstdc++-v3/testsuite/23_containers/map/modifiers/emplace/92878_92947.cc
new file mode 100644 (file)
index 0000000..648a525
--- /dev/null
@@ -0,0 +1,137 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <map>
+#include <testsuite_hooks.h>
+
+struct aggressive_aggregate
+{
+    int a;
+    int b;
+};
+
+void test_emplace()
+{
+  std::map<int, aggressive_aggregate> x;
+  auto emplaced = x.emplace(std::piecewise_construct,
+                           std::tuple(0), std::tuple(1, 2));
+  VERIFY(emplaced.first->second.a == 1);
+  VERIFY(emplaced.first->second.b == 2);
+  emplaced = x.emplace(std::piecewise_construct,
+                      std::tuple(1), std::tuple(1));
+  VERIFY(emplaced.first->second.a == 1);
+  VERIFY(emplaced.first->second.b == 0);
+  emplaced = x.emplace(std::piecewise_construct,
+                      std::tuple(2), std::tuple());
+  VERIFY(emplaced.first->second.a == 0);
+  VERIFY(emplaced.first->second.b == 0);
+}
+
+void test_emplace_hint()
+{
+  std::map<int, aggressive_aggregate> x;
+  auto it = x.emplace_hint(x.begin(),
+                          std::piecewise_construct,
+                          std::tuple(3), std::tuple(1, 2));
+  VERIFY(it->second.a == 1);
+  VERIFY(it->second.b == 2);
+  it = x.emplace_hint(x.begin(),
+                     std::piecewise_construct,
+                     std::tuple(4), std::tuple(1));
+  VERIFY(it->second.a == 1);
+  VERIFY(it->second.b == 0);
+  it = x.emplace_hint(x.begin(),
+                     std::piecewise_construct,
+                     std::tuple(5), std::tuple());
+  VERIFY(it->second.a == 0);
+  VERIFY(it->second.b == 0);
+}
+
+void test_try_emplace_rvalue()
+{
+  std::map<int, aggressive_aggregate> x;
+  auto emplaced = x.try_emplace(6, 1, 2);
+  VERIFY(emplaced.first->second.a == 1);
+  VERIFY(emplaced.first->second.b == 2);
+  emplaced = x.try_emplace(7, 1);
+  VERIFY(emplaced.first->second.a == 1);
+  VERIFY(emplaced.first->second.b == 0);
+  emplaced = x.try_emplace(8);
+  VERIFY(emplaced.first->second.a == 0);
+  VERIFY(emplaced.first->second.b == 0);
+}
+
+void test_try_emplace_lvalue()
+{
+  std::map<int, aggressive_aggregate> x;
+  int key = 9;
+  auto emplaced = x.try_emplace(key, 1, 2);
+  VERIFY(emplaced.first->second.a == 1);
+  VERIFY(emplaced.first->second.b == 2);
+  key = 10;
+  emplaced = x.try_emplace(key, 1);
+  VERIFY(emplaced.first->second.a == 1);
+  VERIFY(emplaced.first->second.b == 0);
+  key = 11;
+  emplaced = x.try_emplace(key);
+  VERIFY(emplaced.first->second.a == 0);
+  VERIFY(emplaced.first->second.b == 0);
+}
+
+void test_try_emplace_hint_rvalue()
+{
+  std::map<int, aggressive_aggregate> x;
+  auto it = x.try_emplace(x.begin(), 12, 1, 2);
+  VERIFY(it->second.a == 1);
+  VERIFY(it->second.b == 2);
+  it = x.try_emplace(x.begin(), 13, 1);
+  VERIFY(it->second.a == 1);
+  VERIFY(it->second.b == 0);
+  it = x.try_emplace(x.begin(), 14);
+  VERIFY(it->second.a == 0);
+  VERIFY(it->second.b == 0);
+}
+
+void test_try_emplace_hint_lvalue()
+{
+  std::map<int, aggressive_aggregate> x;
+  int key = 15;
+  auto it = x.try_emplace(x.begin(), key, 1, 2);
+  VERIFY(it->second.a == 1);
+  VERIFY(it->second.b == 2);
+  key = 16;
+  it = x.try_emplace(x.begin(), key, 1);
+  VERIFY(it->second.a == 1);
+  VERIFY(it->second.b == 0);
+  key = 17;
+  it = x.try_emplace(x.begin(), key);
+  VERIFY(it->second.a == 0);
+  VERIFY(it->second.b == 0);
+}
+
+int main()
+{
+  test_emplace();
+  test_emplace_hint();
+  test_try_emplace_rvalue();
+  test_try_emplace_lvalue();
+  test_try_emplace_hint_rvalue();
+  test_try_emplace_hint_lvalue();
+}
diff --git a/libstdc++-v3/testsuite/23_containers/multimap/modifiers/emplace/92878_92947.cc b/libstdc++-v3/testsuite/23_containers/multimap/modifiers/emplace/92878_92947.cc
new file mode 100644 (file)
index 0000000..9ded663
--- /dev/null
@@ -0,0 +1,71 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <map>
+#include <testsuite_hooks.h>
+
+struct aggressive_aggregate
+{
+    int a;
+    int b;
+};
+
+void test_emplace()
+{
+  std::multimap<int, aggressive_aggregate> x;
+  auto it = x.emplace(std::piecewise_construct,
+                           std::tuple(0), std::tuple(1, 2));
+  VERIFY(it->second.a == 1);
+  VERIFY(it->second.b == 2);
+  it = x.emplace(std::piecewise_construct,
+                      std::tuple(1), std::tuple(1));
+  VERIFY(it->second.a == 1);
+  VERIFY(it->second.b == 0);
+  it = x.emplace(std::piecewise_construct,
+                      std::tuple(2), std::tuple());
+  VERIFY(it->second.a == 0);
+  VERIFY(it->second.b == 0);
+}
+
+void test_emplace_hint()
+{
+  std::multimap<int, aggressive_aggregate> x;
+  auto it = x.emplace_hint(x.begin(),
+                          std::piecewise_construct,
+                          std::tuple(3), std::tuple(1, 2));
+  VERIFY(it->second.a == 1);
+  VERIFY(it->second.b == 2);
+  it = x.emplace_hint(x.begin(),
+                     std::piecewise_construct,
+                     std::tuple(4), std::tuple(1));
+  VERIFY(it->second.a == 1);
+  VERIFY(it->second.b == 0);
+  it = x.emplace_hint(x.begin(),
+                     std::piecewise_construct,
+                     std::tuple(5), std::tuple());
+  VERIFY(it->second.a == 0);
+  VERIFY(it->second.b == 0);
+}
+
+int main()
+{
+  test_emplace();
+  test_emplace_hint();
+}
diff --git a/libstdc++-v3/testsuite/23_containers/multiset/modifiers/emplace/92878_92947.cc b/libstdc++-v3/testsuite/23_containers/multiset/modifiers/emplace/92878_92947.cc
new file mode 100644 (file)
index 0000000..85df099
--- /dev/null
@@ -0,0 +1,70 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <set>
+#include <testsuite_hooks.h>
+
+struct aggressive_aggregate
+{
+    int a;
+    int b;
+};
+
+bool operator<(const aggressive_aggregate& a,
+              const aggressive_aggregate& b)
+{
+  return a.a < b.a;
+};
+
+void test_emplace()
+{
+  std::multiset<aggressive_aggregate> x;
+  auto it = x.emplace(1, 2);
+  VERIFY(it->a == 1);
+  VERIFY(it->b == 2);
+  it = x.emplace(2);
+  VERIFY(it->a == 2);
+  VERIFY(it->b == 0);
+  it = x.emplace();
+  VERIFY(it->a == 0);
+  VERIFY(it->b == 0);
+}
+
+void test_emplace_hint()
+{
+  std::multiset<aggressive_aggregate> x;
+  auto it = x.emplace_hint(x.begin(),
+                     3, 2);
+  VERIFY(it->a == 3);
+  VERIFY(it->b == 2);
+  it = x.emplace_hint(x.begin(),
+                     4);
+  VERIFY(it->a == 4);
+  VERIFY(it->b == 0);
+  it = x.emplace_hint(x.begin());
+  VERIFY(it->a == 0);
+  VERIFY(it->b == 0);
+}
+
+int main()
+{
+  test_emplace();
+  test_emplace_hint();
+}
diff --git a/libstdc++-v3/testsuite/23_containers/priority_queue/92878_92947.cc b/libstdc++-v3/testsuite/23_containers/priority_queue/92878_92947.cc
new file mode 100644 (file)
index 0000000..1111f8c
--- /dev/null
@@ -0,0 +1,52 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <queue>
+#include <testsuite_hooks.h>
+
+struct aggressive_aggregate
+{
+    int a;
+    int b;
+};
+
+bool operator<(const aggressive_aggregate& a, const aggressive_aggregate& b)
+{
+  return a.a < b.a;
+}
+
+void test01()
+{
+  std::priority_queue<aggressive_aggregate> x;
+  x.emplace();
+  VERIFY(x.top().a == 0);
+  VERIFY(x.top().b == 0);
+  x.emplace(1, 2);
+  VERIFY(x.top().a == 1);
+  VERIFY(x.top().b == 2);
+  x.emplace(2);
+  VERIFY(x.top().a == 2);
+  VERIFY(x.top().b == 0);
+}
+
+int main()
+{
+  test01();
+}
diff --git a/libstdc++-v3/testsuite/23_containers/queue/92878_92947.cc b/libstdc++-v3/testsuite/23_containers/queue/92878_92947.cc
new file mode 100644 (file)
index 0000000..e328b36
--- /dev/null
@@ -0,0 +1,47 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <queue>
+#include <testsuite_hooks.h>
+
+struct aggressive_aggregate
+{
+    int a;
+    int b;
+};
+
+void test01()
+{
+  std::queue<aggressive_aggregate> x;
+  x.emplace(1, 2);
+  VERIFY(x.back().a == 1);
+  VERIFY(x.back().b == 2);
+  x.emplace(1);
+  VERIFY(x.back().a == 1);
+  VERIFY(x.back().b == 0);
+  x.emplace();
+  VERIFY(x.back().a == 0);
+  VERIFY(x.back().b == 0);
+}
+
+int main()
+{
+  test01();
+}
diff --git a/libstdc++-v3/testsuite/23_containers/set/modifiers/emplace/92878_92947.cc b/libstdc++-v3/testsuite/23_containers/set/modifiers/emplace/92878_92947.cc
new file mode 100644 (file)
index 0000000..8183b50
--- /dev/null
@@ -0,0 +1,70 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <set>
+#include <testsuite_hooks.h>
+
+struct aggressive_aggregate
+{
+    int a;
+    int b;
+};
+
+bool operator<(const aggressive_aggregate& a,
+              const aggressive_aggregate& b)
+{
+  return a.a < b.a;
+};
+
+void test_emplace()
+{
+  std::set<aggressive_aggregate> x;
+  auto emplaced = x.emplace(1, 2);
+  VERIFY(emplaced.first->a == 1);
+  VERIFY(emplaced.first->b == 2);
+  emplaced = x.emplace(2);
+  VERIFY(emplaced.first->a == 2);
+  VERIFY(emplaced.first->b == 0);
+  emplaced = x.emplace();
+  VERIFY(emplaced.first->a == 0);
+  VERIFY(emplaced.first->b == 0);
+}
+
+void test_emplace_hint()
+{
+  std::set<aggressive_aggregate> x;
+  auto it = x.emplace_hint(x.begin(),
+                     3, 2);
+  VERIFY(it->a == 3);
+  VERIFY(it->b == 2);
+  it = x.emplace_hint(x.begin(),
+                     4);
+  VERIFY(it->a == 4);
+  VERIFY(it->b == 0);
+  it = x.emplace_hint(x.begin());
+  VERIFY(it->a == 0);
+  VERIFY(it->b == 0);
+}
+
+int main()
+{
+  test_emplace();
+  test_emplace_hint();
+}
diff --git a/libstdc++-v3/testsuite/23_containers/stack/92878_92947.cc b/libstdc++-v3/testsuite/23_containers/stack/92878_92947.cc
new file mode 100644 (file)
index 0000000..c452240
--- /dev/null
@@ -0,0 +1,47 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <stack>
+#include <testsuite_hooks.h>
+
+struct aggressive_aggregate
+{
+    int a;
+    int b;
+};
+
+void test01()
+{
+  std::stack<aggressive_aggregate> x;
+  x.emplace();
+  VERIFY(x.top().a == 0);
+  VERIFY(x.top().b == 0);
+  x.emplace(1, 2);
+  VERIFY(x.top().a == 1);
+  VERIFY(x.top().b == 2);
+  x.emplace(2);
+  VERIFY(x.top().a == 2);
+  VERIFY(x.top().b == 0);
+}
+
+int main()
+{
+  test01();
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/modifiers/92878_92947.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/modifiers/92878_92947.cc
new file mode 100644 (file)
index 0000000..2c8e6ca
--- /dev/null
@@ -0,0 +1,137 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <unordered_map>
+#include <testsuite_hooks.h>
+
+struct aggressive_aggregate
+{
+    int a;
+    int b;
+};
+
+void test_emplace()
+{
+  std::unordered_map<int, aggressive_aggregate> x;
+  auto emplaced = x.emplace(std::piecewise_construct,
+                           std::tuple(0), std::tuple(1, 2));
+  VERIFY(emplaced.first->second.a == 1);
+  VERIFY(emplaced.first->second.b == 2);
+  emplaced = x.emplace(std::piecewise_construct,
+                      std::tuple(1), std::tuple(1));
+  VERIFY(emplaced.first->second.a == 1);
+  VERIFY(emplaced.first->second.b == 0);
+  emplaced = x.emplace(std::piecewise_construct,
+                      std::tuple(2), std::tuple());
+  VERIFY(emplaced.first->second.a == 0);
+  VERIFY(emplaced.first->second.b == 0);
+}
+
+void test_emplace_hint()
+{
+  std::unordered_map<int, aggressive_aggregate> x;
+  auto it = x.emplace_hint(x.begin(),
+                          std::piecewise_construct,
+                          std::tuple(3), std::tuple(1, 2));
+  VERIFY(it->second.a == 1);
+  VERIFY(it->second.b == 2);
+  it = x.emplace_hint(x.begin(),
+                     std::piecewise_construct,
+                     std::tuple(4), std::tuple(1));
+  VERIFY(it->second.a == 1);
+  VERIFY(it->second.b == 0);
+  it = x.emplace_hint(x.begin(),
+                     std::piecewise_construct,
+                     std::tuple(5), std::tuple());
+  VERIFY(it->second.a == 0);
+  VERIFY(it->second.b == 0);
+}
+
+void test_try_emplace_rvalue()
+{
+  std::unordered_map<int, aggressive_aggregate> x;
+  auto emplaced = x.try_emplace(6, 1, 2);
+  VERIFY(emplaced.first->second.a == 1);
+  VERIFY(emplaced.first->second.b == 2);
+  emplaced = x.try_emplace(7, 1);
+  VERIFY(emplaced.first->second.a == 1);
+  VERIFY(emplaced.first->second.b == 0);
+  emplaced = x.try_emplace(8);
+  VERIFY(emplaced.first->second.a == 0);
+  VERIFY(emplaced.first->second.b == 0);
+}
+
+void test_try_emplace_lvalue()
+{
+  std::unordered_map<int, aggressive_aggregate> x;
+  int key = 9;
+  auto emplaced = x.try_emplace(key, 1, 2);
+  VERIFY(emplaced.first->second.a == 1);
+  VERIFY(emplaced.first->second.b == 2);
+  key = 10;
+  emplaced = x.try_emplace(key, 1);
+  VERIFY(emplaced.first->second.a == 1);
+  VERIFY(emplaced.first->second.b == 0);
+  key = 11;
+  emplaced = x.try_emplace(key);
+  VERIFY(emplaced.first->second.a == 0);
+  VERIFY(emplaced.first->second.b == 0);
+}
+
+void test_try_emplace_hint_rvalue()
+{
+  std::unordered_map<int, aggressive_aggregate> x;
+  auto it = x.try_emplace(x.begin(), 12, 1, 2);
+  VERIFY(it->second.a == 1);
+  VERIFY(it->second.b == 2);
+  it = x.try_emplace(x.begin(), 13, 1);
+  VERIFY(it->second.a == 1);
+  VERIFY(it->second.b == 0);
+  it = x.try_emplace(x.begin(), 14);
+  VERIFY(it->second.a == 0);
+  VERIFY(it->second.b == 0);
+}
+
+void test_try_emplace_hint_lvalue()
+{
+  std::unordered_map<int, aggressive_aggregate> x;
+  int key = 15;
+  auto it = x.try_emplace(x.begin(), key, 1, 2);
+  VERIFY(it->second.a == 1);
+  VERIFY(it->second.b == 2);
+  key = 16;
+  it = x.try_emplace(x.begin(), key, 1);
+  VERIFY(it->second.a == 1);
+  VERIFY(it->second.b == 0);
+  key = 17;
+  it = x.try_emplace(x.begin(), key);
+  VERIFY(it->second.a == 0);
+  VERIFY(it->second.b == 0);
+}
+
+int main()
+{
+  test_emplace();
+  test_emplace_hint();
+  test_try_emplace_rvalue();
+  test_try_emplace_lvalue();
+  test_try_emplace_hint_rvalue();
+  test_try_emplace_hint_lvalue();
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/modifiers/92878_92947.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/modifiers/92878_92947.cc
new file mode 100644 (file)
index 0000000..4da3c51
--- /dev/null
@@ -0,0 +1,71 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <unordered_map>
+#include <testsuite_hooks.h>
+
+struct aggressive_aggregate
+{
+    int a;
+    int b;
+};
+
+void test_emplace()
+{
+  std::unordered_multimap<int, aggressive_aggregate> x;
+  auto it = x.emplace(std::piecewise_construct,
+                           std::tuple(0), std::tuple(1, 2));
+  VERIFY(it->second.a == 1);
+  VERIFY(it->second.b == 2);
+  it = x.emplace(std::piecewise_construct,
+                      std::tuple(1), std::tuple(1));
+  VERIFY(it->second.a == 1);
+  VERIFY(it->second.b == 0);
+  it = x.emplace(std::piecewise_construct,
+                      std::tuple(2), std::tuple());
+  VERIFY(it->second.a == 0);
+  VERIFY(it->second.b == 0);
+}
+
+void test_emplace_hint()
+{
+  std::unordered_multimap<int, aggressive_aggregate> x;
+  auto it = x.emplace_hint(x.begin(),
+                          std::piecewise_construct,
+                          std::tuple(3), std::tuple(1, 2));
+  VERIFY(it->second.a == 1);
+  VERIFY(it->second.b == 2);
+  it = x.emplace_hint(x.begin(),
+                     std::piecewise_construct,
+                     std::tuple(4), std::tuple(1));
+  VERIFY(it->second.a == 1);
+  VERIFY(it->second.b == 0);
+  it = x.emplace_hint(x.begin(),
+                     std::piecewise_construct,
+                     std::tuple(5), std::tuple());
+  VERIFY(it->second.a == 0);
+  VERIFY(it->second.b == 0);
+}
+
+int main()
+{
+  test_emplace();
+  test_emplace_hint();
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/modifiers/92878_92947.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/modifiers/92878_92947.cc
new file mode 100644 (file)
index 0000000..ec0c86e
--- /dev/null
@@ -0,0 +1,78 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <unordered_set>
+#include <testsuite_hooks.h>
+
+struct aggressive_aggregate
+{
+    int a;
+    int b;
+};
+
+bool operator==(const aggressive_aggregate& a,
+              const aggressive_aggregate& b)
+{
+  return a.a == b.a;
+};
+
+namespace std {
+  template<> struct hash<aggressive_aggregate> {
+    size_t operator()(const aggressive_aggregate& x) const {
+      return std::hash<int>()(x.a);
+    }
+  };
+}
+
+void test_emplace()
+{
+  std::unordered_multiset<aggressive_aggregate> x;
+  auto it = x.emplace(1, 2);
+  VERIFY(it->a == 1);
+  VERIFY(it->b == 2);
+  it = x.emplace(2);
+  VERIFY(it->a == 2);
+  VERIFY(it->b == 0);
+  it = x.emplace();
+  VERIFY(it->a == 0);
+  VERIFY(it->b == 0);
+}
+
+void test_emplace_hint()
+{
+  std::unordered_multiset<aggressive_aggregate> x;
+  auto it = x.emplace_hint(x.begin(),
+                     3, 2);
+  VERIFY(it->a == 3);
+  VERIFY(it->b == 2);
+  it = x.emplace_hint(x.begin(),
+                     4);
+  VERIFY(it->a == 4);
+  VERIFY(it->b == 0);
+  it = x.emplace_hint(x.begin());
+  VERIFY(it->a == 0);
+  VERIFY(it->b == 0);
+}
+
+int main()
+{
+  test_emplace();
+  test_emplace_hint();
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/modifiers/92878_92947.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/modifiers/92878_92947.cc
new file mode 100644 (file)
index 0000000..447e1a8
--- /dev/null
@@ -0,0 +1,78 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <unordered_set>
+#include <testsuite_hooks.h>
+
+struct aggressive_aggregate
+{
+    int a;
+    int b;
+};
+
+bool operator==(const aggressive_aggregate& a,
+              const aggressive_aggregate& b)
+{
+  return a.a == b.a;
+};
+
+namespace std {
+  template<> struct hash<aggressive_aggregate> {
+    size_t operator()(const aggressive_aggregate& x) const {
+      return std::hash<int>()(x.a);
+    }
+  };
+}
+
+void test_emplace()
+{
+  std::unordered_set<aggressive_aggregate> x;
+  auto emplaced = x.emplace(1, 2);
+  VERIFY(emplaced.first->a == 1);
+  VERIFY(emplaced.first->b == 2);
+  emplaced = x.emplace(2);
+  VERIFY(emplaced.first->a == 2);
+  VERIFY(emplaced.first->b == 0);
+  emplaced = x.emplace();
+  VERIFY(emplaced.first->a == 0);
+  VERIFY(emplaced.first->b == 0);
+}
+
+void test_emplace_hint()
+{
+  std::unordered_set<aggressive_aggregate> x;
+  auto it = x.emplace_hint(x.begin(),
+                     3, 2);
+  VERIFY(it->a == 3);
+  VERIFY(it->b == 2);
+  it = x.emplace_hint(x.begin(),
+                     4);
+  VERIFY(it->a == 4);
+  VERIFY(it->b == 0);
+  it = x.emplace_hint(x.begin());
+  VERIFY(it->a == 0);
+  VERIFY(it->b == 0);
+}
+
+int main()
+{
+  test_emplace();
+  test_emplace_hint();
+}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/modifiers/emplace/92878_92947.cc b/libstdc++-v3/testsuite/23_containers/vector/modifiers/emplace/92878_92947.cc
new file mode 100644 (file)
index 0000000..a33bf39
--- /dev/null
@@ -0,0 +1,61 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <vector>
+#include <testsuite_hooks.h>
+
+struct aggressive_aggregate
+{
+    int a;
+    int b;
+};
+
+void test_emplace()
+{
+  std::vector<aggressive_aggregate> x{{42, 666}};
+  auto y = x.emplace(x.begin(), 1, 2);
+  VERIFY(y->a == 1);
+  VERIFY(y->b == 2);
+  y = x.emplace(x.begin(), 1);
+  VERIFY(y->a == 1);
+  VERIFY(y->b == 0);
+  y = x.emplace(x.begin());
+  VERIFY(y->a == 0);
+  VERIFY(y->b == 0);
+}
+
+void test_emplace_back()
+{
+  std::vector<aggressive_aggregate> x;
+  x.emplace_back(1, 2);
+  VERIFY(x.back().a == 1);
+  VERIFY(x.back().b == 2);
+  x.emplace_back(1);
+  VERIFY(x.back().a == 1);
+  VERIFY(x.back().b == 0);
+  x.emplace_back();
+  VERIFY(x.back().a == 0);
+  VERIFY(x.back().b == 0);
+}
+
+int main()
+{
+  test_emplace();
+  test_emplace_back();
+}