]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fortran: Fix some bugs in associate [PR87477]
authorPaul Thomas <pault@gcc.gnu.org>
Wed, 21 Jun 2023 16:05:58 +0000 (17:05 +0100)
committerPaul Thomas <pault@gcc.gnu.org>
Wed, 21 Jun 2023 16:05:58 +0000 (17:05 +0100)
commit577223aebc7acdd31e62b33c1682fe54a622ae27
treed5c1cae4de436a0fe54a5f0a2a197d309f3d654c
parentcaf0892eea67349d9a1e44590c3440768136fe2b
Fortran: Fix some bugs in associate [PR87477]

2023-06-21  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/87477
PR fortran/88688
PR fortran/94380
PR fortran/107900
PR fortran/110224
* decl.cc (char_len_param_value): Fix memory leak.
(resolve_block_construct): Remove unnecessary static decls.
* expr.cc (gfc_is_ptr_fcn): New function.
(gfc_check_vardef_context): Use it to permit pointer function
result selectors to be used for associate names in variable
definition context.
* gfortran.h: Prototype for gfc_is_ptr_fcn.
* match.cc (build_associate_name): New function.
(gfc_match_select_type): Use the new function to replace inline
version and to build a new associate name for the case where
the supplied associate name is already used for that purpose.
* resolve.cc (resolve_assoc_var): Call gfc_is_ptr_fcn to allow
associate names with pointer function targets to be used in
variable definition context.
* trans-decl.cc (gfc_get_symbol_decl): Unlimited polymorphic
variables need deferred initialisation of the vptr.
(gfc_trans_deferred_vars): Do the vptr initialisation.
* trans-stmt.cc (trans_associate_var): Ensure that a pointer
associate name points to the target of the selector and not
the selector itself.

gcc/testsuite/
PR fortran/87477
PR fortran/107900
* gfortran.dg/pr107900.f90 : New test

PR fortran/110224
* gfortran.dg/pr110224.f90 : New test

PR fortran/88688
* gfortran.dg/pr88688.f90 : New test

PR fortran/94380
* gfortran.dg/pr94380.f90 : New test

PR fortran/95398
* gfortran.dg/pr95398.f90 : Set -std=f2008, bump the line
numbers in the error tests by two and change the text in two.
12 files changed:
gcc/fortran/decl.cc
gcc/fortran/expr.cc
gcc/fortran/gfortran.h
gcc/fortran/match.cc
gcc/fortran/resolve.cc
gcc/fortran/trans-decl.cc
gcc/fortran/trans-stmt.cc
gcc/testsuite/gfortran.dg/pr107900.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/pr110224.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/pr88688.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/pr94380.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/pr95398.f90