public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-969] c++: new-expression is potentially constant in C++20
@ 2022-06-02 20:39 Marek Polacek
0 siblings, 0 replies; only message in thread
From: Marek Polacek @ 2022-06-02 20:39 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:2423f6548405185e256036df3d0ef3c13fd996c5
commit r13-969-g2423f6548405185e256036df3d0ef3c13fd996c5
Author: Marek Polacek <polacek@redhat.com>
Date: Thu Jun 2 15:56:18 2022 -0400
c++: new-expression is potentially constant in C++20
... so adjust p_c_e accordingly.
gcc/cp/ChangeLog:
* constexpr.cc (potential_constant_expression_1): Treat
{,VEC_}NEW_EXPR and {,VEC_}DELETE_EXPRas potentially constant in C++20.
Diff:
---
gcc/cp/constexpr.cc | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
index 1346a1d4c10..684238883dc 100644
--- a/gcc/cp/constexpr.cc
+++ b/gcc/cp/constexpr.cc
@@ -9039,12 +9039,20 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now,
"before C++17");
return false;
- case DYNAMIC_CAST_EXPR:
- case PSEUDO_DTOR_EXPR:
case NEW_EXPR:
case VEC_NEW_EXPR:
case DELETE_EXPR:
case VEC_DELETE_EXPR:
+ if (cxx_dialect >= cxx20)
+ /* In C++20, new-expressions are potentially constant. */
+ return true;
+ else if (flags & tf_error)
+ error_at (loc, "new-expression is not a constant expression "
+ "before C++20");
+ return false;
+
+ case DYNAMIC_CAST_EXPR:
+ case PSEUDO_DTOR_EXPR:
case THROW_EXPR:
case OMP_PARALLEL:
case OMP_TASK:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-02 20:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-02 20:39 [gcc r13-969] c++: new-expression is potentially constant in C++20 Marek Polacek
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).