]> git.ipfire.org Git - thirdparty/gcc.git/commit
gfortran: Allow ref'ing PDT's len() in parameter-initializer.
authorAndre Vehreschild <vehre@gcc.gnu.org>
Wed, 12 Jul 2023 10:51:30 +0000 (12:51 +0200)
committerHarald Anlauf <anlauf@gmx.de>
Fri, 26 Apr 2024 06:35:25 +0000 (08:35 +0200)
commite207b67fcde224f2be0c79bf2a24f7fc75b6f481
tree0095ca10c7dbe431ec9aa87f26241073794f2c19
parent45816f7eefa669f98b1ab5746331111d520f3a7b
gfortran: Allow ref'ing PDT's len() in parameter-initializer.

Fix declaring a parameter initialized using a pdt_len reference
not simplifying the reference to a constant.

2023-07-12  Andre Vehreschild  <vehre@gcc.gnu.org>

gcc/fortran/ChangeLog:

PR fortran/102003
* expr.cc (find_inquiry_ref): Replace len of pdt_string by
constant.
(simplify_ref_chain): Ensure input to find_inquiry_ref is
NULL.
(gfc_match_init_expr): Prevent PDT analysis for function calls.
(gfc_pdt_find_component_copy_initializer): Get the initializer
value for given component.
* gfortran.h (gfc_pdt_find_component_copy_initializer): New
function.
* simplify.cc (gfc_simplify_len): Replace len() of PDT with pdt
component ref or constant.

gcc/testsuite/ChangeLog:

* gfortran.dg/pdt_33.f03: New test.

(cherry picked from commit f9182da3213aa57c16dd0b52862126de4a259f6a)
gcc/fortran/expr.cc
gcc/fortran/gfortran.h
gcc/fortran/simplify.cc
gcc/testsuite/gfortran.dg/pdt_33.f03 [new file with mode: 0644]