else if (lhs_attr.codimension)
{
lhs_tok = gfc_get_ultimate_alloc_ptr_comps_caf_token (lse, expr1);
- lhs_tok = build_fold_indirect_ref (lhs_tok);
+ if (!lhs_tok)
+ {
+ lhs_tok = gfc_get_tree_for_caf_expr (expr1);
+ lhs_tok = GFC_TYPE_ARRAY_CAF_TOKEN (TREE_TYPE (lhs_tok));
+ }
+ else
+ lhs_tok = build_fold_indirect_ref (lhs_tok);
tmp = build2_loc (input_location, MODIFY_EXPR, void_type_node,
lhs_tok, null_pointer_node);
gfc_prepend_expr_to_block (&lse->post, tmp);
--- /dev/null
+!{ dg-do run }
+
+! Check that PR101100 is fixed.
+
+! Contributed by G. Steinmetz <gscfq@t-online.de>
+
+program p
+ type t
+ procedure(), pointer, nopass :: f
+ end type
+
+ integer :: i = 0
+ type(t) :: x[*]
+
+ x%f => null()
+ if ( associated(x%f) ) stop 1
+
+ x%f => g
+ if (.not. associated(x%f) ) stop 2
+
+ call x%f()
+ if ( i /= 1 ) stop 3
+
+contains
+ subroutine g()
+ i = 1
+ end subroutine
+end
+