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: [gfortran,patch] Hollerith constants with -fdump-parse-tree


--- 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;
 }
 

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