@@ -7081,7 +7081,12 @@ oacc_default_clause (struct gimplify_omp_ctx *ctx, tree decl, unsigned flags)
case ORT_ACC_PARALLEL:
rkind = "parallel";
- if (is_private)
+ if (TREE_CODE (type) == REFERENCE_TYPE
+ && TREE_CODE (TREE_TYPE (type)) == POINTER_TYPE)
+ flags |= GOVD_MAP | GOVD_MAP_0LEN_ARRAY;
+ else if (!lang_GNU_Fortran () && TREE_CODE (type) == POINTER_TYPE)
+ flags |= GOVD_MAP | GOVD_MAP_0LEN_ARRAY;
+ else if (is_private)
flags |= GOVD_FIRSTPRIVATE;
else if (on_device || declared)
flags |= GOVD_MAP;
new file mode 100644
@@ -0,0 +1,42 @@
+/* Expect dynamic arrays to be mapped on the accelerator via
+ GOMP_MAP_0LEN_ARRAY. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+
+int
+main ()
+{
+ const int n = 1000;
+ int *a, *b, *c, *d, i;
+
+ d = (int *) 12345;
+ a = (int *) malloc (sizeof (int) * n);
+ b = (int *) malloc (sizeof (int) * n);
+ c = (int *) malloc (sizeof (int) * n);
+
+ for (i = 0; i < n; i++)
+ {
+ a[i] = -1;
+ b[i] = i+1;
+ c[i] = 2*(i+1);
+ }
+
+#pragma acc enter data create(a[0:n]) copyin(b[:n], c[:n])
+#pragma acc parallel loop
+ for (i = 0; i < n; ++i)
+ {
+ a[i] = b[i] + c[i] + *((int *)&d);
+ }
+#pragma acc exit data copyout(a[0:n]) delete(b[0:n], c[0:n])
+
+ for (i = 0; i < n; i++)
+ assert (a[i] == 3*(i+1) + 12345);
+
+ free (a);
+ free (b);
+ free (c);
+
+ return 0;
+}