public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-7739] libstdc++: Make __cmp_cat::__unseq constructor consteval
@ 2023-08-22 11:46 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2023-08-22 11:46 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:d919309679334a76ee1df583b4673d3eabb32e04

commit r13-7739-gd919309679334a76ee1df583b4673d3eabb32e04
Author: Jonathan Wakely <jwakely@redhat.com>
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.
    
    (cherry picked from commit 84cff28fd282c74399e6ad80df77025a5008e851)

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 8fa960eff470..cb88c8420104 100644
--- a/libstdc++-v3/libsupc++/compare
+++ b/libstdc++-v3/libsupc++/compare
@@ -54,7 +54,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" }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-08-22 11:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-22 11:46 [gcc r13-7739] libstdc++: Make __cmp_cat::__unseq constructor consteval Jonathan Wakely

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).