[PATCH 2/5] fortran: [PR49802] Allow VALUE attribute on assumed-length CHARACTER and array dummies
Jerry D
jvdelisle2@gmail.com
Mon Aug 24 23:32:57 GMT 2026
See attached 2 of 5 patch
Regression tested on x86_64
Regards,
Jerry
---
fortran: [PR49802]-2 Allow VALUE on assumed-length
CHARACTER dummies
Fortran 2003 C528 prohibited the VALUE attribute on a CHARACTER dummy
whose length is not one. Fortran 2008 relaxed this with C557, and
F2023 Annex C.2 lists it as a Fortran 2008 feature that the Fortran
2008 Introduction did not mention. gfortran was still rejecting both
an assumed length and a specified but non-constant length, such as
another dummy argument used as the length.
resolve.cc relaxes the constant-length requirement, gated by
gfc_notify_std so that -std=f2003 still rejects it, and consolidates
the C-interop length checks into a single "must have length one"
condition ordered ahead of the Fortran 2008 allowance.
trans-types.cc keeps such a dummy passed by reference, since VALUE now
means copy-in-only semantics rather than pass-by-value of the raw data,
and conv_dummy_value makes the caller-side copy. The copy size is
scaled by the size of the character kind, so that a kind wider than one
byte copies the whole string rather than its first bytes.
PR fortran/49802
gcc/fortran/ChangeLog:
* resolve.cc (resolve_symbol): Allow character(len=*) VALUE and a
specified but non-constant length under Fortran 2008; consolidate
the C-interop length checks into a single "must have length one"
check ordered ahead of the Fortran 2008 allowance.
* trans-expr.cc (conv_dummy_value): For assumed-length or
non-constant-length CHARACTER VALUE dummies, make a caller-side
copy and pass its address; scale the copy size by the size of the
character kind.
* trans-types.cc (gfc_sym_type): Use byref=1 for assumed-length or
non-constant-length VALUE character dummies, so the ABI still
passes by reference.
gcc/testsuite/ChangeLog:
* gfortran.dg/value_5.f90: Compile under -std=f2003 so the Fortran
2008 assumed-length VALUE relaxation is exercised as a rejection,
and update the C-interop error expectation to match the
consolidated diagnostic.
* gfortran.dg/value_6.f90: New test.
* gfortran.dg/value_7.f90: New test.
* gfortran.dg/value_11.f90: New test.
* gfortran.dg/value_14.f90: New test.
---
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PR49802-2of5-assumed-length-char.patch
Type: text/x-patch
Size: 11945 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/fortran/attachments/20260824/268868b6/attachment.bin>
More information about the Fortran
mailing list