@@ -2237,8 +2237,11 @@ argument_rank_mismatch (const char *name, locus *where,
}
else
{
- gcc_assert (rank2 != -1);
- if (rank1 == 0)
+ if (rank2 == -1)
+ gfc_error_opt (0, "The assumed-rank array actual argument at %L and "
+ "actual argument at %L are ambiguous, an explicit "
+ "interface is required.", where, where_formal);
+ else if (rank1 == 0)
gfc_error_opt (0, "Rank mismatch between actual argument at %L "
"and actual argument at %L (scalar and rank-%d)",
where, where_formal, rank2);
@@ -5358,7 +5361,7 @@ gfc_get_formal_from_actual_arglist (gfc_symbol *sym,
s->ts.is_iso_c = 0;
s->ts.is_c_interop = 0;
s->attr.flavor = FL_VARIABLE;
- if (a->expr->rank > 0)
+ if (a->expr->rank)
{
s->attr.dimension = 1;
s->as = gfc_get_array_spec ();
new file mode 100644
@@ -0,0 +1,37 @@
+! { dg-do compile }
+!
+program foobar
+
+ implicit none
+
+ type :: foo_t
+ end type foo_t
+
+ class(foo_t), pointer :: a
+ type(foo_t), target :: b
+
+ call bar1(a)
+ call bar2(b)
+ stop
+
+contains
+
+ subroutine bar1(this)
+ class(foo_t), pointer, intent(in) :: this(..)
+
+ call foo(this)
+ return
+ end subroutine bar1
+
+ subroutine bar2(this)
+ type(foo_t), pointer, intent(in) :: this(..)
+
+ call foo(this)
+ return
+ end subroutine bar2
+
+end program foobar
+! { dg-error "Explicit interface required for polymorphic argument at \\\(1\\\)" "" { target "*-*-*" } 22 }
+! { dg-excess-errors "" }
+
+
new file mode 100644
@@ -0,0 +1,25 @@
+! { dg-do compile }
+!
+program foo_p
+
+ implicit none
+
+ class(*), pointer :: a
+
+ call foo(a)
+ call sub_s(a)
+ stop
+
+contains
+
+ subroutine bar_s(this)
+ class(*), intent(in) :: this(..)
+
+ call foo(this)
+ return
+ end subroutine bar_s
+
+end program foo_p
+! { dg-error "Explicit interface required for polymorphic argument at \\\(1\\\)" "" { target "*-*-*" } 10 }
+! { dg-excess-errors "" }
+