From: Tobias Burnus Date: Thu, 27 Mar 2014 21:17:43 +0000 (+0100) Subject: re PR fortran/58880 ([OOP] ICE on valid with FINAL function and type extension) X-Git-Tag: releases/gcc-4.9.0~265 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7651172f5905494f4bd79577969ebb44a22b4574;p=thirdparty%2Fgcc.git re PR fortran/58880 ([OOP] ICE on valid with FINAL function and type extension) 2014-03-27 Tobias Burnus PR fortran/58880 * trans-expr.c (gfc_conv_scalar_to_descriptor): Fix handling of nonpointers. 2014-03-27 Tobias Burnus PR fortran/58880 * gfortran.dg/finalize_24.f90: New. From-SVN: r208879 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 848a76efb3c2..ab702313d477 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2014-03-27 Tobias Burnus + + PR fortran/58880 + * trans-expr.c (gfc_conv_scalar_to_descriptor): Fix handling + of nonpointers. + 2014-03-26 Dominique d'Humieres PR fortran/34928 diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index f5350bb5ba9d..9a6b40c5c58a 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -69,14 +69,16 @@ gfc_conv_scalar_to_descriptor (gfc_se *se, tree scalar, symbol_attribute attr) type = get_scalar_to_descriptor_type (scalar, attr); desc = gfc_create_var (type, "desc"); DECL_ARTIFICIAL (desc) = 1; + + if (!POINTER_TYPE_P (TREE_TYPE (scalar))) + scalar = gfc_build_addr_expr (NULL_TREE, scalar); gfc_add_modify (&se->pre, gfc_conv_descriptor_dtype (desc), gfc_get_dtype (type)); gfc_conv_descriptor_data_set (&se->pre, desc, scalar); /* Copy pointer address back - but only if it could have changed and if the actual argument is a pointer and not, e.g., NULL(). */ - if ((attr.pointer || attr.allocatable) - && attr.intent != INTENT_IN && POINTER_TYPE_P (TREE_TYPE (scalar))) + if ((attr.pointer || attr.allocatable) && attr.intent != INTENT_IN) gfc_add_modify (&se->post, scalar, fold_convert (TREE_TYPE (scalar), gfc_conv_descriptor_data_get (desc))); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bf280022184f..03a617b4a432 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-03-27 Tobias Burnus + + PR fortran/58880 + * gfortran.dg/finalize_24.f90: New. + 2014-03-27 Michael Meissner * gcc.target/powerpc/p8vector-vbpermq.c: New test to test the @@ -43,8 +48,8 @@ 2014-03-26 Fabien Chêne - PR c++/52369 - * g++.dg/init/const10.C: New. + PR c++/52369 + * g++.dg/init/const10.C: New. * g++.dg/init/const11.C: New. * g++.dg/init/pr25811.C: Adjust. * g++.dg/init/pr29043.C: Likewise. diff --git a/gcc/testsuite/gfortran.dg/finalize_24.f90 b/gcc/testsuite/gfortran.dg/finalize_24.f90 new file mode 100644 index 000000000000..2a218584a8f8 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/finalize_24.f90 @@ -0,0 +1,28 @@ +! { dg-do compile } +! +! PR fortran/58880 +! +! Contributed by Andrew Benson +! + +module gn + type sl + integer, allocatable, dimension(:) :: lv + contains + final :: sld + end type sl + type :: nde + type(sl) :: r + end type nde +contains + subroutine ndm(s) + type(nde), intent(inout) :: s + type(nde) :: i + i=s + end subroutine ndm + subroutine sld(s) + implicit none + type(sl), intent(inout) :: s + return + end subroutine sld +end module gn