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
+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
{
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)
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;
/* 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;
{
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
{
{
struct gfc_symbol *derived; /* For derived types only. */
gfc_charlen *cl; /* For character types only. */
+ int pad; /* For hollerith types only. */
}
u;
locus old_loc;
gfc_expr *e = NULL;
const char *msg;
- int num;
+ int num, pad;
int i;
old_loc = gfc_current_locus;
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++)
{
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;