Commit 7d60270a by Feng Wang Committed by Feng Wang

simplify.c (gfc_simplify_char): Use UCHAR_MAX instead of literal constant.

fortran/
2006-01-09  Feng Wang  <fengwang@nudt.edu.cn>

	* simplify.c (gfc_simplify_char): Use UCHAR_MAX instead of literal
	constant.
	(gfc_simplify_ichar): Get the result from unsinged char and in the
	range 0 to UCHAR_MAX instead of CHAR_MIN to CHAR_MAX.

Testsuite ChangeLog entry:
2006-01-09  Feng Wang  <fengwang@nudt.edu.cn>

	* gfortran.dg/intrinsic_i_char.f90: New test.

From-SVN: r109488
parent 3b0a1d36
2006-01-09 Feng Wang <fengwang@nudt.edu.cn>
* simplify.c (gfc_simplify_char): Use UCHAR_MAX instead of literal
constant.
(gfc_simplify_ichar): Get the result from unsinged char and in the
range 0 to UCHAR_MAX instead of CHAR_MIN to CHAR_MAX.
2005-01-08 Erik Edelmann <eedelman@gcc.gnu.org>
PR fortran/25093
......
......@@ -662,7 +662,7 @@ gfc_simplify_char (gfc_expr * e, gfc_expr * k)
if (e->expr_type != EXPR_CONSTANT)
return NULL;
if (gfc_extract_int (e, &c) != NULL || c < 0 || c > 255)
if (gfc_extract_int (e, &c) != NULL || c < 0 || c > UCHAR_MAX)
{
gfc_error ("Bad character in CHAR function at %L", &e->where);
return &gfc_bad_expr;
......@@ -1370,9 +1370,9 @@ gfc_simplify_ichar (gfc_expr * e)
return &gfc_bad_expr;
}
index = (int) e->value.character.string[0];
index = (unsigned char) e->value.character.string[0];
if (index < CHAR_MIN || index > CHAR_MAX)
if (index < 0 || index > UCHAR_MAX)
{
gfc_error ("Argument of ICHAR at %L out of range of this processor",
&e->where);
......
2006-01-09 Feng Wang <fengwang@nudt.edu.cn>
* gfortran.dg/ichar_2.f90: New test.
2005-01-08 Erik Edelmann <eedelman@gcc.gnu.org>
PR fortran/25093
! { dg-do run }
! Test char and ichar intrinsic functions
Program test
integer i
if (ichar (char (0)) .ne. 0) call abort ()
if (ichar (char (255)) .ne. 255) call abort ()
if (ichar (char (127)) .ne. 127) call abort ()
i = 0
if (ichar (char (i)) .ne. i) call abort ()
i = 255
if (ichar (char (i)) .ne. i) call abort ()
i = 127
if (ichar (char (i)) .ne. i) call abort ()
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment