[patch, fortran] PR34495 - accepts invalid init-expr with TRANSFER

Daniel Franke franke.daniel@gmail.com
Tue Dec 18 11:43:00 GMT 2007

Hi all.

In initialization expressions, all arguments to any accepted intrinsic 
function must be (reducable to) constants. As in

    real x :: x = transfer(1234, x)

the usage of 'x' on the rhs does not meet the requirement. Neither does

    real x :: x = transfer(1234, y)

where 'y' is an implicitly typed variable. The same holds for PARAMETER 
definitions. The latter needed a wee bit more of attention as the generated 
error message was not correct by default. In all cases, the error now reads:

Error: Parameter '...' at (1) has not been declared or is a variable, which 
does not reduce to a constant expression

:ADDPATCH fortran:

2007-12-18  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/34495
	* expr.c (check_init_expr): Check whether variables with flavor
	FL_PARAMETER do have a value assigned.
	* simplify.c (gfc_simplify_transfer): Added check if the MOLD
	argument is a constant if working with initialization expressions.

2007-12-18  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/34495
	* transfer_simplify_2.f90: Fixed invalid initialization expressions.
	* transfer_simplify_7.f90: New test.

Regression tested on i686-pc-linux-gnu without errors.
Ok for trunk?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr34495.diff
Type: text/x-diff
Size: 2074 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20071218/1f12bfa5/attachment.bin>

More information about the Gcc-patches mailing list