summaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c/vla-1.c
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /libgomp/testsuite/libgomp.c/vla-1.c
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'libgomp/testsuite/libgomp.c/vla-1.c')
-rw-r--r--libgomp/testsuite/libgomp.c/vla-1.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.c/vla-1.c b/libgomp/testsuite/libgomp.c/vla-1.c
new file mode 100644
index 000000000..bdacdbbe8
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/vla-1.c
@@ -0,0 +1,60 @@
+/* { dg-do run } */
+
+#include <omp.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+main (int argc, char **argv[])
+{
+ int n = argc < 5 ? 12 : 31, i, m, l;
+ char a[n + 3];
+ unsigned short b[n / 2 - 1];
+ int c[n * 2 + 1];
+
+ for (i = 0; i < n + 3; i++)
+ a[i] = i;
+ for (i = 0; i < n / 2 - 1; i++)
+ b[i] = (i << 8) | i;
+ for (i = 0; i < n * 2 + 1; i++)
+ c[i] = (i << 24) | i;
+ l = 0;
+ m = n;
+#pragma omp parallel default (shared) num_threads (4) \
+ firstprivate (a, m) private (b, i) reduction (+:l)
+ {
+ for (i = 0; i < m + 3; i++)
+ if (a[i] != i)
+ l++;
+ for (i = 0; i < m * 2 + 1; i++)
+ if (c[i] != ((i << 24) | i))
+ l++;
+#pragma omp barrier
+ memset (a, omp_get_thread_num (), m + 3);
+ for (i = 0; i < m / 2 - 1; i++)
+ b[i] = a[0] + 7;
+#pragma omp master
+ {
+ for (i = 0; i < m * 2 + 1; i++)
+ c[i] = a[0] + 16;
+ }
+#pragma omp barrier
+ if (a[0] != omp_get_thread_num ())
+ l++;
+ for (i = 1; i < m + 3; i++)
+ if (a[i] != a[0])
+ l++;
+ for (i = 0; i < m / 2 - 1; i++)
+ if (b[i] != a[0] + 7)
+ l++;
+ for (i = 0; i < m * 2 + 1; i++)
+ if (c[i] != 16)
+ l++;
+ }
+ if (l)
+ abort ();
+ for (i = 0; i < n * 2 + 1; i++)
+ if (c[i] != 16)
+ l++;
+ return 0;
+}