@@ -4271,7 +4271,7 @@ gfc_trans_omp_arrayshape_type (tree type, vec<tree> *dims)
{
gcc_assert (dims->length () > 0);
- for (int i = dims->length () - 1; i >= 0; i--)
+ for (unsigned i = 0; i < dims->length (); i++)
{
tree dim = fold_convert (sizetype, (*dims)[i]);
/* We need the index of the last element, not the array size. */
@@ -14290,7 +14290,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
dims++;
}
- int tdim = tdims.length () - 1;
+ unsigned tdim = 0;
vec<constructor_elt, va_gc> *vdim;
vec<constructor_elt, va_gc> *vindex;
@@ -14365,7 +14365,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
nc = nc2;
}
- if (tdim >= 0)
+ if (tdim < tdims.length ())
{
/* We have an array shape -- use that to find the
total size of the data on the target to look up
@@ -14403,7 +14403,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
"for array");
dim = index = len = stride = error_mark_node;
}
- tdim--;
+ tdim++;
c = nc;
}
new file mode 100644
@@ -0,0 +1,34 @@
+/* { dg-do run { target offload_device_nonshared_as } } */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <assert.h>
+
+typedef struct {
+ int *ptr;
+} S;
+
+int main(void)
+{
+ S q;
+ q.ptr = (int *) calloc (9 * 11, sizeof (int));
+
+#pragma omp target enter data map(to: q.ptr, q.ptr[0:9*11])
+
+#pragma omp target
+ for (int i = 0; i < 9*11; i++)
+ q.ptr[i] = i;
+
+#pragma omp target update from(([9][11]) q.ptr[3:3:2][1:4:3])
+
+ for (int j = 0; j < 9; j++)
+ for (int i = 0; i < 11; i++)
+ if (j >= 3 && j <= 7 && ((j - 3) % 2) == 0
+ && i >= 1 && i <= 10 && ((i - 1) % 3) == 0)
+ assert (q.ptr[j * 11 + i] == j * 11 + i);
+ else
+ assert (q.ptr[j * 11 + i] == 0);
+
+#pragma omp target exit data map(release: q.ptr, q.ptr[0:9*11])
+ return 0;
+}