+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
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;
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
--- /dev/null
+! { 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