From 237b2f1b418a4394535f64c8fb600bc78fd00169 Mon Sep 17 00:00:00 2001 From: Paul Thomas Date: Fri, 16 Nov 2007 13:46:04 +0000 Subject: [PATCH] re PR fortran/33986 (ICE on allocatable function result) 2007-11-16 Paul Thomas PR fortran/33986 * trans-array.c (gfc_conv_array_parameter ): Allow allocatable function results. 2007-11-16 Paul Thomas PR fortran/33986 * gfortran.dg/allocatable_function_3.f90. From-SVN: r130228 --- gcc/fortran/ChangeLog | 9 ++++--- gcc/fortran/trans-array.c | 2 +- gcc/testsuite/ChangeLog | 5 ++++ .../gfortran.dg/allocatable_function_3.f90 | 24 +++++++++++++++++++ 4 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/allocatable_function_3.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 5411776c668..776b6520212 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,9 +1,8 @@ -2007-11-15 Tobias Burnus +2007-11-16 Paul Thomas - PR fortran/33917 - * decl.c (match_procedure_decl): Pre-resolve interface. - * resolve.c (resolve_symbol): Reject interfaces later - declared in procedure statements. + PR fortran/33986 + * trans-array.c (gfc_conv_array_parameter ): Allow allocatable + function results. 2007-11-13 Jerry DeLisle diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 87ef815b297..c418ae2a61a 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -5003,7 +5003,7 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, gfc_ss * ss, int g77) } if (sym->attr.allocatable) { - if (sym->attr.dummy) + if (sym->attr.dummy || sym->attr.result) { gfc_conv_expr_descriptor (se, expr, ss); se->expr = gfc_conv_array_data (se->expr); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 46fd19a8110..49c708ce9e1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-11-16 Paul Thomas + + PR fortran/33986 + * gfortran.dg/allocatable_function_3.f90. + 2007-11-16 Richard Guenther PR tree-optimization/34113 diff --git a/gcc/testsuite/gfortran.dg/allocatable_function_3.f90 b/gcc/testsuite/gfortran.dg/allocatable_function_3.f90 new file mode 100644 index 00000000000..538924f6719 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/allocatable_function_3.f90 @@ -0,0 +1,24 @@ +! { dg-do run } +! Tests the fix for PR33986, in which the call to scram would call +! an ICE because allocatable result actuals had not been catered for. +! +! Contributed by Damian Rouson +! +function transform_to_spectral_from() result(spectral) + integer, allocatable :: spectral(:) + allocate(spectral(2)) + call scram(spectral) +end function transform_to_spectral_from + +subroutine scram (x) + integer x(2) + x = (/1,2/) +end subroutine + + interface + function transform_to_spectral_from() result(spectral) + integer, allocatable :: spectral(:) + end function transform_to_spectral_from + end interface + if (any (transform_to_spectral_from () .ne. (/1,2/))) call abort () +end