[fortran, patch] Fix PR15959, character array initialization.
Feng Wang
wf_cs@yahoo.com
Fri Apr 1 13:01:00 GMT 2005
--- Steven Bosscher <stevenb@suse.de> wrote:
> On Apr 01, 2005 11:45 AM, Feng Wang <wf_cs@yahoo.com> wrote:
> > This patch fix pr15959. If we resolve a constant character array, update
> the
> > expression's character length with the maximun of its constructor. And set
> the
> > initializer's length to symbol.
> >
> > Tested with no regression on i686. Ok for mainline and gcc40?
>
> Mostly looks OK. A few points:
>
> ! max_length = (p->expr->value.character.length > max_length) ?
> ! p->expr->value.character.length : max_length;
>
> I believe we have a MAX macro for this.
Yes. Changed.
>
> ! else
> ! return;
>
> Why return here, can you add a comment? Can this happen at all,
> that we have a non-EXPR_CONSTANT in an character array initializer?
This is not only for initializer. We may have variable character array
constructor. I will add comment for this. Example from
gfortran.dg/string_ctor_1.f90:
subroutine test (n, t, u)
integer n
character(len=n) :: s(2)
character(len=*) :: t
character(len=*) :: u
! A variable array constructor.
s = (/t, u/)
end subroutine
>
>
> ! p->expr->ts.cl->length = gfc_int_expr (max_length);
>
> Maybe a really silly question, but I suppose we pad the strings
> that are shorter? Could you add a comment here about where that
> happens?
>
Yes, it is a really question. In fact we now don't pad parameter string. But I
think it is another bug. Example follows:
character(len = 10),parameter:: a = 'hello'
print *, a, "world"
end
And I report this bug as PR20713.
Best Regards,
Feng Wang
_________________________________________________________
Do You Yahoo!?
150ÃòÃúMP3·è¿ñÃ㬴øÃú´³ÃëÃôÃõîÃÃ
http://music.yisou.com/
ÃÃÃ
®Ã÷ÃÃæÃþ¡Ãã¬ÃñéÃÃü¡¢ÃÃüºÃ¿áü
http://image.yisou.com
1G¾ÃÃÃ1000Ãã¬ÃÃ
»¢µçÃÃÃÃÃúéÃã¡
http://cn.rd.yahoo.com/mail_cn/tag/1g/*http://cn.mail.yahoo.com/event/mail_1g/
More information about the Gcc-patches
mailing list