https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127187

--- Comment #12 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
I can reproduce the failure with -fdefault-integer-8.

$ gfc -fdefault-integer-8 associate_90.f90 
$ ./a.out 
ERROR STOP 8

And this fixes it.

diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 7ad9eeb2db5..dd9ae1817e4 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -10844,6 +10844,16 @@ resolve_assoc_var (gfc_symbol* sym, bool
resolve_target)
                           && !gfc_has_vector_subscript (target))
                          || gfc_is_ptr_fcn (target));

+  /* A type parameter inquiry is not a variable.  */
+  if (sym->assoc->variable && target->expr_type == EXPR_VARIABLE)
+    for (gfc_ref *ref = target->ref; ref; ref = ref->next)
+      if (ref->type == REF_INQUIRY
+         && (ref->u.i == INQUIRY_LEN || ref->u.i == INQUIRY_KIND))
+       {
+         sym->assoc->variable = false;
+         break;
+       }
+
   /* Finally resolve if this is an array or not.  */
   if (target->expr_type == EXPR_FUNCTION && target->rank == 0
       && (sym->ts.type == BT_CLASS || sym->ts.type == BT_DERIVED))

Reply via email to