From: Paul Thomas Date: Thu, 18 Oct 2018 10:33:25 +0000 (+0000) Subject: re PR fortran/58618 (Wrong code with character substring and ASSOCIATE) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=75a6d7da396ca7cecdc1b0e977203bb58a8ca024;p=gcc.git re PR fortran/58618 (Wrong code with character substring and ASSOCIATE) 2018-10-18 Paul Thomas PR fortran/58618 * trans-decl.c (gfc_get_symbol_decl): Deal correctly with the initialization with NULL() of a deferred length pointer. 2018-10-18 Paul Thomas PR fortran/58618 * gfortran.dg/deferred_character_30.f90 : New test. From-SVN: r265263 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 4f216d94cae..5ca39af187a 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2018-10-18 Paul Thomas + + PR fortran/58618 + * trans-decl.c (gfc_get_symbol_decl): Deal correctly with the + initialization with NULL() of a deferred length pointer. + 2018-10-17 Tobias Burnus PR fortran/87632 diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index b0c12e5fc38..88f9f570725 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -1762,7 +1762,8 @@ gfc_get_symbol_decl (gfc_symbol * sym) gfc_finish_var_decl (length, sym); if (!sym->attr.associate_var && TREE_CODE (length) == VAR_DECL - && sym->value && sym->value->ts.u.cl->length) + && sym->value && sym->value->expr_type != EXPR_NULL + && sym->value->ts.u.cl->length) { gfc_expr *len = sym->value->ts.u.cl->length; DECL_INITIAL (length) = gfc_conv_initializer (len, &len->ts, @@ -1772,7 +1773,7 @@ gfc_get_symbol_decl (gfc_symbol * sym) DECL_INITIAL (length)); } else - gcc_assert (!sym->value); + gcc_assert (!sym->value || sym->value->expr_type == EXPR_NULL); } gfc_finish_var_decl (decl, sym); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9cf4cbc4019..57cbb79bba2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-10-18 Paul Thomas + + PR fortran/58618 + * gfortran.dg/deferred_character_30.f90 : New test. + 2018-10-18 Richard Biener PR middle-end/87087 diff --git a/gcc/testsuite/gfortran.dg/deferred_character_30.f90 b/gcc/testsuite/gfortran.dg/deferred_character_30.f90 new file mode 100644 index 00000000000..6d9bd5a2d67 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/deferred_character_30.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +! +! Fix a regression introduced by the patch for PR70149. +! + character (:), pointer :: ptr => NULL() ! The NULL () caused an ICE. + character (6), target :: tgt = 'lmnopq' + ptr => tgt + print *, len (ptr), ptr +end