From: Paul Thomas Date: Sat, 6 Oct 2018 15:14:29 +0000 (+0000) Subject: re PR fortran/83999 (ICE in gfc_trans_assignment_1, at fortran/trans-expr.c:10233) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2b03b800d866d345b078eaec77ef47fb05daeec2;p=gcc.git re PR fortran/83999 (ICE in gfc_trans_assignment_1, at fortran/trans-expr.c:10233) 2018-10-06 Paul Thomas PR fortran/83999 * resolve.c (resolve_fl_procedure): Include class functions in the test that elemental function results be scalar. 2018-10-06 Paul Thomas PR fortran/83999 * gfortran.dg/elemental_function_4.f90 : New test. From-SVN: r264899 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 309a714aeaf..542d04c4c06 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,4 +1,10 @@ - 2018-10-06 Thomas Koenig +2018-10-06 Paul Thomas + + Backport from trunk + * resolve.c (resolve_fl_procedure): Include class functions in + the test that elemental function results be scalar. + +2018-10-06 Thomas Koenig PR fortran/84640 * simplify.c (gfc_simplify_cshift): Extend size of hs_ex and ss_ex diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index a2beb7fc90a..87e65df5f4e 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -12503,7 +12503,8 @@ resolve_fl_procedure (gfc_symbol *sym, int mp_flag) } /* An elemental function is required to return a scalar 12.7.1 */ - if (sym->attr.elemental && sym->attr.function && sym->as) + if (sym->attr.elemental && sym->attr.function + && (sym->as || (sym->ts.type == BT_CLASS && CLASS_DATA (sym)->as))) { gfc_error ("ELEMENTAL function %qs at %L must have a scalar " "result", sym->name, &sym->declared_at); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f34b1670a93..407e90a2eef 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-10-06 Paul Thomas + + PR fortran/83999 + * gfortran.dg/elemental_function_4.f90 : New test. + 2018-10-05 Peter Bergner PR rtl-optimization/86939 diff --git a/gcc/testsuite/gfortran.dg/elemental_function_4.f90 b/gcc/testsuite/gfortran.dg/elemental_function_4.f90 new file mode 100644 index 00000000000..fbd55ac8ea5 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/elemental_function_4.f90 @@ -0,0 +1,18 @@ +! { dg-do compile } +! +! Tests the fix for PR83999, where the invalid function 'f' caused an ICE. +! +! Contributed by Gerhard Steinmetz +! +program p + type t + integer :: a + end type + type(t) :: x(3) + x = f() + print *, x +contains + elemental function f() result(z) ! { dg-error "must have a scalar result" } + type(t), pointer :: z(:) + end +end