aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2017-02-03 16:38:15 +0000
committerMartin Sebor <msebor@gcc.gnu.org>2017-02-03 09:38:15 -0700
commit3f3430400b2ce552a5dbdae49a3a482687b96afa (patch)
treec78749d08d207350d71edfc1c5b9871d422a1f1c /gcc/tree.c
parent46a2ab580a762b0fc3e64dc4ab24d459a4bd1fd2 (diff)
downloadgcc-3f3430400b2ce552a5dbdae49a3a482687b96afa.zip
gcc-3f3430400b2ce552a5dbdae49a3a482687b96afa.tar.gz
gcc-3f3430400b2ce552a5dbdae49a3a482687b96afa.tar.bz2
PR tree-optimization/79352 - -fprintf-return-value doesn't handle flexible-like array members properly
gcc/ChangeLog: PR tree-optimization/79352 * gimple-fold.c (get_range_strlen): Add argument. (get_range_strlen): Change return type to bool. (get_maxval_strlen): Pass in a dummy argument. * gimple-fold.h (get_range_strlen): Change return type to bool. * gimple-ssa-sprintf.c (get_string_length): Set unlikely counter. * tree.h (array_at_struct_end_p): Add argument. * tree.c (array_at_struct_end_p): Handle it. gcc/testsuite/ChangeLog: PR tree-optimization/79352 * gcc.dg/tree-ssa/pr79352.c: New test. From-SVN: r245156
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 8426834..804ab5e 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -13195,13 +13195,16 @@ array_ref_up_bound (tree exp)
/* Returns true if REF is an array reference to an array at the end of
a structure. If this is the case, the array may be allocated larger
- than its upper bound implies. */
+ than its upper bound implies. When ALLOW_COMPREF is true considers
+ REF when it's a COMPONENT_REF in addition ARRAY_REF and
+ ARRAY_RANGE_REF. */
bool
-array_at_struct_end_p (tree ref)
+array_at_struct_end_p (tree ref, bool allow_compref)
{
if (TREE_CODE (ref) != ARRAY_REF
- && TREE_CODE (ref) != ARRAY_RANGE_REF)
+ && TREE_CODE (ref) != ARRAY_RANGE_REF
+ && (!allow_compref || TREE_CODE (ref) != COMPONENT_REF))
return false;
while (handled_component_p (ref))