This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [gfortran] PATCH: Allow wide boz constants
Tobias Schlüter wrote:
> Both examples are not conforming code, as boz-literal-constants are only
> allowed as data initializers, so we could do whatever we want, and that's why
> I didn't bother to preserve existing semantics in those cases. But I
> understand that F2K allows boz constants everywhere, so I will look if that
> standard offers a solution for these kinds of issues. I'll also see if that's
> any different from what g77 does.
F2K only allows boz-literal-constants under certain circumstances, and g77
always makes them integer*4. Some closer reading of the Fortran 95 standard
revealed to me that the kind of boz-literal-constants is defined, and it is
the default integer kind.
Given this, I concluded that the right way t osolving the problem I outlined
before, would be allowing kind parameter suffixes also on boz literal
constants. This is implemented by the appended patch. This patch does one more
thing: it moves the error for non-standard constants of the form x'd1325ff' (x
instead of z) further to the front of the function, thereby making it possible
to remove the cleanup code from that path.
Built and tested, verified that it works except for the preexisting issues
that are related to the new PR 17872. Along with this I will commit some tests
for the bit intrinsics which will make use of the features in this patch. Ok?
- Tobi
2004-10-07 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
* primary.c (match_boz_constant): Allow kind parameter suffixes.
Move standard warning further to the front.
Index: primary.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/primary.c,v
retrieving revision 1.12
diff -c -3 -p -r1.12 primary.c
*** primary.c 31 Aug 2004 13:35:01 -0000 1.12
--- primary.c 6 Oct 2004 22:54:55 -0000
*************** match_integer_constant (gfc_expr ** resu
*** 235,241 ****
static match
match_boz_constant (gfc_expr ** result)
{
! int radix, delim, length, x_hex;
locus old_loc;
char *buffer;
gfc_expr *e;
--- 235,241 ----
static match
match_boz_constant (gfc_expr ** result)
{
! int radix, delim, length, x_hex, kind;
locus old_loc;
char *buffer;
gfc_expr *e;
*************** match_boz_constant (gfc_expr ** result)
*** 272,277 ****
--- 272,283 ----
if (delim != '\'' && delim != '\"')
goto backup;
+ if (x_hex && pedantic
+ && (gfc_notify_std (GFC_STD_GNU, "Extension: Hexadecimal "
+ "constant at %C uses non-standard syntax.")
+ == FAILURE))
+ return MATCH_ERROR;
+
old_loc = gfc_current_locus;
length = match_digits (0, radix, NULL);
*************** match_boz_constant (gfc_expr ** result)
*** 293,317 ****
memset (buffer, '\0', length + 1);
match_digits (0, radix, buffer);
! gfc_next_char ();
! e = gfc_convert_integer (buffer, gfc_default_integer_kind, radix,
! &gfc_current_locus);
if (gfc_range_check (e) != ARITH_OK)
{
! gfc_error ("Integer too big for default integer kind at %C");
!
! gfc_free_expr (e);
! return MATCH_ERROR;
! }
- if (x_hex
- && pedantic
- && (gfc_notify_std (GFC_STD_GNU, "Extension: Hexadecimal "
- "constant at %C uses non-standard syntax.")
- == FAILURE))
- {
gfc_free_expr (e);
return MATCH_ERROR;
}
--- 299,323 ----
memset (buffer, '\0', length + 1);
match_digits (0, radix, buffer);
! gfc_next_char (); /* Eat delimiter. */
! kind = get_kind ();
! if (kind == -1)
! return MATCH_ERROR;
! if (kind == -2)
! kind = gfc_default_integer_kind;
! else if (pedantic
! && (gfc_notify_std (GFC_STD_GNU, "Extension: Kind parameter "
! "suffix to boz literal constant at %C.")
! == FAILURE))
! return MATCH_ERROR;
!
! e = gfc_convert_integer (buffer, kind, radix, &gfc_current_locus);
if (gfc_range_check (e) != ARITH_OK)
{
! gfc_error ("Integer too big for integer kind %i at %C", kind);
gfc_free_expr (e);
return MATCH_ERROR;
}