summaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c++/pr30703.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++/pr30703.C
downloadcbb-gcc-4.6.4-upstream.tar.bz2
cbb-gcc-4.6.4-upstream.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++/pr30703.C')
-rw-r--r--libgomp/testsuite/libgomp.c++/pr30703.C73
1 files changed, 73 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.c++/pr30703.C b/libgomp/testsuite/libgomp.c++/pr30703.C
new file mode 100644
index 000000000..d48efd952
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/pr30703.C
@@ -0,0 +1,73 @@
+// PR c++/30703
+// { dg-do run }
+
+#include <omp.h>
+
+extern "C" void abort ();
+
+int ctor, cctor, dtor;
+
+struct A
+{
+ A();
+ A(const A &);
+ ~A();
+ int i;
+};
+
+A::A()
+{
+#pragma omp atomic
+ ctor++;
+}
+
+A::A(const A &r)
+{
+ i = r.i;
+#pragma omp atomic
+ cctor++;
+}
+
+A::~A()
+{
+#pragma omp atomic
+ dtor++;
+}
+
+void
+foo (A a, A b)
+{
+ int i, j = 0;
+#pragma omp parallel for firstprivate (a) lastprivate (a) private (b) schedule (static, 1) num_threads (5)
+ for (i = 0; i < 5; i++)
+ {
+ b.i = 5;
+ if (a.i != 6)
+ #pragma omp atomic
+ j += 1;
+ a.i = b.i + i + 6;
+ }
+
+ if (j || a.i != 15)
+ abort ();
+}
+
+void
+bar ()
+{
+ A a, b;
+ a.i = 6;
+ b.i = 7;
+ foo (a, b);
+}
+
+int
+main ()
+{
+ omp_set_dynamic (false);
+ if (ctor || cctor || dtor)
+ abort ();
+ bar ();
+ if (ctor + cctor != dtor)
+ abort ();
+}