aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2025-09-02 21:51:33 +0100
committerPaul Thomas <pault@gcc.gnu.org>2025-09-02 21:51:33 +0100
commitf7dee170ba6d37aba6a9e1fa73711e4e03e42990 (patch)
tree2ddcd8bbfdb4bb94e37625ed8bbe38ffe9736061 /gcc/fortran
parent2d93be8907fa33f8791409490ed06e45de5c8420 (diff)
downloadgcc-f7dee170ba6d37aba6a9e1fa73711e4e03e42990.zip
gcc-f7dee170ba6d37aba6a9e1fa73711e4e03e42990.tar.gz
gcc-f7dee170ba6d37aba6a9e1fa73711e4e03e42990.tar.bz2
Fortran: Allow PDT parameterized procedure pointer components [PR89707]
2025-09-02 Paul Thomas <pault@gcc.gnu.org> gcc/fortran PR fortran/89707 * decl.cc (gfc_get_pdt_instance): Copy the typebound procedure field from the PDT template. If the template interface has kind=0, provide the new instance with an interface with a type spec that points to that of the parameterized component. (match_ppc_decl): When 'saved_kind_expr' this is a PDT and the expression should be copied to the component kind_expr. * gfortran.h: Define gfc_get_tbp. gcc/testsuite/ PR fortran/89707 * gfortran.dg/pdt_43.f03: New test.
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/decl.cc19
-rw-r--r--gcc/fortran/gfortran.h1
2 files changed, 20 insertions, 0 deletions
diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc
index 1e91b57..fcbbc2f 100644
--- a/gcc/fortran/decl.cc
+++ b/gcc/fortran/decl.cc
@@ -4076,6 +4076,11 @@ gfc_get_pdt_instance (gfc_actual_arglist *param_list, gfc_symbol **sym,
c2->ts = c1->ts;
c2->attr = c1->attr;
+ if (c1->tb)
+ {
+ c2->tb = gfc_get_tbp ();
+ c2->tb = c1->tb;
+ }
/* The order of declaration of the type_specs might not be the
same as that of the components. */
@@ -4163,6 +4168,17 @@ gfc_get_pdt_instance (gfc_actual_arglist *param_list, gfc_symbol **sym,
c2->ts.kind, gfc_basic_typename (c2->ts.type));
goto error_return;
}
+ if (c2->attr.proc_pointer && c2->attr.function
+ && c1->ts.interface && c1->ts.interface->ts.kind == 0)
+ {
+ c2->ts.interface = gfc_new_symbol ("", gfc_current_ns);
+ c2->ts.interface->result = c2->ts.interface;
+ c2->ts.interface->ts = c2->ts;
+ c2->ts.interface->attr.flavor = FL_PROCEDURE;
+ c2->ts.interface->attr.function = 1;
+ c2->attr.function = 1;
+ c2->attr.if_source = IFSRC_UNKNOWN;
+ }
}
/* Similarly, set the string length if parameterized. */
@@ -7573,6 +7589,9 @@ match_ppc_decl (void)
*c->tb = *tb;
}
+ if (saved_kind_expr)
+ c->kind_expr = gfc_copy_expr (saved_kind_expr);
+
/* Set interface. */
if (proc_if != NULL)
{
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index 2644cd8..482031d 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -1916,6 +1916,7 @@ typedef struct gfc_typebound_proc
}
gfc_typebound_proc;
+#define gfc_get_tbp() XCNEW (gfc_typebound_proc)
/* Symbol nodes. These are important things. They are what the
standard refers to as "entities". The possibly multiple names that