===================================================================
@@ -1862,7 +1862,19 @@ resolve_procedure_expression (gfc_expr* expr)
return true;
}
+/* Check that name is not a derived type. */
+static bool
+is_dt_name (const char *name)
+{
+ gfc_dt_list *dt_list;
+
+ for (dt_list = gfc_derived_types; dt_list; dt_list = dt_list->next)
+ if (strcmp(dt_list->derived->name, name) == 0)
+ return true;
+ return false;
+}
+
/* Resolve an actual argument list. Most of the time, this is just
resolving the expressions in the list.
The exception is that we sometimes have to decide whether arguments
@@ -1963,6 +1975,14 @@ resolve_actual_arglist (gfc_actual_arglist *arg, proce
gfc_error ("ELEMENTAL non-INTRINSIC procedure %qs is not "
"allowed as an actual argument at %L", sym->name,
&e->where);
+ }
+
+ /* Check to see if the argument is actually a derived type. */
+ if (is_dt_name (sym->name))
+ {
+ gfc_error ("Derived type %qs is used as an actual "
+ "argument at %L", sym->name, &e->where);
+ goto cleanup;
}
/* Check if a generic interface has a specific procedure
===================================================================
@@ -0,0 +1,13 @@
+! { dg-do compile }
+! PF fortran/68544
+program p
+ real x
+ type t
+ end type
+ x = f(t) ! { dg-error "used as an actual argument" }
+end
+subroutine b
+ type t
+ end type
+ print *, shape(t) ! { dg-error "used as an actual argument" }
+end
===================================================================
@@ -1,8 +1,9 @@
! { dg-do compile }
! PR fortran/85687
! Code original contributed by Gerhard Steinmetz gscfq at t-oline dot de
+! Originally, error message superceded by fix for PR fortran/68544.
program p
type t
end type
- print *, rank(t) ! { dg-error "must be a data object" }
+ print *, rank(t) ! { dg-error "used as an actual argument" }
end