[patch, RFC] Fix PR 30389 - ASCII functions

Steve Kargl sgk@troutmask.apl.washington.edu
Sat Jan 27 16:59:00 GMT 2007


On Wed, Jan 24, 2007 at 10:02:34PM +0100, Thomas Koenig wrote:
> 
> 2007-01-22  Thomas Koenig  <Thomas.Koenig@online.de>
> 
> 	PR libfortran/30389
> 	* gfortran.h:  Remove gfc_simplify_init_1.
> 	* arith.h:  Remove third argument from gfc_compare_string.
> 	* arith.c(gfc_compare_expression):  Remove third argument
> 	from call to gfc_compare_string.
> 	(gfc_compare_string):  Remove third argument xcoll_table.
> 	Remove use of xcoll_table.
> 	* misc.c(gfc_init_1):  Remove call to gfc_simplify_init_1.
> 	* simplify.c(ascii_table):  Remove.
> 	(xascii_table): Likewise.
> 	(gfc_simplify_achar):  ICE if extract_int fails.  Remove use of
> 	ascii_table.  Warn if -Wsurprising and value < 0 or > 127.
> 	(gfc_simplify_char):  ICE if extract_int fails. Warn if
> 	-Wsurprising and value < 0 or value > 255.
> 	(gfc_simplify_iachar):  Remove use of xascii_table.
> 	Char values outside of 0..255 are an ICE.
> 	(gfc_simplify_lge):  Remove use of xascii_table.
> 	(gfc_simplify_lgt):  Likewise.
> 	(gfc_simplify_lle):  Likewise.
> 	(gfc_simplify_llt):  Likewise.
> 	(invert_table):  Remove.
> 	(gfc_simplify_init_1):  Remove.
> 
> 2007-01-22  Thomas Koenig  <Thomas.Koenig@online.de>
> 
> 	PR libfortran/30389
> 	* gfortran.dg/achar_2.f90:  New test.
> 	* gfortran.dg/achar_3.f90:  New test.


OK with a few suggested changes.  Thanks.


> +  if (gfc_option.warn_surprising && (c < 0 || c > 127))
> +    gfc_warning ("Argument of ACHAR function at %L outside of range 0..127",
> +		 &e->where);

Can you change '0..127' to '[0,127]' or 1-127?  The two periods looks
odd to me because in at least the USA you'ld write '0, ..., 127' to
denote an enumeration with ellipsis.

> +  if (gfc_option.warn_surprising && (c < 0 || c > UCHAR_MAX))
> +    gfc_warning ("Argument of CHAR function at %L outside of range 0..255",
> +		 &e->where);

'0..255' becomes '[0,255]'

> +  if (gfc_option.warn_surprising && index > 127)
> +    gfc_warning ("Argument of IACHAR function at %L outside of range 0..127",
> +		 &e->where);

See above.

> +    gfc_internal_error("Argument of ICHAR at %L out of range",
> +		       &e->where);

Can you unwrap the above?  That is, &e->where fits on the previous line.

> +  return gfc_logical_expr (gfc_compare_string (a, b) >= 0,
>  			   &a->where);

Ditto.

> +  return gfc_logical_expr (gfc_compare_string (a, b) > 0,
>  			   &a->where);

Ditto.

> +  return gfc_logical_expr (gfc_compare_string (a, b) <= 0,
>  			   &a->where);

Ditto.

> +  return gfc_logical_expr (gfc_compare_string (a, b) < 0,
>  			   &a->where);

Ditto.

-- 
Steve



More information about the Gcc-patches mailing list