[PATCH] PR fortran/58027,60993 -- BOZ in array constructor initialization expression

Steve Kargl sgk@troutmask.apl.washington.edu
Mon Nov 16 02:22:00 GMT 2015


First, thanks to Dominiq for prodding me into looking at PR 58027.

This was a fun ICE to track down!

Most users have no idea what the Fortran standard requires for
the parsing of a BOZ.  Consider the line of code

  integer, parameter :: i(1) = (/ z'ff800000' /)

The naive user wants to assign a BOZ interpreted as a 32-bit entity
to i(1) in an array constructor.  Ignoring the fact that a BOZ 
can't be used here, the BOZ is converted to an integer with the
widest decimal exponential range.  On all(?) targets this is at
least a 64-bit integer (known as INTEGER(8)).  To do the assignment
gfortan inserts a __convert_i8_i4(), but it does so after any
checking for an initialization expression.  So, when gfortran
finally gets around to calling gfc_conv_array_initializer() to
translates into tree-ssa form, gfc_conv_array_initializer() is not
expecting a function and dies with an ICE. 

The fix is affected by calling gfc_check_init_expr() under
appropriate conditions.  Because the __convert_* functions
are sort of psuedo-intrinsic procedures, a check for an intrinsic
procedure needs to be circumvented.

Anyway, the patch has been built and tested on i386-*-freebsd
and x86_64-*-freebsd.  OK to commit?

2015-11-15  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/58027
	PR fortran/60993
	* expr.c (gfc_check_init_expr): Prevent a redundant check when a
	__convert_* function was inserted into an array constructor.
	(gfc_check_assign_symbol): Check for an initialization expression
	when a __convert_* was inserted.

2015-11-15  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/58027
	PR fortran/60993
	* gfortran.dg/pr58027.f90: New test.

-- 
Steve
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr58027.diff
Type: text/x-diff
Size: 2508 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20151116/bc1e5686/attachment.bin>


More information about the Fortran mailing list