From 4ca4d1e95e39d256095f8274d8dd0d04aed603da Mon Sep 17 00:00:00 2001 From: Andre Vehreschild Date: Sun, 19 Feb 2017 19:43:49 +0100 Subject: [PATCH] re PR fortran/79229 (ICE in gfc_trans_assignment_1 with -fcheck=mem) gcc/testsuite/ChangeLog: 2017-02-19 Andre Vehreschild PR fortran/79229 * gfortran.dg/class_allocate_24.f90: New test. gcc/fortran/ChangeLog: 2017-02-19 Andre Vehreschild PR fortran/79229 * trans-expr.c (gfc_trans_assignment_1): Deref indirect refs when compiling with -fcheck=mem to check the pointer and not the data. From-SVN: r245581 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/trans-expr.c | 9 ++++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/class_allocate_24.f90 | 16 ++++++++++++++++ 4 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/class_allocate_24.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 82733be6fa4..3dfbbc5ed5b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -5,6 +5,12 @@ (gfc_resolve_expr): Call it for dummy variables with a unique symtree name. +2017-02-19 Andre Vehreschild + + PR fortran/79229 + * trans-expr.c (gfc_trans_assignment_1): Deref indirect refs when + compiling with -fcheck=mem to check the pointer and not the data. + 2017-02-19 Andre Vehreschild PR fortran/79335 diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index cc41fe3fe6d..9c4715b44be 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -9961,13 +9961,16 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag, tree cond; const char* msg; + tmp = INDIRECT_REF_P (lse.expr) + ? gfc_build_addr_expr (NULL_TREE, lse.expr) : lse.expr; + /* We should only get array references here. */ - gcc_assert (TREE_CODE (lse.expr) == POINTER_PLUS_EXPR - || TREE_CODE (lse.expr) == ARRAY_REF); + gcc_assert (TREE_CODE (tmp) == POINTER_PLUS_EXPR + || TREE_CODE (tmp) == ARRAY_REF); /* 'tmp' is either the pointer to the array(POINTER_PLUS_EXPR) or the array itself(ARRAY_REF). */ - tmp = TREE_OPERAND (lse.expr, 0); + tmp = TREE_OPERAND (tmp, 0); /* Provide the address of the array. */ if (TREE_CODE (lse.expr) == ARRAY_REF) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ada192093af..eb74a459abf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-02-19 Andre Vehreschild + + PR fortran/79229 + * gfortran.dg/class_allocate_24.f90: New test. + 2017-02-19 Paul Thomas PR fortran/79402 diff --git a/gcc/testsuite/gfortran.dg/class_allocate_24.f90 b/gcc/testsuite/gfortran.dg/class_allocate_24.f90 new file mode 100644 index 00000000000..883247dd7b8 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/class_allocate_24.f90 @@ -0,0 +1,16 @@ +! { dg-do compile } +! { dg-options "-fcheck=mem" } +! +! Compile time check only, to test that the ICE is fixed in the assignment of the +! default initializer of the class to sf. + +implicit none + +type :: t + integer, pointer :: data => null () +end type + +class(t), dimension(:), allocatable :: sf +allocate (t :: sf (1)) +end + -- 2.30.2