From 90966337970092f84e1029aa27376922fb24943c Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 10 Sep 2010 14:44:20 +0000 Subject: Check that result of string folding is of integral type. gcc/ 2010-09-10 H.J. Lu PR middle-end/45634 * tree-ssa-ccp.c (fold_const_aggregate_ref): Check that result of string folding is of integral type. gcc/testsuite/ 2010-09-10 H.J. Lu PR middle-end/45634 * gfortran.fortran-torture/compile/pr45634.f90: New. From-SVN: r164183 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.fortran-torture/compile/pr45634.f90 | 5 +++++ gcc/tree-ssa-ccp.c | 5 +++-- 4 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.fortran-torture/compile/pr45634.f90 (limited to 'gcc') diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5f62d06..bda4cda 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2010-09-10 H.J. Lu + + PR middle-end/45634 + * tree-ssa-ccp.c (fold_const_aggregate_ref): Check that result + of string folding is of integral type. + 2010-09-10 Ryan Mansfield * doc/invoke.texi (-x): Fix typo. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7f4f87b..9815d18 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-09-10 H.J. Lu + + PR middle-end/45634 + * gfortran.fortran-torture/compile/pr45634.f90: New. + 2010-09-10 Nicola Pero * objc.dg/fobjc-exceptions.m: New test. diff --git a/gcc/testsuite/gfortran.fortran-torture/compile/pr45634.f90 b/gcc/testsuite/gfortran.fortran-torture/compile/pr45634.f90 new file mode 100644 index 0000000..ab0c33a --- /dev/null +++ b/gcc/testsuite/gfortran.fortran-torture/compile/pr45634.f90 @@ -0,0 +1,5 @@ + SUBROUTINE RCRDRD (VTYP) + CHARACTER(4), INTENT(OUT) :: VTYP + CHARACTER(1), SAVE :: DBL = "D" + VTYP = DBL + END diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 60e2b55..33d5cc7 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -1537,8 +1537,9 @@ fold_const_aggregate_ref (tree t) /* Fold read from constant string. */ if (TREE_CODE (ctor) == STRING_CST) { - if ((TYPE_MODE (TREE_TYPE (t)) - == TYPE_MODE (TREE_TYPE (TREE_TYPE (ctor)))) + if (INTEGRAL_TYPE_P (TREE_TYPE (t)) + && (TYPE_MODE (TREE_TYPE (t)) + == TYPE_MODE (TREE_TYPE (TREE_TYPE (ctor)))) && (GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (TREE_TYPE (ctor)))) == MODE_INT) && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (TREE_TYPE (ctor)))) == 1 -- cgit v1.1