The issue came up while reviewing the patch for PR58793.

Build and regtested on x86-64-gnu-linux
OK for the trunk?

Tobias
2013-10-21  Tobias Burnus  <bur...@net-b.de>

	PR fortran/58793
	* interface.c (compare_parameter): Reject passing TYPE(*)
	to CLASS(*).

2013-10-21  Tobias Burnus  <bur...@net-b.de>

	PR fortran/58793
	* gfortran.dg/assumed_type_8.f90: New.

diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c
index b3ddf5f..0504c90 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -1972,6 +1972,15 @@ compare_parameter (gfc_symbol *formal, gfc_expr *actual,
       return 0;
     }
 
+  if (actual->ts.type == BT_ASSUMED && formal->ts.type != BT_ASSUMED)
+    {
+      if (where)
+	gfc_error ("Assumed-type actual argument at %L requires that dummy "
+		   "argument '%s' is of assumed type", &actual->where,
+		   formal->name);
+      return 0;
+    }
+
   /* F2008, 12.5.2.5; IR F08/0073.  */
   if (formal->ts.type == BT_CLASS && formal->attr.class_ok
       && actual->expr_type != EXPR_NULL
diff --git a/gcc/testsuite/gfortran.dg/assumed_type_8.f90 b/gcc/testsuite/gfortran.dg/assumed_type_8.f90
new file mode 100644
index 0000000..543e693
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/assumed_type_8.f90
@@ -0,0 +1,19 @@
+! { dg-do compile }
+!
+! Issue came up during the review of PR fortran/58793
+!
+! Test for TS29113:2012's C407b.
+! 
+program test
+  use iso_c_binding
+  integer,target ::aa
+  call up(c_loc(aa))
+contains
+  subroutine up(x)
+    class(*) :: x
+  end subroutine
+  subroutine bar(x)
+   type(*) :: x
+   call up(x) ! { dg-error "Assumed-type actual argument at .1. requires that dummy argument 'x' is of assumed type" }
+  end subroutine bar
+end program test

Reply via email to