[gfortran] PATCH: Allow wide boz constants

Tobias Schlüter tobias.schlueter@physik.uni-muenchen.de
Wed Oct 6 17:33:00 GMT 2004


Currently, we always parse boz-literal-constants as INTEGER*4. This was a
problem for me when I wanted to write testcases for our bit intrinsics, as I
couldn't enter numbers in hexadecimal, which of course makes it much easier to
see what should happen in bit handling.

The fundamental issue with this is that we don't know which type variable a
data constant will be assigned to. I briefly contemplated adding kind suffixes
to boz-literal-constants, like z'44444'_4, but not only is this ugly, it is
also superfluous, as the kind information is certainly redundant, as the boz
constant will always be the initial value of a variable of a fixed type.
Instead I developed this patch, which determines the smallest integer kind
that a given boz-literal-constant of a certain length (measured in characters
of source code) will fit in, and then sets the constant to that kind. Of
course leading zeros will set off this scheme, and we will give the
initialization a bigger kind than required, but as the value will be converted
to the type of the corresponding variable, this works as well. Another special
case is where there are more digits than supported by any integer kind. In
this case this patch sets the value to the largest available integer kind, and
then we will get an error if the value actually overflows that kind.

Built, and verified. When trying to run the testsuite I found out that
something in my tree broke during the last build, so I couldn't yet test this.
Along with this patch I will add new testcases for the bit functions which
will exercise this code. Ok if the testsuite passes?

- Tobi

2004-10-06  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>

	* primary.c (match_boz_constant): Determine required bit width from
	constant.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: boz.diff
Type: text/x-patch
Size: 2140 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20041006/03e2063c/attachment.bin>


More information about the Gcc-patches mailing list