aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2009-02-11 22:57:52 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2009-02-11 22:57:52 +0100
commit3ad6b2669b7a6d9cd1b12330fd7accd44fdd2154 (patch)
tree4a20f063b19d39a1b3b6f180cab2f0a734d92d9c /libgomp/testsuite/libgomp.c
parentb058b753550ca9588b3961e75f6d30399f9d2c67 (diff)
downloadgcc-3ad6b2669b7a6d9cd1b12330fd7accd44fdd2154.zip
gcc-3ad6b2669b7a6d9cd1b12330fd7accd44fdd2154.tar.gz
gcc-3ad6b2669b7a6d9cd1b12330fd7accd44fdd2154.tar.bz2
re PR middle-end/39154 (Miscompilation of VLAs in nested parallel regions)
PR middle-end/39154 * gimplify.c (omp_notice_variable): If adding GOVD_SEEN bit to variable length decl's flags, add it also to its pointer replacement variable. * testsuite/libgomp.c/pr39154.c: New test. From-SVN: r144111
Diffstat (limited to 'libgomp/testsuite/libgomp.c')
-rw-r--r--libgomp/testsuite/libgomp.c/pr39154.c105
1 files changed, 105 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.c/pr39154.c b/libgomp/testsuite/libgomp.c/pr39154.c
new file mode 100644
index 0000000..5a4c89e
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/pr39154.c
@@ -0,0 +1,105 @@
+/* PR middle-end/39154 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -std=gnu99" } */
+
+extern void abort (void);
+
+int n = 20;
+
+int
+main (void)
+{
+ int a[n], b[n][n];
+
+#pragma omp parallel for
+ for (int i = 0; i < n; i++)
+ {
+ a[i] = i + 1;
+#pragma omp parallel for
+ for (int j = 0; j < n; j++)
+ b[i][j] = a[i];
+ }
+
+ for (int i = 0; i < n; i++)
+ {
+ for (int j = 0; j < n; j++)
+ if (b[i][j] != i + 1)
+ abort ();
+ if (a[i] != i + 1)
+ abort ();
+ }
+
+#pragma omp parallel for shared (n, a, b)
+ for (int i = 0; i < n; i++)
+ {
+ a[i] = i + 3;
+#pragma omp parallel for
+ for (int j = 0; j < n; j++)
+ b[i][j] = a[i];
+ }
+
+ for (int i = 0; i < n; i++)
+ {
+ for (int j = 0; j < n; j++)
+ if (b[i][j] != i + 3)
+ abort ();
+ if (a[i] != i + 3)
+ abort ();
+ }
+
+#pragma omp parallel for
+ for (int i = 0; i < n; i++)
+ {
+ a[i] = i + 5;
+#pragma omp parallel for shared (n, a, b)
+ for (int j = 0; j < n; j++)
+ b[i][j] = a[i];
+ }
+
+ for (int i = 0; i < n; i++)
+ {
+ for (int j = 0; j < n; j++)
+ if (b[i][j] != i + 5)
+ abort ();
+ if (a[i] != i + 5)
+ abort ();
+ }
+
+#pragma omp parallel for shared (n, a, b)
+ for (int i = 0; i < n; i++)
+ {
+ a[i] = i + 7;
+#pragma omp parallel for shared (n, a, b)
+ for (int j = 0; j < n; j++)
+ b[i][j] = a[i];
+ }
+
+ for (int i = 0; i < n; i++)
+ {
+ for (int j = 0; j < n; j++)
+ if (b[i][j] != i + 7)
+ abort ();
+ if (a[i] != i + 7)
+ abort ();
+ }
+
+#pragma omp parallel for private (a, b)
+ for (int i = 0; i < n; i++)
+ {
+ a[i] = i + 1;
+#pragma omp parallel for
+ for (int j = 0; j < n; j++)
+ b[i][j] = a[i];
+ }
+
+#pragma omp parallel for private (a, b)
+ for (int i = 0; i < n; i++)
+ {
+ a[i] = i + 1;
+#pragma omp parallel for private (b)
+ for (int j = 0; j < n; j++)
+ b[i][j] = a[i];
+ }
+
+ return 0;
+}