https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86679

--- Comment #1 from janus at gcc dot gnu.org ---
(In reply to janus from comment #0)
> I assume for now it is invalid, but haven't checked the standard yet. There
> are two issues that I can see:
> 
> 1) We are casting a pointer to a variable ('i') that is not declared as
> TARGET. gfortran should probably check that in the subroutine call the
> TARGET attributes of formal and actual argument match.

Draft patch for the first problem:

Index: gcc/fortran/interface.c
===================================================================
--- gcc/fortran/interface.c     (revision 262988)
+++ gcc/fortran/interface.c     (working copy)
@@ -3156,6 +3156,14 @@ compare_actual_formal (gfc_actual_arglist **ap, gf
          return false;
        }

+      if (a->expr->expr_type != EXPR_NULL
+         && f->sym->attr.target && !gfc_expr_attr (a->expr).target)
+       {
+         if (where)
+           gfc_error ("Actual argument for %qs must have the TARGET attribute"
+                      " at %L",f->sym->name, &a->expr->where);
+         return false;
+       }

       /* Fortran 2008, C1242.  */
       if (f->sym->attr.pointer && gfc_is_coindexed (a->expr))

Reply via email to