aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2017-05-22 20:54:54 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2017-05-22 20:54:54 +0200
commit655e52652b2af93ae6508dfc2026c6903bf391de (patch)
treef78ceed96325d47d3bf86d478392268ca65be633 /libgomp/testsuite
parente9e2ef9f2f1e037e0f3bc4990947e242106e43b9 (diff)
downloadgcc-655e52652b2af93ae6508dfc2026c6903bf391de.zip
gcc-655e52652b2af93ae6508dfc2026c6903bf391de.tar.gz
gcc-655e52652b2af93ae6508dfc2026c6903bf391de.tar.bz2
re PR middle-end/80809 (Multi-free error for variable size array used within OpenMP task)
PR middle-end/80809 * omp-low.c (finish_taskreg_remap): New function. (finish_taskreg_scan): If unit size of ctx->record_type is non-constant, unshare the size expression and replace decls in it with possible outer var refs. * testsuite/libgomp.c/pr80809-2.c: New test. * testsuite/libgomp.c/pr80809-3.c: New test. From-SVN: r248346
Diffstat (limited to 'libgomp/testsuite')
-rw-r--r--libgomp/testsuite/libgomp.c/pr80809-2.c35
-rw-r--r--libgomp/testsuite/libgomp.c/pr80809-3.c42
2 files changed, 77 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.c/pr80809-2.c b/libgomp/testsuite/libgomp.c/pr80809-2.c
new file mode 100644
index 0000000..48af370
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/pr80809-2.c
@@ -0,0 +1,35 @@
+/* PR middle-end/80809 */
+/* { dg-do run } */
+
+__attribute__((noinline, noclone)) void
+foo (int x)
+{
+ int i, v[x], w[16];
+ for (i = 0; i < x; i++)
+ v[i] = i;
+ for (i = 0; i < 16; i++)
+ w[i] = 0;
+#pragma omp parallel
+#pragma omp single
+ for (i = 0; i < 16; i++)
+#pragma omp task firstprivate (v)
+ {
+ int j;
+ for (j = 0; j < x; j++)
+ v[j] += i;
+ for (j = 0; j < x; j++)
+ w[i] += v[j];
+ }
+ for (i = 0; i < 16; i++)
+ if (w[i] != (x - 1) * x / 2 + x * i)
+ __builtin_abort ();
+}
+
+int
+main ()
+{
+ foo (4);
+ foo (27);
+ foo (196);
+ return 0;
+}
diff --git a/libgomp/testsuite/libgomp.c/pr80809-3.c b/libgomp/testsuite/libgomp.c/pr80809-3.c
new file mode 100644
index 0000000..7e0d179
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/pr80809-3.c
@@ -0,0 +1,42 @@
+/* PR middle-end/80809 */
+/* { dg-do run } */
+
+__attribute__((noinline, noclone)) void
+foo (int x)
+{
+ int i, v[x], w[16];
+ for (i = 0; i < x; i++)
+ v[i] = i;
+ for (i = 0; i < 16; i++)
+ w[i] = 0;
+#pragma omp parallel
+#pragma omp single
+ {
+ int z[x];
+ for (i = 0; i < x; i++)
+ z[0] = 0;
+ for (i = 0; i < 16; i++)
+#pragma omp task firstprivate (z) firstprivate (v)
+ {
+ int j;
+ for (j = 0; j < x; j++)
+ z[j] = i;
+ for (j = 0; j < x; j++)
+ v[j] += z[j];
+ for (j = 0; j < x; j++)
+ w[i] += v[j];
+ }
+ }
+ for (i = 0; i < 16; i++)
+ if (w[i] != (x - 1) * x / 2 + x * i)
+ __builtin_abort ();
+}
+
+int
+main ()
+{
+ foo (4);
+ foo (27);
+ foo (196);
+ return 0;
+}