"are allowed on ORDERED directive at %L",
                                 &n->where);
                  }
-               gfc_ref *array_ref = NULL;
+               gfc_ref *lastref = NULL, *lastslice = NULL;
                bool resolved = false;
                if (n->expr)
                  {
-                   array_ref = n->expr->ref;
+                   lastref = n->expr->ref;
                    resolved = gfc_resolve_expr (n->expr);
 
                    /* Look through component refs to find last array
                       reference.  */
                    if (resolved)
                      {
+                       for (gfc_ref *ref = n->expr->ref; ref; ref = ref->next)
+                         if (ref->type == REF_COMPONENT
+                             || ref->type == REF_SUBSTRING
+                             || ref->type == REF_INQUIRY)
+                           lastref = ref;
+                         else if (ref->type == REF_ARRAY)
+                           {
+                             for (int i = 0; i < ref->u.ar.dimen; i++)
+                               if (ref->u.ar.dimen_type[i] == DIMEN_RANGE)
+                                 lastslice = ref;
+
+                             lastref = ref;
+                           }
+
                        /* The "!$acc cache" directive allows rectangular
                           subarrays to be specified, with some restrictions
                           on the form of bounds (not implemented).
                           array isn't contiguous.  An expression such as
                           arr(-n:n,-n:n) could be contiguous even if it looks
                           like it may not be.  */
-                       if (list != OMP_LIST_CACHE
+                       if (code->op != EXEC_OACC_UPDATE
+                           && list != OMP_LIST_CACHE
                            && list != OMP_LIST_DEPEND
                            && !gfc_is_simply_contiguous (n->expr, false, true)
-                           && gfc_is_not_contiguous (n->expr))
+                           && gfc_is_not_contiguous (n->expr)
+                           && !(lastslice
+                                && (lastslice->next
+                                    || lastslice->type != REF_ARRAY)))
                          gfc_error ("Array is not contiguous at %L",
                                     &n->where);
-
-                       while (array_ref
-                              && (array_ref->type == REF_COMPONENT
-                                  || (array_ref->type == REF_ARRAY
-                                      && array_ref->next
-                                      && (array_ref->next->type
-                                          == REF_COMPONENT))))
-                         array_ref = array_ref->next;
                      }
                  }
-               if (array_ref
+               if (lastref
                    || (n->expr
                        && (!resolved || n->expr->expr_type != EXPR_VARIABLE)))
                  {
-                   if (array_ref
-                       && (array_ref->type == REF_SUBSTRING
-                           || (array_ref->next
-                               && array_ref->next->type == REF_SUBSTRING)))
+                   if (!lastslice
+                       && lastref
+                       && lastref->type == REF_SUBSTRING)
                      gfc_error ("Unexpected substring reference in %s clause "
                                 "at %L", name, &n->where);
-                   else if (array_ref && array_ref->type == REF_INQUIRY)
+                   else if (!lastslice
+                            && lastref
+                            && lastref->type == REF_INQUIRY)
                      {
-                       gcc_assert (array_ref->u.i == INQUIRY_RE
-                                   || array_ref->u.i == INQUIRY_IM);
+                       gcc_assert (lastref->u.i == INQUIRY_RE
+                                   || lastref->u.i == INQUIRY_IM);
                        gfc_error ("Unexpected complex-parts designator "
                                   "reference in %s clause at %L",
                                   name, &n->where);
                      }
                    else if (!resolved
-                       || n->expr->expr_type != EXPR_VARIABLE
-                       || array_ref->next
-                       || array_ref->type != REF_ARRAY)
+                            || n->expr->expr_type != EXPR_VARIABLE
+                            || (lastslice
+                                && (lastslice->next
+                                    || lastslice->type != REF_ARRAY)))
                      gfc_error ("%qs in %s clause at %L is not a proper "
                                 "array section", n->sym->name, name,
                                 &n->where);
-                   else
+                   else if (lastslice)
                      {
                        int i;
-                       gfc_array_ref *ar = &array_ref->u.ar;
+                       gfc_array_ref *ar = &lastslice->u.ar;
                        for (i = 0; i < ar->dimen; i++)
-                         if (ar->stride[i])
+                         if (ar->stride[i] && code->op != EXEC_OACC_UPDATE)
                            {
                              gfc_error ("Stride should not be specified for "
                                         "array section in %s clause at %L",
 
 !$acc enter data copyin(z%re)    ! { dg-error "Unexpected complex-parts designator" }
 !$acc enter data copyin(z%im)    ! { dg-error "Unexpected complex-parts designator" }
 !$acc enter data copyin(zz%re)   ! { dg-error "not a proper array section" }
-                                 ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 }
 !$acc enter data copyin(zz%im)   ! { dg-error "not a proper array section" }
-                                 ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 }
 
 !$acc enter data copyin(x%z%re)  ! { dg-error "Unexpected complex-parts designator" }
 !$acc enter data copyin(x%z%im)  ! { dg-error "Unexpected complex-parts designator" }
 !$acc enter data copyin(x%zz%re) ! { dg-error "not a proper array section" }
-                                 ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 }
 !$acc enter data copyin(x%zz%im) ! { dg-error "not a proper array section" }
-                                 ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 }
 
 !$acc update self(z%re)         ! { dg-error "Unexpected complex-parts designator" }
 !$acc update self(z%im)         ! { dg-error "Unexpected complex-parts designator" }
 !$acc update self(zz%re)        ! { dg-error "not a proper array section" }
-                                ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 }
 !$acc update self(zz%im)        ! { dg-error "not a proper array section" }
-                                ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 }
 
 !$acc update self(x%z%re)       ! { dg-error "Unexpected complex-parts designator" }
 !$acc update self(x%z%im)       ! { dg-error "Unexpected complex-parts designator" }
 !$acc update self(x%zz%re)      ! { dg-error "is not a proper array section" }
-                                ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 }
 !$acc update self(x%zz%im)      ! { dg-error "is not a proper array section" }
-                                ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 }
 end
 
 !$omp target enter data map(to: z%re)    ! { dg-error "Unexpected complex-parts designator" }
 !$omp target enter data map(to: z%im)    ! { dg-error "Unexpected complex-parts designator" }
 !$omp target enter data map(to: zz%re)   ! { dg-error "not a proper array section" }
-                                         ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 }
 !$omp target enter data map(to: zz%im)   ! { dg-error "not a proper array section" }
-                                         ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 }
 
 !$omp target enter data map(to: x%z%re)  ! { dg-error "Unexpected complex-parts designator" }
 !$omp target enter data map(to: x%z%im)  ! { dg-error "Unexpected complex-parts designator" }
 !$omp target enter data map(to: x%zz%re) ! { dg-error "not a proper array section" }
-                                         ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 }
 !$omp target enter data map(to: x%zz%im) ! { dg-error "not a proper array section" }
-                                         ! { dg-error "Array is not contiguous" "" { target *-*-* } .-1 }
 
 end