aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/cp-gimplify.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2017-11-19 17:17:01 +0000
committerJakub Jelinek <jakub@redhat.com>2017-11-19 17:17:01 +0000
commit6d00fc72d5a4fc9206f2a4e90140644e50fa2648 (patch)
tree418d66f5607f88d0a122bfdd9c9fe4038f93d9f8 /gcc/cp/cp-gimplify.c
parentb3667b80cef6c3583e43523c76186040dc97abdc (diff)
PR c/66618
PR c/69960 c-family/ * c-common.h (c_fully_fold): Add LVAL argument defaulted to false. c/ * c-parser.c (c_parser_omp_atomic): Pass true as LVAL to c_fully_fold where needed. * c-typeck.c (build_unary_op, build_modify_expr, build_asm_expr, handle_omp_array_sections): Likewise. (digest_init): Don't call decl_constant_value_for_optimization. * c-tree.h (decl_constant_value_for_optimization): Removed. * c-fold.c (c_fold_array_ref): New function. (c_fully_fold_internal): Add LVAL argument, propagate it through recursive calls. For VAR_P call decl_constant_value and unshare if not LVAL and either optimizing or IN_INIT. Remove decl_constant_value_for_optimization calls. If IN_INIT and not LVAL, fold ARRAY_REF with STRING_CST and INTEGER_CST operands. (c_fully_fold): Add LVAL argument, pass it through to c_fully_fold_internal. (decl_constant_value_for_optimization): Removed. cp/ * cp-gimplify.c (c_fully_fold): Add LVAL argument, call cp_fold_maybe_rvalue instead of cp_fold_rvalue and pass it !LVAL. testsuite/ * gcc.dg/pr69960.c: New test. * gcc.dg/pr66618.c: New test. * gcc.dg/pr66618-2.c: New test. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@254930 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/cp-gimplify.c')
-rw-r--r--gcc/cp/cp-gimplify.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index 7c7c0409af8..8849f9d3735 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -2048,11 +2048,9 @@ cp_fully_fold (tree x)
C_MAYBE_CONST_EXPR. */
tree
-c_fully_fold (tree x, bool /*in_init*/, bool */*maybe_const*/)
+c_fully_fold (tree x, bool /*in_init*/, bool */*maybe_const*/, bool lval)
{
- /* c_fully_fold is only used on rvalues, and we need to fold CONST_DECL to
- INTEGER_CST. */
- return cp_fold_rvalue (x);
+ return cp_fold_maybe_rvalue (x, !lval);
}
static GTY((deletable)) hash_map<tree, tree> *fold_cache;