[PATCH, fortran] character length (PR fortran/21730)

David Edelsohn dje@watson.ibm.com
Wed Jul 13 17:38:00 GMT 2005


	Gfortran currently assigns an initializer to a symbol if the two
are conforming, but character initializers are not truncated or padded to
match a fixed character length target.  This patch calls
gfc_set_constant_character_len() to adjust the initializer so that it
conforms to the target character length.

Bootstrapped.  Okay if no regressions?

Thanks, David


        PR fortran/21730
        * decl.c (do_parm): Adjust character initializer to character length
        of symbol before assigning.

Index: decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/decl.c,v
retrieving revision 1.37
diff -c -p -r1.37 decl.c
*** decl.c	6 Jul 2005 22:12:12 -0000	1.37
--- decl.c	13 Jul 2005 17:35:16 -0000
*************** do_parm (void)
*** 3101,3106 ****
--- 3101,3116 ----
        goto cleanup;
      }
  
+   if (sym->ts.type == BT_CHARACTER
+       && sym->ts.cl != NULL
+       && sym->ts.cl->length != NULL
+       && sym->ts.cl->length->expr_type == EXPR_CONSTANT
+       && init->expr_type == EXPR_CONSTANT
+       && init->ts.type == BT_CHARACTER
+       && init->ts.kind == 1)
+     gfc_set_constant_character_len (
+       mpz_get_si (sym->ts.cl->length->value.integer), init);
+ 
    sym->value = init;
    return MATCH_YES;
  



More information about the Fortran mailing list