]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fortran: f_c_string intrinsic improvements
authorSandra Loosemore <sloosemore@baylibre.com>
Thu, 28 May 2026 22:33:33 +0000 (22:33 +0000)
committerSandra Loosemore <sloosemore@baylibre.com>
Thu, 28 May 2026 23:41:45 +0000 (23:41 +0000)
commit656d97bbc4b0f4614f1f074ab3ca7c425fe569d2
tree1934117d1223bd790419e7dce7b349426d007e7c
parenta6b2fe7f54bffc4006bee4b20dd788c0a81a9e2e
Fortran: f_c_string intrinsic improvements

The existing implementation of f_c_string is quite inefficient, doing
either 2 or 3 allocations and copies of the input string prefix.  This
rewrite adds folding for constant string arguments and handles other
cases with a single allocation and copy.

This patch also adds the missing documentation for this intrinsic to the
gfortran manual.

gcc/fortran/ChangeLog
* intrinsic.texi (F_C_STRING): New section.
* trans-intrinsic.cc (conv_trim): Delete.
(conv_isocbinding_function): Rewrite the F_C_STRING case.

gcc/testsuite/ChangeLog
* gfortran.dg/f_c_string3.f90: New.
* gfortran.dg/f_c_string4.f90: New.
* gfortran.dg/f_c_string5.f90: New.
gcc/fortran/intrinsic.texi
gcc/fortran/trans-intrinsic.cc
gcc/testsuite/gfortran.dg/f_c_string3.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/f_c_string4.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/f_c_string5.f90 [new file with mode: 0644]