[gfortran] Fix CHAR intrinsic.

Paul Brook paul@nowt.org
Sat Oct 11 20:59:00 GMT 2003


Patch below fixes the CHAR & ACHAR intrinsics (with testcase).

Applied to tree-ssa branch.

Paul

2003-10-11  Huang Chun  <jiwang@mail.edu.cn>

	* trans-intrinsic.c (gfc_conv_intrinsic_char): Don't use
	gfc_get_character_type.

2003-10-11  Paul Brook  <paul@nowt.org>

	* gfortran.fortran-torture/execute/intrinsic_achar.f90: New test.

--- clean/tree-ssa/gcc/fortran/trans-intrinsic.c
+++ gcc/gcc/fortran/trans-intrinsic.c
@@ -898,12 +898,11 @@ gfc_conv_intrinsic_char (gfc_se * se, gf
 
   /* We currently don't support character types != 1.  */
   assert (expr->ts.kind == 1);
-  type = gfc_get_character_type (expr->ts.kind, expr->ts.cl);
+  type = gfc_character1_type_node;
   var = gfc_create_var (type, "char");
   TREE_ADDRESSABLE (var) = 1;
 
-  arg = convert (gfc_character1_type_node, arg);
-  var = build (ARRAY_REF, gfc_character1_type_node, var, integer_one_node);
+  arg = convert (type, arg);
   gfc_add_modify_expr (&se->pre, var, arg);
   se->expr = build1 (ADDR_EXPR, build_pointer_type (type), var);
   se->string_length = integer_one_node;
-------------- next part --------------
! Program to test the ACHAR and IACHAR intrinsics
program intrinsic_achar
  integer i

  i = 32
  if (achar(i) .ne. " ") call abort
  i = iachar("A")
  if ((i .ne. 65) .or. char(i) .ne. "A") call abort
end program


More information about the Fortran mailing list