Hi Dominique,

AFAICT there is no patch attached.

I guess that would have helped :-)

Here it is.


2019-02-25  Thomas Koenig  <tkoe...@gcc.gnu.org>

        PR fortran/89496
        * trans-types.c (get_formal_from_actual_arglist): If
        the actual arglist has no expression, the corresponding
        formal arglist is an alternate return.

2019-02-25  Thomas Koenig  <tkoe...@gcc.gnu.org>

        PR fortran/89496
        * gfortran.dg/altreturn_9_0.f90: New file.
        * gfortran.dg/altreturn_9_1.f90: New file.
! { dg-do compile }
! { dg-options "-std=gnu" }
! See altreturn_9_0.f90
subroutine sub(i, *, j)
  if (i == 10 .and. j == 20) return 1
  return
end subroutine sub
! { dg-do  run }
! { dg-options -std=gnu }
! { dg-additional-sources altreturn_9_1.f90 }
! PR 89496 - wrong type for alternate return was generated

program main
  call sub(10, *10, 20)
  stop 1
10 continue
end program main
Index: trans-types.c
===================================================================
--- trans-types.c	(Revision 269161)
+++ trans-types.c	(Arbeitskopie)
@@ -2988,9 +2988,9 @@ get_formal_from_actual_arglist (gfc_symbol *sym, g
   f = &sym->formal;
   for (a = actual_args; a != NULL; a = a->next)
     {
+      (*f) = gfc_get_formal_arglist ();
       if (a->expr)
 	{
-	  (*f) = gfc_get_formal_arglist ();
 	  snprintf (name, GFC_MAX_SYMBOL_LEN, "_formal_%d", var_num ++);
 	  gfc_get_symbol (name, NULL, &s);
 	  if (a->expr->ts.type == BT_PROCEDURE)
@@ -3012,6 +3012,9 @@ get_formal_from_actual_arglist (gfc_symbol *sym, g
 	  s->attr.intent = INTENT_UNKNOWN;
 	  (*f)->sym = s;
 	}
+      else  /* If a->expr is NULL, this is an alternate rerturn.  */
+	(*f)->sym = NULL;
+
       f = &((*f)->next);
     }
 }

Reply via email to