aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2025-09-08 08:13:07 +0100
committerPaul Thomas <pault@gcc.gnu.org>2025-09-08 08:13:07 +0100
commit565d9a3617fcc167f190e04445a1d7952b4d9bba (patch)
tree99cd331aefe5f8e02a5da26a86ebd59b510fcf0b /gcc
parented264541c353866cedf46ad873f2e2c46cf62839 (diff)
downloadgcc-565d9a3617fcc167f190e04445a1d7952b4d9bba.zip
gcc-565d9a3617fcc167f190e04445a1d7952b4d9bba.tar.gz
gcc-565d9a3617fcc167f190e04445a1d7952b4d9bba.tar.bz2
Fortran: Correct variable typespec in PDT specification exprs [PR84008]
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/decl.cc3
-rw-r--r--gcc/testsuite/gfortran.dg/pdt_45.f0329
2 files changed, 32 insertions, 0 deletions
diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc
index 8b0d959..9fe697c 100644
--- a/gcc/fortran/decl.cc
+++ b/gcc/fortran/decl.cc
@@ -3817,6 +3817,9 @@ insert_parameter_exprs (gfc_expr* e, gfc_symbol* sym ATTRIBUTE_UNUSED,
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;
}
}
diff --git a/gcc/testsuite/gfortran.dg/pdt_45.f03 b/gcc/testsuite/gfortran.dg/pdt_45.f03
new file mode 100644
index 0000000..ceba1ad
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pdt_45.f03
@@ -0,0 +1,29 @@
+! { 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