]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Make __cmp_cat::__unseq constructor consteval
authorJonathan Wakely <jwakely@redhat.com>
Thu, 17 Aug 2023 17:27:15 +0000 (18:27 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 17 Aug 2023 19:24:17 +0000 (20:24 +0100)
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.

libstdc++-v3/libsupc++/compare
libstdc++-v3/testsuite/18_support/comparisons/categories/zero_neg.cc

index b133fdbcf1ef9ac0768ebccc19e25ab0a071585c..9215f51e94bfaec9547e9a09095e85e4ea3bc75e 100644 (file)
@@ -53,7 +53,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
 
     struct __unspec
     {
-      constexpr __unspec(__unspec*) noexcept { }
+      consteval __unspec(__unspec*) noexcept { }
     };
   }
 
index 7daf799f71d8ae5b8ddbfa52a9cb9cfc0457838d..17a129bcb75a1bc3f21f89749b375c1bfdf8cd8c 100644 (file)
@@ -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" }