PR 83975 Associate target with non-constant character length
authorJanne Blomqvist <jb@gcc.gnu.org>
Thu, 1 Feb 2018 19:47:15 +0000 (21:47 +0200)
committerJanne Blomqvist <jb@gcc.gnu.org>
Thu, 1 Feb 2018 19:47:15 +0000 (21:47 +0200)
When associating a variable of type character, if the length of the
target isn't known at compile time, generate an error. See PR 83344
for more details.

Regtested on x86_64-pc-linux-gnu.

gcc/fortran/ChangeLog:

2018-02-01  Janne Blomqvist  <jb@gcc.gnu.org>

PR 83975
PR 83344
* resolve.c (resolve_assoc_var): Generate an error if
target length unknown.

From-SVN: r257310

gcc/fortran/ChangeLog
gcc/fortran/resolve.c

index 6f6a21a413c44cc088b14fab1e855edaaf8ae868..d5a6e2641de35e83fcb7824868f24b485149eaef 100644 (file)
@@ -1,3 +1,10 @@
+2018-02-01  Janne Blomqvist  <jb@gcc.gnu.org>
+
+       PR 83975
+       PR 83344
+       * resolve.c (resolve_assoc_var): Generate an error if
+       target length unknown.
+
 2018-02-01  Janne Blomqvist  <jb@gcc.gnu.org>
 
        PR fortran/83705
index 9c8ba868a5a09a0b846a63f059d22f0c0f075599..60b9bc306ef9b295abba39fbde73f8082009c40a 100644 (file)
@@ -8634,11 +8634,16 @@ resolve_assoc_var (gfc_symbol* sym, bool resolve_target)
       if (!sym->ts.u.cl)
        sym->ts.u.cl = target->ts.u.cl;
 
-      if (!sym->ts.u.cl->length && !sym->ts.deferred
-         && target->expr_type == EXPR_CONSTANT)
-       sym->ts.u.cl->length
-         = gfc_get_int_expr (gfc_charlen_int_kind,
-                             NULL, target->value.character.length);
+      if (!sym->ts.u.cl->length && !sym->ts.deferred)
+       {
+         if (target->expr_type == EXPR_CONSTANT)
+           sym->ts.u.cl->length =
+             gfc_get_int_expr (gfc_charlen_int_kind, NULL,
+                               target->value.character.length);
+         else
+           gfc_error ("Not Implemented: Associate target with type character"
+                      " and non-constant length at %L", &target->where);
+       }
     }
 
   /* If the target is a good class object, so is the associate variable.  */