[patch, fortran] Add string padding on assignment

Thomas Koenig tkoenig@netcologne.de
Tue Sep 28 09:35:00 GMT 2010


Hello world,

this patch addresses the case where a constant string is assigned to a
longer string, requiring padding with blanks.  This adds the blanks in
the front end, transforming

character*2 a
a = 'y'


into
character*2 a
a = 'y '

To avoid bloat for strings, I set an arbitrary limit of <8 spaces to be
padded, but of course I'd welcome better suggesionts.

Regression-tested.  OK for trunk with or without a better strategy?

	Thomas

2010-09-27  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/45636
	* frontend-passes.c (optimize_assignment):  In an assignment,
	fill up blanks on the right-hand side if fewer than
	STRING_PAD_LIMIT characters are missing.

2010-09-27  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/45636
	* gfortran.dg/character_pad_1.f90:  New test.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: len-3.diff
Type: text/x-patch
Size: 2333 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20100928/79a8e38f/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: character_pad_1.f90
Type: text/x-fortran
Size: 355 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20100928/79a8e38f/attachment-0001.bin>


More information about the Gcc-patches mailing list