diff options
author | jvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-08-27 06:50:03 +0000 |
---|---|---|
committer | jvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-08-27 06:50:03 +0000 |
commit | 757fb7abad2d7d7a512cae4e1d8e836402f826f1 (patch) | |
tree | b23e60e3b6c1de5d17cec4f6a741db7d30a1e5bf /gcc/fortran | |
parent | cda5fe864d366d244bbfb4da6d492cfc837dea7d (diff) | |
download | gcc-757fb7abad2d7d7a512cae4e1d8e836402f826f1.tar.gz |
2010-08-27 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/43217
* primary.c (match_hollerith_constant): Calculate padding needed to
fill default integer and allocate string for that size. Set pad bytes
to ' '.
* gfortran.h: Add hollerith pad value to type spec union.
* data.c (create_character_initializer): Fix spelling of function name.
Use hollerith pad value to calculate length.
* arith.c (hollerith2representation); Use hollerith pad value to
calculate length.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@163581 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran')
-rw-r--r-- | gcc/fortran/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/fortran/arith.c | 2 | ||||
-rw-r--r-- | gcc/fortran/data.c | 8 | ||||
-rw-r--r-- | gcc/fortran/gfortran.h | 1 | ||||
-rw-r--r-- | gcc/fortran/primary.c | 16 |
5 files changed, 30 insertions, 9 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 4377bd2e0da..f28030f936e 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,15 @@ +2010-08-27 Jerry DeLisle <jvdelisle@gcc.gnu.org> + + PR fortran/43217 + * primary.c (match_hollerith_constant): Calculate padding needed to + fill default integer and allocate string for that size. Set pad bytes + to ' '. + * gfortran.h: Add hollerith pad value to type spec union. + * data.c (create_character_initializer): Fix spelling of function name. + Use hollerith pad value to calculate length. + * arith.c (hollerith2representation); Use hollerith pad value to + calculate length. + 2010-08-26 Daniel Kraft <d@domob.eu> PR fortran/38936 diff --git a/gcc/fortran/arith.c b/gcc/fortran/arith.c index f555eb104cd..2a9ea750103 100644 --- a/gcc/fortran/arith.c +++ b/gcc/fortran/arith.c @@ -2260,7 +2260,7 @@ hollerith2representation (gfc_expr *result, gfc_expr *src) { int src_len, result_len; - src_len = src->representation.length; + src_len = src->representation.length - src->ts.u.pad; result_len = gfc_target_expr_size (result); if (src_len > result_len) diff --git a/gcc/fortran/data.c b/gcc/fortran/data.c index 6829fe9cd03..b1cfd6ec75b 100644 --- a/gcc/fortran/data.c +++ b/gcc/fortran/data.c @@ -100,8 +100,8 @@ find_con_by_component (gfc_component *com, gfc_constructor_base base) according to normal assignment rules. */ static gfc_expr * -create_character_intializer (gfc_expr *init, gfc_typespec *ts, - gfc_ref *ref, gfc_expr *rvalue) +create_character_initializer (gfc_expr *init, gfc_typespec *ts, + gfc_ref *ref, gfc_expr *rvalue) { int len, start, end; gfc_char_t *dest; @@ -149,7 +149,7 @@ create_character_intializer (gfc_expr *init, gfc_typespec *ts, /* Copy the initial value. */ if (rvalue->ts.type == BT_HOLLERITH) - len = rvalue->representation.length; + len = rvalue->representation.length - rvalue->ts.u.pad; else len = rvalue->value.character.length; @@ -342,7 +342,7 @@ gfc_assign_data_value (gfc_expr *lvalue, gfc_expr *rvalue, mpz_t index) { if (lvalue->ts.u.cl->length == NULL && !(ref && ref->u.ss.length != NULL)) return FAILURE; - expr = create_character_intializer (init, last_ts, ref, rvalue); + expr = create_character_initializer (init, last_ts, ref, rvalue); } else { diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 689b9df636b..c84c63387a2 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -880,6 +880,7 @@ typedef struct { struct gfc_symbol *derived; /* For derived types only. */ gfc_charlen *cl; /* For character types only. */ + int pad; /* For hollerith types only. */ } u; diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c index 63889856604..b07632d951c 100644 --- a/gcc/fortran/primary.c +++ b/gcc/fortran/primary.c @@ -242,7 +242,7 @@ match_hollerith_constant (gfc_expr **result) locus old_loc; gfc_expr *e = NULL; const char *msg; - int num; + int num, pad; int i; old_loc = gfc_current_locus; @@ -279,7 +279,10 @@ match_hollerith_constant (gfc_expr **result) e = gfc_get_constant_expr (BT_HOLLERITH, gfc_default_character_kind, &gfc_current_locus); - e->representation.string = XCNEWVEC (char, num + 1); + /* Calculate padding needed to fit default integer memory. */ + pad = gfc_default_integer_kind - (num % gfc_default_integer_kind); + + e->representation.string = XCNEWVEC (char, num + pad + 1); for (i = 0; i < num; i++) { @@ -294,8 +297,13 @@ match_hollerith_constant (gfc_expr **result) e->representation.string[i] = (unsigned char) c; } - e->representation.string[num] = '\0'; - e->representation.length = num; + /* Now pad with blanks and end with a null char. */ + for (i = 0; i < pad; i++) + e->representation.string[num + i] = ' '; + + e->representation.string[num + i] = '\0'; + e->representation.length = num + pad; + e->ts.u.pad = pad; *result = e; return MATCH_YES; |