The problem at hand can be seen in this simple testcase:

int array[999];
void foo()
{
  _Cilk_for (int i=0; i < 999; ++i)
    array[:] = 0;
}

The issue here is that the _Cilk_for degrades into an OMP PARALLEL, and we fail to expand the array extension in the body of the OMP PARALLEL.

This is probably an obvious patch, but just in case... OK for trunk?

Aldy
commit d92a180d74fc6b20f140928eadccc406fba25edc
Author: Aldy Hernandez <al...@redhat.com>
Date:   Mon Jan 16 11:28:35 2017 -0500

            PR c++/70565
            * cp/cp-array-notation.c (expand_array_notation_exprs): Handle
            OMP_PARALLEL.

diff --git a/gcc/cp/cp-array-notation.c b/gcc/cp/cp-array-notation.c
index a0c54fd..36d6624 100644
--- a/gcc/cp/cp-array-notation.c
+++ b/gcc/cp/cp-array-notation.c
@@ -1198,6 +1198,10 @@ expand_array_notation_exprs (tree t)
       }
 
     case OMP_PARALLEL:
+      OMP_PARALLEL_BODY (t)
+       = expand_array_notation_exprs (OMP_PARALLEL_BODY (t));
+      return t;
+
     case OMP_TASK:
     case OMP_FOR:
     case OMP_SINGLE:
diff --git a/gcc/testsuite/g++.dg/cilk-plus/pr70565.C 
b/gcc/testsuite/g++.dg/cilk-plus/pr70565.C
new file mode 100644
index 0000000..781ce2c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cilk-plus/pr70565.C
@@ -0,0 +1,9 @@
+// { dg-do compile } */
+// { dg-options "-fcilkplus" }
+
+int array[999];
+void foo()
+{
+  _Cilk_for (int i=0; i < 999; ++i)
+    array[:] = 0;
+}

Reply via email to