aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-ccp.c
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2010-09-09 17:07:21 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2010-09-09 15:07:21 +0000
commit54e34c358acefd04573881cb5db372423c1e8e9d (patch)
tree26599e9e8b44b5ab012025bf37371c093d0ec20f /gcc/tree-ssa-ccp.c
parentba885ec559ca39e0dc23641dbbe67cc0072378f3 (diff)
downloadgcc-54e34c358acefd04573881cb5db372423c1e8e9d.zip
gcc-54e34c358acefd04573881cb5db372423c1e8e9d.tar.gz
gcc-54e34c358acefd04573881cb5db372423c1e8e9d.tar.bz2
tree-ssa-ccp.c (fold_const_aggregate_ref): Check that result of string folding is of integral type.
* tree-ssa-ccp.c (fold_const_aggregate_ref): Check that result of string folding is of integral type. * fortran.fortran-torture/compile/pr45598.f90: New test. From-SVN: r164111
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r--gcc/tree-ssa-ccp.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 7341477..60e2b55 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -1398,8 +1398,7 @@ fold_const_aggregate_ref (tree t)
}
/* Fold read from constant string. */
- if (TREE_CODE (ctor) == STRING_CST
- && TREE_CODE (idx) == INTEGER_CST)
+ if (TREE_CODE (ctor) == STRING_CST)
{
tree low_bound = array_ref_low_bound (t);
double_int low_bound_cst;
@@ -1407,7 +1406,9 @@ fold_const_aggregate_ref (tree t)
double_int length_cst;
bool signed_p = TYPE_UNSIGNED (TREE_TYPE (idx));
- if (TREE_CODE (low_bound) != INTEGER_CST)
+ if (TREE_CODE (idx) != INTEGER_CST
+ || !INTEGRAL_TYPE_P (TREE_TYPE (t))
+ || TREE_CODE (low_bound) != INTEGER_CST)
return NULL_TREE;
low_bound_cst = tree_to_double_int (low_bound);
index_cst = tree_to_double_int (idx);