diff options
author | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2010-08-27 06:50:03 +0000 |
---|---|---|
committer | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2010-08-27 06:50:03 +0000 |
commit | 401fcd3b8fd7158703263fd4de33a23faa7a2738 (patch) | |
tree | b23e60e3b6c1de5d17cec4f6a741db7d30a1e5bf /gcc/fortran/primary.c | |
parent | 9f8f1def9dd5d303a437397c5e1aaa60aef468d9 (diff) | |
download | gcc-401fcd3b8fd7158703263fd4de33a23faa7a2738.zip gcc-401fcd3b8fd7158703263fd4de33a23faa7a2738.tar.gz gcc-401fcd3b8fd7158703263fd4de33a23faa7a2738.tar.bz2 |
re PR fortran/43217 (Output of Hollerith constants which are not a multiple of 4 bytes)
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.
From-SVN: r163581
Diffstat (limited to 'gcc/fortran/primary.c')
-rw-r--r-- | gcc/fortran/primary.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c index 6388985..b07632d 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; |