Re: [PATCH, fortran] PR89782 READ/WRITE of a character array when it is a parameter

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH, fortran] PR89782 READ/WRITE of a character array when it is a parameter

jerry DeLisle-3
On 6/22/19 11:32 AM, Steve Kargl wrote:

> On Sat, Jun 22, 2019 at 11:23:48AM -0700, Jerry DeLisle wrote:
>>
>> 2019-06-22  Jerry DeLisle  <[hidden email]>
>>
>> PR fortran/89782
>> * io.c (gfc_resolve_dt): Check that internal units are not
>> character PARAMETER.
>
> This part of the patch is missing.
>
>>
>> * gfortran.dg/io_constraints.f90: New test.
>>
>
> this part looks fine, but depends on the missing part.
>

Sorry about that, I missed the HEAD in "git diff HEAD".

Jerry

diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c
index 425c2b86899..cd21c6bcf82 100644
--- a/gcc/fortran/io.c
+++ b/gcc/fortran/io.c
@@ -3328,6 +3328,14 @@ gfc_resolve_dt (gfc_dt *dt, locus *loc)
        return false;
      }

+  if (e->symtree && e->symtree->n.sym->attr.flavor == FL_PARAMETER
+      && e->ts.type == BT_CHARACTER)
+    {
+      gfc_error ("UNIT specification at %L must "
+      "not be a character PARAMETER", &e->where);
+      return false;
+    }
+
    if (gfc_resolve_expr (e)
        && (e->ts.type != BT_INTEGER
   && (e->ts.type != BT_CHARACTER || e->expr_type != EXPR_VARIABLE)))