This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch, fortran, committed] Set deferred flag on typespec for temporary strings
- From: Thomas Koenig <tkoenig at netcologne dot de>
- To: "fortran at gcc dot gnu dot org" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 15 Aug 2016 21:38:23 +0200
- Subject: [patch, fortran, committed] Set deferred flag on typespec for temporary strings
- Authentication-results: sourceware.org; auth=none
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.
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;