2025-09-08 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/84008
* decl.cc (insert_parameter_exprs): Correct the typespec of new
variable declarations, where the type is set to BT_PROCEDURE as
a precaution for resolution of the whole program unit.
gcc/testsuite/
PR fortran/84008
* gfortran.dg/pdt_45.f03: New test.
copy = gfc_copy_expr (param->expr);
*e = *copy;
free (copy);
+ /* Catch variables declared without a value expression. */
+ if (e->expr_type == EXPR_VARIABLE && e->ts.type == BT_PROCEDURE)
+ e->ts = e->symtree->n.sym->ts;
}
}
--- /dev/null
+! { dg-do compile }
+!
+! Contributed by Steve Kargl <kargl@gcc.gnu.org>
+!
+module mod
+
+ type :: objects(k1,l1)
+ integer, kind :: k1 = selected_int_kind(4)
+ integer, len :: l1
+ integer(k1) :: p(l1+1)
+ end type
+
+ contains
+ subroutine foo(n)
+ integer n
+ type(objects(l1=n)) :: x
+ ! Any of these lines caused an ICE in compilation.
+ if (x%k1 /= selected_int_kind(4)) stop 1
+ if (x%l1 /= n) stop 2
+ if (size(x%p) /= x%l1+1) stop 3
+ end subroutine
+
+end module
+
+program p
+ use mod
+ type(objects(1,30)) :: x
+ call foo(3)
+end program p