This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
re: [gfortran,patch] Hollerith constants with -fdump-parse-tree
- From: Feng Wang <wf_cs at yahoo dot com>
- To: Feng Wang <wf_cs at yahoo dot com>, "François-Xavier" Coudert <fxcoudert at gmail dot com>, GFortran <fortran at gcc dot gnu dot org>, patch <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 16 May 2006 22:21:55 +0800 (CST)
- Subject: re: [gfortran,patch] Hollerith constants with -fdump-parse-tree
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=kQ3cnpZhX9T+41K/EvJ9ihcpqEMELWWRCIDjXLD5jpOrI6tEauq/63li3SxvbBbW6EbiO1+PIidJw5aypSDbNtMuXJ8ehIF/pHdnAM2fqvWrphrMUClWuvyB1d50L/F/bMBKVrS5lN1g2GRqDREqwdKKmQmFU5KFoUFUL+gbY8g= ;
--- Feng Wang <wf_cs@yahoo.com> wrote:
> --- Fran?is-Xavier Coudert <fxcoudert@gmail.com> wrote:
>
> > :ADDPATCH fortran:
> >
> > Attached patch fixes PR fortran/27552: we couldn't use
> > -fdump-parse-tree on a code containing Holleriths, because there was
> > no code in place in dump_parse_tree.c to handle them. The patch is
> > very simple and self-contained, regtested on i686-linux.
> >
>
> Your patch is not enough. BT_HOLLERITH constants should also be handled. Not
> all the strings are terminated by '\0', so the output should use the length
> to
> control. And when a character variable is initialized by a Hollerith constant
> in data statement, it can not be dumped properly.
>
> I modified your patch to fix them.
>
Regtested on ia64-linux. Updated diff file attached. OK for mainline and 4.1?
ChangeLog entry:
2006-05-16 Francois-Xavier Coudert <coudert@clipper.ens.fr>
Feng Wang <fengwang@nudt.edu.cn>
PR fortran/27552
* dump-parse-tree.c (gfc_show_expr): Deal with Hollerith constants.
* data.c (create_character_intializer): Set from_H flag if character is
initialized by Hollerith constant.
Feng Wang
___________________________________________________________
雅虎免费邮箱-3.5G容量,20M附件
http://cn.mail.yahoo.com/
Index: dump-parse-tree.c
===================================================================
--- dump-parse-tree.c (revision 113823)
+++ dump-parse-tree.c (working copy)
@@ -348,6 +348,16 @@ gfc_show_expr (gfc_expr * p)
break;
case EXPR_CONSTANT:
+ if (p->from_H || p->ts.type == BT_HOLLERITH)
+ {
+ gfc_status ("%dH", p->value.character.length);
+ c = p->value.character.string;
+ for (i = 0; i < p->value.character.length; i++, c++)
+ {
+ gfc_status_char (*c);
+ }
+ break;
+ }
switch (p->ts.type)
{
case BT_INTEGER:
Index: data.c
===================================================================
--- data.c (revision 113823)
+++ data.c (working copy)
@@ -192,6 +192,9 @@ create_character_intializer (gfc_expr *
if (len < end - start && ref == NULL)
memset (&dest[start + len], ' ', end - (start + len));
+ if (rvalue->ts.type == BT_HOLLERITH)
+ init->from_H = 1;
+
return init;
}