From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 73C033853D32; Thu, 17 Aug 2023 20:30:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 73C033853D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692304256; bh=478r6e404/IJXHn+DvzshwQVjuc7VE5C3MDBsbs6iKw=; h=From:To:Subject:Date:From; b=wd+gBfHgxGAH3r8tk+5FkM61hOA6zqSqrt+JEA9g6u2HvWYrfGyfR3RE3RJ957VVW 8e2S8cPnURCHKUIL255PxxjXYVK23w6MnDIrIO4G/PeKuhD81JNzrAif4UQX8rUnIw egY8vfeYoOboFZiwy2hexA9m8NqL0ETKR5guoIEg= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r14-3302] libstdc++: Make __cmp_cat::__unseq constructor consteval X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: c992acdc6774ef3d566fab5f324d254bed1b9d4b X-Git-Newrev: 84cff28fd282c74399e6ad80df77025a5008e851 Message-Id: <20230817203056.73C033853D32@sourceware.org> Date: Thu, 17 Aug 2023 20:30:56 +0000 (GMT) List-Id: https://gcc.gnu.org/g:84cff28fd282c74399e6ad80df77025a5008e851 commit r14-3302-g84cff28fd282c74399e6ad80df77025a5008e851 Author: Jonathan Wakely Date: Thu Aug 17 18:27:15 2023 +0100 libstdc++: Make __cmp_cat::__unseq constructor consteval This constructor should only ever be used with a literal 0 as the argument, so we can make it consteval. This has the nice advantage that it is expanded immediately in the front end, and so GDB will never step into the __cmp_cat::__unseq::__unseq(__unseq*) constructor that is uninteresting and probably confusing to users. libstdc++-v3/ChangeLog: * libsupc++/compare (__cmp_cat::__unseq): Make ctor consteval. * testsuite/18_support/comparisons/categories/zero_neg.cc: Prune excess errors caused by invalid consteval calls. Diff: --- libstdc++-v3/libsupc++/compare | 2 +- .../testsuite/18_support/comparisons/categories/zero_neg.cc | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/libsupc++/compare b/libstdc++-v3/libsupc++/compare index b133fdbcf1ef..9215f51e94bf 100644 --- a/libstdc++-v3/libsupc++/compare +++ b/libstdc++-v3/libsupc++/compare @@ -53,7 +53,7 @@ namespace std _GLIBCXX_VISIBILITY(default) struct __unspec { - constexpr __unspec(__unspec*) noexcept { } + consteval __unspec(__unspec*) noexcept { } }; } diff --git a/libstdc++-v3/testsuite/18_support/comparisons/categories/zero_neg.cc b/libstdc++-v3/testsuite/18_support/comparisons/categories/zero_neg.cc index 7daf799f71d8..17a129bcb75a 100644 --- a/libstdc++-v3/testsuite/18_support/comparisons/categories/zero_neg.cc +++ b/libstdc++-v3/testsuite/18_support/comparisons/categories/zero_neg.cc @@ -34,6 +34,11 @@ test01() std::weak_ordering::equivalent == 1; // { dg-error "invalid conversion" } std::strong_ordering::equivalent == 1; // { dg-error "invalid conversion" } + constexpr int z = 0; + std::partial_ordering::equivalent == z; // { dg-error "invalid conversion" } + std::weak_ordering::equivalent == z; // { dg-error "invalid conversion" } + std::strong_ordering::equivalent == z; // { dg-error "invalid conversion" } + constexpr void* p = nullptr; std::partial_ordering::equivalent == p; // { dg-error "invalid conversion" } std::weak_ordering::equivalent == p; // { dg-error "invalid conversion" } @@ -44,3 +49,6 @@ test01() std::weak_ordering::equivalent == nullptr; std::strong_ordering::equivalent == nullptr; } + +// { dg-prune-output "reinterpret_cast.* is not a constant expression" } +// { dg-prune-output "cast from 'void.' is not allowed" }