Fortran: diagnostic for argument w/type parameters for assumed-type dummy
authorSandra Loosemore <sandra@codesourcery.com>
Wed, 22 Sep 2021 14:49:17 +0000 (07:49 -0700)
committerSandra Loosemore <sandra@codesourcery.com>
Thu, 23 Sep 2021 00:11:08 +0000 (17:11 -0700)
2021-09-22  Sandra Loosemore  <sandra@codesourcery.com>

PR fortran/101319

gcc/fortran/
* interface.c (gfc_compare_actual_formal): Extend existing
assumed-type diagnostic to also check for argument with type
parameters.

gcc/testsuite/
* gfortran.dg/c-interop/assumed-type-dummy.f90: Remove xfail.

gcc/fortran/interface.c
gcc/testsuite/gfortran.dg/c-interop/assumed-type-dummy.f90

index f9a7c9c..dae4b95 100644 (file)
@@ -3183,21 +3183,21 @@ gfc_compare_actual_formal (gfc_actual_arglist **ap, gfc_formal_arglist *formal,
                              is_elemental, where))
        return false;
 
-      /* TS 29113, 6.3p2.  */
+      /* TS 29113, 6.3p2; F2018 15.5.2.4.  */
       if (f->sym->ts.type == BT_ASSUMED
          && (a->expr->ts.type == BT_DERIVED
              || (a->expr->ts.type == BT_CLASS && CLASS_DATA (a->expr))))
        {
-         gfc_namespace *f2k_derived;
-
-         f2k_derived = a->expr->ts.type == BT_DERIVED
-                       ? a->expr->ts.u.derived->f2k_derived
-                       : CLASS_DATA (a->expr)->ts.u.derived->f2k_derived;
-
-         if (f2k_derived
-             && (f2k_derived->finalizers || f2k_derived->tb_sym_root))
+         gfc_symbol *derived = (a->expr->ts.type == BT_DERIVED
+                                ? a->expr->ts.u.derived
+                                : CLASS_DATA (a->expr)->ts.u.derived);
+         gfc_namespace *f2k_derived = derived->f2k_derived;
+         if (derived->attr.pdt_type
+             || (f2k_derived
+                 && (f2k_derived->finalizers || f2k_derived->tb_sym_root)))
            {
-             gfc_error ("Actual argument at %L to assumed-type dummy is of "
+             gfc_error ("Actual argument at %L to assumed-type dummy "
+                        "has type parameters or is of "
                         "derived type with type-bound or FINAL procedures",
                         &a->expr->where);
              return false;
index a14c9a5..24bdf2b 100644 (file)
@@ -73,7 +73,7 @@ contains
     type(t4) :: a4
 
     call s1 (a1)  ! OK
-    call s1 (a2)  ! { dg-error "assumed-type dummy" "pr101319" { xfail *-*-* } }
+    call s1 (a2)  ! { dg-error "assumed-type dummy" }
     call s1 (a3)  ! { dg-error "assumed-type dummy" }
     call s1 (a4)  ! { dg-error "assumed-type dummy" }
   end subroutine