aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/constexpr.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2020-04-04 11:04:55 -0400
committerJason Merrill <jason@redhat.com>2020-04-04 11:06:31 -0400
commit9f143008c73c60e02634d6b433139a035ef7bb65 (patch)
treedde2a0566499fe03a7c93a2f784d3b3cad280477 /gcc/cp/constexpr.c
parent2523d721cfc861a3abea6e97736446c99ba8b52d (diff)
downloadgcc-9f143008c73c60e02634d6b433139a035ef7bb65.zip
gcc-9f143008c73c60e02634d6b433139a035ef7bb65.tar.gz
gcc-9f143008c73c60e02634d6b433139a035ef7bb65.tar.bz2
c++: Fix reuse of class constants [PR94453]
The testcase hit an ICE trying to expand a TARGET_EXPR temporary cached from the other lambda-expression. This patch fixes this in two ways: 1) Avoid reusing a TARGET_EXPR from another function. 2) Avoid ending up with a TARGET_EXPR at all; the use of 'p' had become <TARGET_EXPR<NON_LVALUE_EXPR<TARGET_EXPR ...>>>, which doesn't make any sense. gcc/cp/ChangeLog 2020-04-04 Jason Merrill <jason@redhat.com> PR c++/94453 * constexpr.c (maybe_constant_value): Use break_out_target_exprs. * expr.c (mark_use) [VIEW_CONVERT_EXPR]: Don't wrap a TARGET_EXPR in NON_LVALUE_EXPR.
Diffstat (limited to 'gcc/cp/constexpr.c')
-rw-r--r--gcc/cp/constexpr.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 91f0c3b..8c693ea8 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -6793,7 +6793,7 @@ maybe_constant_value (tree t, tree decl, bool manifestly_const_eval,
r = *cached;
if (r != t)
{
- r = unshare_expr_without_location (r);
+ r = break_out_target_exprs (r, /*clear_loc*/true);
protected_set_expr_location (r, EXPR_LOCATION (t));
}
return r;