===================================================================
@@ -1252,6 +1252,12 @@ gfc_check_dependency (gfc_expr *expr1, g
gfc_constructor *c;
int n;
+ /* -fcoarray=lib can end up here with expr1->expr_type set to EXPR_FUNCTION
+ and a reference to _F.caf_get, so skip the assert. */
+ if (expr1->expr_type == EXPR_FUNCTION
+ && strcmp (expr1->value.function.name, "_F.caf_get") == 0)
+ return 0;
+
gcc_assert (expr1->expr_type == EXPR_VARIABLE);
switch (expr2->expr_type)
===================================================================
@@ -0,0 +1,6 @@
+! { dg-do compile }
+! { dg-options "-fcoarray=lib -O2" }
+program p
+ integer :: z(2)[*] = 1
+ z(:)[1] = z(:)[*] ! { dg-error "must be a scalar at" }
+end