From ae976c332dca908d826a71cdc81d28af71552939 Mon Sep 17 00:00:00 2001 From: Janne Blomqvist Date: Thu, 1 Feb 2018 21:47:15 +0200 Subject: [PATCH] PR 83975 Associate target with non-constant character length 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 PR 83975 PR 83344 * resolve.c (resolve_assoc_var): Generate an error if target length unknown. From-SVN: r257310 --- gcc/fortran/ChangeLog | 7 +++++++ gcc/fortran/resolve.c | 15 ++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 6f6a21a413c..d5a6e2641de 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2018-02-01 Janne Blomqvist + + PR 83975 + PR 83344 + * resolve.c (resolve_assoc_var): Generate an error if + target length unknown. + 2018-02-01 Janne Blomqvist PR fortran/83705 diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 9c8ba868a5a..60b9bc306ef 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -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. */ -- 2.30.2