This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[FORTRAN] New -fboz-kind option to aid compilation of legacy code


The attached patch has been bootstrapped and regression
tested on x86_64-*-freebsd.  There were no new failures
in the testsuite.

Much old code and even new code fail to compile due to 
the Fortran 95 requirements on BOZ-literal-constants.
Read the audit trail for PR 18026 for the gory details.

Consider the following example:

troutmask:sgk[207] cat po.f90
program po
  integer x
  data x/z'ffffffff'/
  print *, x
end program po
troutmask:sgk[208] gfc4x -o z po.f90
po.f90:3:

  data x/z'ffffffff'/
                   1
Error: Arithmetic overflow converting INTEGER(16) to INTEGER(4) at (1)
troutmask:sgk[209] gfc4x -o z -fboz-kind=4 po.f90
troutmask:sgk[210] ./z
          -1

The patch simply allows an person to set the kind type parameter
used in the conversion of a BOZ to an integer.  Note, this patch
does not deal with the much more difficult problem of the nonstandard
use of BOZ to affect a bitwise copy of the BOZ into a REAL.

2006-11-13  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/18026
	* gfortran.texi: Update BOZ documentation to mention -fboz-kind.
	* gfortran.h (gfc_option_t): New member flag_boz_kind.
	* lang.opt: New option -fboz-kind=<n>.
	* invoke.texi: Document -fboz-kind.
	* primary.c (match_boz_constant):  Use option and member.
	* options.c (gfc_init_options):  Initialize flag_boz_kind
	(gfc_handle_option): Parse option.

Enjoy

-- 
Steve

Attachment: boz.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]