deferred-shape vs assumed-shape

Message ID 20200401200443.GA55208@troutmask.apl.washington.edu
State New
Headers show
Series
  • deferred-shape vs assumed-shape
Related show

Commit Message

Iain Buclaw via Gcc-patches April 1, 2020, 8:04 p.m.
See 
https://stackoverflow.com/questions/60972134/whats-wrong-with-the-following-fortran-code-gfortran-dtio-dummy-argument-at

Is A(:) a deferred-shape array or an assumed-shape array?  The
answer of course depends on context.

This patch fixes the issue found at the above URL.


-- 
Steve

Patch

Index: gcc/fortran/interface.c
===================================================================
--- gcc/fortran/interface.c	(revision 280157)
+++ gcc/fortran/interface.c	(working copy)
@@ -4916,10 +4916,15 @@  check_dtio_arg_TKR_intent (gfc_symbol *fsym, bool type
 	  || ((type != BT_CLASS) && fsym->attr.dimension)))
     gfc_error ("DTIO dummy argument at %L must be a scalar",
 	       &fsym->declared_at);
-  else if (rank == 1
-	   && (fsym->as == NULL || fsym->as->type != AS_ASSUMED_SHAPE))
-    gfc_error ("DTIO dummy argument at %L must be an "
-	       "ASSUMED SHAPE ARRAY", &fsym->declared_at);
+  else if (rank == 1)
+    {
+      if (fsym->as == NULL
+	  || !(fsym->as->type == AS_ASSUMED_SHAPE
+		|| (fsym->as->type == AS_DEFERRED && fsym->attr.dummy
+		    && !fsym->attr.allocatable && !fsym->attr.pointer)))
+	gfc_error ("DTIO dummy argument at %L must be an "
+		   "ASSUMED-SHAPE ARRAY", &fsym->declared_at);
+    }
 
   if (type == BT_CHARACTER && fsym->ts.u.cl->length != NULL)
     gfc_error ("DTIO character argument at %L must have assumed length",