re PR fortran/83999 (ICE in gfc_trans_assignment_1, at fortran/trans-expr.c:10233)
authorPaul Thomas <pault@gcc.gnu.org>
Sat, 6 Oct 2018 15:14:29 +0000 (15:14 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Sat, 6 Oct 2018 15:14:29 +0000 (15:14 +0000)
2018-10-06  Paul Thomas  <pault@gcc.gnu.org>

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  <pault@gcc.gnu.org>

PR fortran/83999
* gfortran.dg/elemental_function_4.f90 : New test.

From-SVN: r264899

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/elemental_function_4.f90 [new file with mode: 0644]

index 309a714aeaf7307f14db6866171b269ad8153539..542d04c4c063986bed30e171e74ce22c26a42649 100644 (file)
@@ -1,4 +1,10 @@
- 2018-10-06  Thomas Koenig  <tkoenig@gcc.gnu.org>
+2018-10-06  Paul Thomas  <pault@gcc.gnu.org>
+
+       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  <tkoenig@gcc.gnu.org>
 
        PR fortran/84640
        * simplify.c (gfc_simplify_cshift): Extend size of hs_ex and ss_ex
index a2beb7fc90a8f8abb2be8262655f528f7fb0b555..87e65df5f4e83234900d53b3be63fb4773d2b3e9 100644 (file)
@@ -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);
index f34b1670a9388d352a8070ce25ba8d43b534076c..407e90a2eef249cc9bb683fb763e783362274acc 100644 (file)
@@ -1,3 +1,8 @@
+2018-10-06  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/83999
+       * gfortran.dg/elemental_function_4.f90 : New test.
+
 2018-10-05  Peter Bergner  <bergner@linux.ibm.com>
 
        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 (file)
index 0000000..fbd55ac
--- /dev/null
@@ -0,0 +1,18 @@
+! { dg-do compile }
+!
+! Tests the fix for PR83999, where the invalid function 'f' caused an ICE.
+!
+! Contributed by Gerhard Steinmetz  <gscfq@t-online.de>
+!
+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