diff options
author | Jason Merrill <jason@redhat.com> | 2023-07-14 09:37:21 -0400 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2023-07-14 18:35:40 -0400 |
commit | 8d344146727da02eb5c62fbf6cee97a4e96d63db (patch) | |
tree | 0347706ee6d8958ed23f47e994b4662f95d6477e /gcc/cp | |
parent | 49a2a63e6518cfa294d903f5f62ab1f922df438e (diff) | |
download | gcc-8d344146727da02eb5c62fbf6cee97a4e96d63db.zip gcc-8d344146727da02eb5c62fbf6cee97a4e96d63db.tar.gz gcc-8d344146727da02eb5c62fbf6cee97a4e96d63db.tar.bz2 |
c++: c++26 regression fixes
Apparently I wasn't actually running the testsuite in C++26 mode like I
thought I was, so there were some failures I wasn't seeing.
The constexpr hunk fixes regressions with the P2738 implementation; we still
need to use the old handling for casting from void pointers to heap
variables.
PR c++/110344
gcc/cp/ChangeLog:
* constexpr.cc (cxx_eval_constant_expression): Move P2738 handling
after heap handling.
* name-lookup.cc (get_cxx_dialect_name): Add C++26.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/constexpr-cast2.C: Adjust for P2738.
* g++.dg/ipa/devirt-45.C: Handle -fimplicit-constexpr.
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/constexpr.cc | 21 | ||||
-rw-r--r-- | gcc/cp/name-lookup.cc | 2 |
2 files changed, 12 insertions, 11 deletions
diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc index cca0435..9f96a6c 100644 --- a/gcc/cp/constexpr.cc +++ b/gcc/cp/constexpr.cc @@ -7681,17 +7681,6 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, && !is_std_construct_at (ctx->call) && !is_std_allocator_allocate (ctx->call)) { - /* P2738 (C++26): a conversion from a prvalue P of type "pointer to - cv void" to a pointer-to-object type T unless P points to an - object whose type is similar to T. */ - if (cxx_dialect > cxx23) - if (tree ob - = cxx_fold_indirect_ref (ctx, loc, TREE_TYPE (type), op)) - { - r = build1 (ADDR_EXPR, type, ob); - break; - } - /* Likewise, don't error when casting from void* when OP is &heap uninit and similar. */ tree sop = tree_strip_nop_conversions (op); @@ -7699,6 +7688,16 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, && VAR_P (TREE_OPERAND (sop, 0)) && DECL_ARTIFICIAL (TREE_OPERAND (sop, 0))) /* OK */; + /* P2738 (C++26): a conversion from a prvalue P of type "pointer to + cv void" to a pointer-to-object type T unless P points to an + object whose type is similar to T. */ + else if (cxx_dialect > cxx23 + && (sop = cxx_fold_indirect_ref (ctx, loc, + TREE_TYPE (type), sop))) + { + r = build1 (ADDR_EXPR, type, sop); + break; + } else { if (!ctx->quiet) diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc index 7456518..2d74756 100644 --- a/gcc/cp/name-lookup.cc +++ b/gcc/cp/name-lookup.cc @@ -6731,6 +6731,8 @@ get_cxx_dialect_name (enum cxx_dialect dialect) return "C++20"; case cxx23: return "C++23"; + case cxx26: + return "C++26"; } } |