public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Aldy Hernandez <aldyh@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc/devel/ranger] libstdc++: Fix tests that fail in C++20 mode
Date: Wed, 17 Jun 2020 20:34:45 +0000 (GMT)	[thread overview]
Message-ID: <20200617203445.76F44398642C@sourceware.org> (raw)

https://gcc.gnu.org/g:0ea89b15782a4ee92bae0175a0a963752c39076c

commit 0ea89b15782a4ee92bae0175a0a963752c39076c
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Apr 20 22:06:32 2020 +0100

    libstdc++: Fix tests that fail in C++20 mode
    
            * testsuite/20_util/is_constructible/51185.cc: Make test class a
            non-aggregate so that the test verifies the same thing in all -std
            modes.
            * testsuite/20_util/is_constructible/value-2.cc: Adjust expected
            results for some types when paren-init for aggregates is supported.

Diff:
---
 libstdc++-v3/ChangeLog                             |  6 +++++
 .../testsuite/20_util/is_constructible/51185.cc    |  9 ++++++-
 .../testsuite/20_util/is_constructible/value-2.cc  | 31 ++++++++++++++++------
 3 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 9f4c9d327c3..932e2afe812 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,11 @@
 2020-04-20  Jonathan Wakely  <jwakely@redhat.com>
 
+	* testsuite/20_util/is_constructible/51185.cc: Make test class a
+	non-aggregate so that the test verifies the same thing in all -std
+	modes.
+	* testsuite/20_util/is_constructible/value-2.cc: Adjust expected
+	results for some types when paren-init for aggregates is supported.
+
 	* include/std/version (__cpp_lib_three_way_comparison): Update value.
 	* libsupc++/compare (__cpp_lib_three_way_comparison): Likewise.
 	(__detail::__synth3way): Add noexcept-specifier.
diff --git a/libstdc++-v3/testsuite/20_util/is_constructible/51185.cc b/libstdc++-v3/testsuite/20_util/is_constructible/51185.cc
index d2750d8607e..8605135ad5a 100644
--- a/libstdc++-v3/testsuite/20_util/is_constructible/51185.cc
+++ b/libstdc++-v3/testsuite/20_util/is_constructible/51185.cc
@@ -20,7 +20,14 @@
 #include <type_traits>
 
 struct A { };
-struct B : A { };
+struct B : A {
+#if __cpp_aggregate_bases && __cpp_aggregate_paren_init
+  // A user-declared constructor prevents B from being an aggregate.
+  // Otherwise 'B&& b{A{}};' becomes valid in C++17 (__cpp_aggregate_bases),
+  // and 'B&& b(A{});' becomes valid in C++17 (__cpp_aggregate_paren_init).
+  B();
+#endif
+};
 
 // libstdc++/51185
 void f()
diff --git a/libstdc++-v3/testsuite/20_util/is_constructible/value-2.cc b/libstdc++-v3/testsuite/20_util/is_constructible/value-2.cc
index c54b749c046..8ba50e1efe7 100644
--- a/libstdc++-v3/testsuite/20_util/is_constructible/value-2.cc
+++ b/libstdc++-v3/testsuite/20_util/is_constructible/value-2.cc
@@ -216,12 +216,20 @@ static_assert(std::is_constructible<const B&&, D&&>::value, "Error");
 static_assert(!std::is_constructible<B&, const D&>::value, "Error");
 static_assert(!std::is_constructible<B&&, const D&&>::value, "Error");
 
+#if __cpp_aggregate_bases && __cpp_aggregate_paren_init
+// In C++20 an rvalue reference or const lvalue reference can bind to a
+// temporary of aggregate type that is initialized from a base class value.
+constexpr bool v = true;
+#else
+constexpr bool v = false;
+#endif
+
 static_assert(!std::is_constructible<D&, B&>::value, "Error");
-static_assert(!std::is_constructible<D&&, B&&>::value, "Error");
+static_assert(v == std::is_constructible<D&&, B&&>::value, "Error");
 static_assert(!std::is_constructible<D&, const B&>::value, "Error");
-static_assert(!std::is_constructible<D&&, const B&&>::value, "Error");
-static_assert(!std::is_constructible<const D&, B&>::value, "Error");
-static_assert(!std::is_constructible<const D&&, B&&>::value, "Error");
+static_assert(v == std::is_constructible<D&&, const B&&>::value, "Error");
+static_assert(v == std::is_constructible<const D&, B&>::value, "Error");
+static_assert(v == std::is_constructible<const D&&, B&&>::value, "Error");
 
 static_assert(!std::is_constructible<B&&, B&>::value, "Error");
 static_assert(!std::is_constructible<B&&, D&>::value, "Error");
@@ -754,14 +762,21 @@ static_assert(!std::is_constructible<FromArgs<std::initializer_list<int>&,
 	      std::initializer_list<B>&>, std::initializer_list<int>,
 	      std::initializer_list<B>>::value, "Error");
 
+#if __cpp_aggregate_paren_init
+// In C++20 arrays can be initialized using parentheses.
+constexpr bool w = true;
+#else
+constexpr bool w = false;
+#endif
+
 static_assert(!std::is_constructible<FromArgs<std::initializer_list<int>>,
 	      int, int>::value, "Error");
 static_assert(!std::is_constructible<const
 	      FromArgs<std::initializer_list<int>>, int, int>::value, "Error");
-static_assert(!std::is_constructible<B[2], B, B>::value, "Error");
-static_assert(!std::is_constructible<const B[2], B, B>::value, "Error");
-static_assert(!std::is_constructible<U[2], U, U>::value, "Error");
-static_assert(!std::is_constructible<const U[2], U, U>::value, "Error");
+static_assert(w == std::is_constructible<B[2], B, B>::value, "Error");
+static_assert(w == std::is_constructible<const B[2], B, B>::value, "Error");
+static_assert(w == std::is_constructible<U[2], U, U>::value, "Error");
+static_assert(w == std::is_constructible<const U[2], U, U>::value, "Error");
 
 static_assert(!std::is_constructible<E, E, E>::value, "Error");
 static_assert(!std::is_constructible<const E, E, E>::value, "Error");


                 reply	other threads:[~2020-06-17 20:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200617203445.76F44398642C@sourceware.org \
    --to=aldyh@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).