diff options
author | Jakub Jelinek <jakub@redhat.com> | 2018-01-13 18:00:43 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2018-01-13 18:00:43 +0100 |
commit | b4923738ef57a441f6f9248260848bde5af165fa (patch) | |
tree | 5e1b4802d2cab1d24b857680da9e4057d37fc2d7 /gcc/c/c-fold.c | |
parent | 567a6e1cdb3cae09ae74bdd528fd31c0b4956ad2 (diff) | |
download | gcc-b4923738ef57a441f6f9248260848bde5af165fa.zip gcc-b4923738ef57a441f6f9248260848bde5af165fa.tar.gz gcc-b4923738ef57a441f6f9248260848bde5af165fa.tar.bz2 |
re PR c/83801 ([avr] String constant in __flash not put into .progmem)
PR c/83801
* c-tree.h (decl_constant_value_1): Add a bool argument.
* c-typeck.c (decl_constant_value_1): Add IN_INIT argument, allow
returning a CONSTRUCTOR if it is true. Use error_operand_p.
(decl_constant_value): Adjust caller.
* c-fold.c (c_fully_fold_internal): If in_init, pass true to
decl_constant_value_1 as IN_INIT. Otherwise, punt if
decl_constant_value returns initializer that has BLKmode or
array type.
(c_fully_fold_internal) <case COMPONENT_REF>: Fold if !lval.
* gcc.dg/pr83801.c: New test.
From-SVN: r256608
Diffstat (limited to 'gcc/c/c-fold.c')
-rw-r--r-- | gcc/c/c-fold.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/gcc/c/c-fold.c b/gcc/c/c-fold.c index 5776f1b..12460bc 100644 --- a/gcc/c/c-fold.c +++ b/gcc/c/c-fold.c @@ -168,9 +168,15 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands, if (VAR_P (expr) && !lval && (optimize || in_init)) { if (in_init) - ret = decl_constant_value_1 (expr); + ret = decl_constant_value_1 (expr, true); else - ret = decl_constant_value (expr); + { + ret = decl_constant_value (expr); + if (ret != expr + && (TYPE_MODE (TREE_TYPE (ret)) == BLKmode + || TREE_CODE (TREE_TYPE (ret)) == ARRAY_TYPE)) + return expr; + } /* Avoid unwanted tree sharing between the initializer and current function's body where the tree can be modified e.g. by the gimplifier. */ @@ -264,6 +270,8 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands, TREE_READONLY (ret) = TREE_READONLY (expr); TREE_THIS_VOLATILE (ret) = TREE_THIS_VOLATILE (expr); } + if (!lval) + ret = fold (ret); goto out; case ARRAY_REF: |