]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fortran: default-initialization and functions returning derived type [PR85750]
authorHarald Anlauf <anlauf@gmx.de>
Thu, 15 May 2025 19:07:07 +0000 (21:07 +0200)
committerHarald Anlauf <anlauf@gmx.de>
Thu, 22 May 2025 19:06:39 +0000 (21:06 +0200)
commit6fb3dd1de63e48a0cc465973f9de24f680c3fde5
treeee266aafdc4627fe0dd961354c1f5958d201da0e
parent8c4b23611a73ac788e32d707c266bc37b0153146
Fortran: default-initialization and functions returning derived type [PR85750]

Functions with non-pointer, non-allocatable result and of derived type did
not always get initialized although the type had default-initialization,
and a derived type component had the allocatable or pointer attribute.
Rearrange the logic when to apply default-initialization.

PR fortran/85750

gcc/fortran/ChangeLog:

* resolve.cc (resolve_symbol): Reorder conditions when to apply
default-initializers.

gcc/testsuite/ChangeLog:

* gfortran.dg/alloc_comp_auto_array_3.f90: Adjust scan counts.
* gfortran.dg/alloc_comp_class_3.f03: Remove bogus warnings.
* gfortran.dg/alloc_comp_class_4.f03: Likewise.
* gfortran.dg/allocate_with_source_14.f03: Adjust scan count.
* gfortran.dg/derived_constructor_comps_6.f90: Likewise.
* gfortran.dg/derived_result_5.f90: New test.

(cherry picked from commit d31ab498b12ebbe4f50acb2aa240ff92c73f310c)
gcc/fortran/resolve.cc
gcc/testsuite/gfortran.dg/alloc_comp_auto_array_3.f90
gcc/testsuite/gfortran.dg/alloc_comp_class_3.f03
gcc/testsuite/gfortran.dg/alloc_comp_class_4.f03
gcc/testsuite/gfortran.dg/allocate_with_source_14.f03
gcc/testsuite/gfortran.dg/derived_constructor_comps_6.f90
gcc/testsuite/gfortran.dg/derived_result_5.f90 [new file with mode: 0644]