diff mbox

[fortran,committed] Set deferred flag on typespec for temporary strings

Message ID 46935568-3b42-8429-4978-0117f3861624@netcologne.de
State New
Headers show

Commit Message

Thomas Koenig Aug. 15, 2016, 7:38 p.m. UTC
Hello world,

I just committed the attached patch as obvious and simple after
regression-testing.

One source of mysterious errors (and regressions) in the front end was
that the deferred flag on the typespec was not set for deffered strings.

Because some flags (including the deferred flag) in the typespec were
not output to the dump of the Fortran AST, I have also added this.

I will backport to 6 and 5 in a few days.

Regards

	Thomas

  2016-08-15  Thomas Koenig  <tkoenig@gcc.gnu.org>

         * frontend-passes.c (create_var):  Set ts.deferred for
         deferred-length character variables.
         * dump-parse-tree.c (show_typespec):  Also dump
         is_c_interop, is_iso_c and deferred flags.
diff mbox

Patch

Index: dump-parse-tree.c
===================================================================
--- dump-parse-tree.c	(Revision 239218)
+++ dump-parse-tree.c	(Arbeitskopie)
@@ -120,7 +120,15 @@  show_typespec (gfc_typespec *ts)
       fprintf (dumpfile, "%d", ts->kind);
       break;
     }
+  if (ts->is_c_interop)
+    fputs (" C_INTEROP", dumpfile);
 
+  if (ts->is_iso_c)
+    fputs (" ISO_C", dumpfile);
+
+  if (ts->deferred)
+    fputs (" DEFERRED", dumpfile);
+
   fputc (')', dumpfile);
 }
 
Index: frontend-passes.c
===================================================================
--- frontend-passes.c	(Revision 239218)
+++ frontend-passes.c	(Arbeitskopie)
@@ -616,6 +616,7 @@  create_var (gfc_expr * e, const char *vname)
   gfc_code *n;
   gfc_namespace *ns;
   int i;
+  bool deferred;
 
   if (e->expr_type == EXPR_CONSTANT || is_fe_temp (e))
     return gfc_copy_expr (e);
@@ -666,6 +667,7 @@  create_var (gfc_expr * e, const char *vname)
 	}
     }
 
+  deferred = 0;
   if (e->ts.type == BT_CHARACTER && e->rank == 0)
     {
       gfc_expr *length;
@@ -675,7 +677,10 @@  create_var (gfc_expr * e, const char *vname)
       if (length)
 	symbol->ts.u.cl->length = length;
       else
-	symbol->attr.allocatable = 1;
+	{
+	  symbol->attr.allocatable = 1;
+	  deferred = 1;
+	}
     }
 
   symbol->attr.flavor = FL_VARIABLE;
@@ -687,6 +692,7 @@  create_var (gfc_expr * e, const char *vname)
   result = gfc_get_expr ();
   result->expr_type = EXPR_VARIABLE;
   result->ts = e->ts;
+  result->ts.deferred = deferred;
   result->rank = e->rank;
   result->shape = gfc_copy_shape (e->shape, e->rank);
   result->symtree = symtree;