This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [fortran, patch] Enable Hollerith constant and character array in format tag.


--- Steven Bosscher <stevenb@suse.de> wrote:
> On Friday 08 April 2005 04:11, Feng Wang wrote:
> > Is anybody reviewing this? I think this is also an important extension.
> 
> I agree that it is important, but there really is more to do before
> the patch is OK.  At least two things come to mind (I hope I can't
> think up more for the next review ;-)
> 1. Can you add more test cases that:
>    * make sure we do the warnings;
>    * make sure holleriths can only appear where they are
>      allowed to appear (which is itself a debatable question);
>    * make sure (*cough*) "numerical" holleriths are converted
>      to the proper value;
>    * see what parts of the good old g77 test suite can now be
>      included in the gfortran test suite.
> 2. Document the extension (perhaps c&p from the g77 manual?).
> 
> Re. 1, consider for example:
>  
>        program freakmeout
>        implicit none
>        real r, x, y
>        parameter (r = 4hdead)
>        parameter (y = 4*r)
>        x = sin(r)
>        x = x * r
>        x = x / r
>        x = x + r
>        x = x - r
>        end
> 
> This segfaults with your patch.

Parameter, another parameter. Hmm, it seems that we have to support literal
arithmetic of Hollerith constant. Do we have to convert Hollerith to mpfr? And
mpfr shares a union with character in the gfc_expr. Should we save Hollerith to
character or mpfr? Character, of course. If we save to mpfr (supported we can),
how can we converted it to tree node? It may be not a validate real number and
I think we can not recover character from mpfr. We cannot save it to
value.character either, it will rewrite mpfr and cause mpfr arithmetic error.

Ok. I think we can add another field in gfc_expr:
struct
{
int length;
char * h_ch;
}

When we convert Hollerith to another numerical constant, we convert character
to mpfr (or mpz) with a pointer assignment from (char *) to (double *) and copy
character at the same time. We use mpfr in the constant arithmetic and use
character to convert to tree nodes.
But I am not sure (double*) is correct, and cannot predict its result.
Thoughts?



Best Regards,
Feng Wang

--
Creative Compiler Research Group,
National University of Defense Technology, China.

_________________________________________________________
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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]