]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: reduce redundant TARGET_EXPR
authorJason Merrill <jason@redhat.com>
Tue, 20 Sep 2022 14:25:42 +0000 (16:25 +0200)
committerJason Merrill <jason@redhat.com>
Fri, 30 Sep 2022 01:27:02 +0000 (21:27 -0400)
commit43faf3e5445b571731e52faa1be085ecd0a09323
tree095d0b528bcb5282e8edd8b950682dc4eddea4b3
parentbbdcdf5cc73e1b3385d9a25bdab4df70c4bd8c2e
c++: reduce redundant TARGET_EXPR

An experiment led me to notice that in some cases we were ending up with
TARGET_EXPR initialized by TARGET_EXPR, which isn't useful.

The target_expr_needs_replace change won't make a difference in most cases,
since cp_genericize_init will have already expanded VEC_INIT_EXPR by the
time we consider it, but it is correct.

gcc/cp/ChangeLog:

* cp-gimplify.cc (cp_fold_r) [TARGET_EXPR]: Collapse
TARGET_EXPR within TARGET_EXPR.
* constexpr.cc (cxx_eval_outermost_constant_expr): Avoid
adding redundant TARGET_EXPR.
* cp-tree.h (target_expr_needs_replace): VEC_INIT_EXPR doesn't.
gcc/cp/constexpr.cc
gcc/cp/cp-gimplify.cc
gcc/cp/cp-tree.h