summaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c++
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2006-05-02 20:03:38 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2006-05-02 20:03:38 +0000
commitf49d7bb59a7a1e21e1de1a78d832b4ea4b218b3d (patch)
treeeb02e1dd8220b3599be8ae1486c225f960b5ccf3 /libgomp/testsuite/libgomp.c++
parentd067645d609b3617e0943295c1addea34d8fc223 (diff)
downloadgcc-f49d7bb59a7a1e21e1de1a78d832b4ea4b218b3d.tar.gz
PR c++/26943
* omp-low.c (maybe_lookup_decl_in_outer_ctx): New function. (build_outer_var_ref): Use maybe_lookup_decl_in_outer_ctx to find if var will be a global variable even in the nested context. (omp_copy_decl): Only check for global variable at the end, it might be overridden in outer contexts. (scan_sharing_clauses): For global variables don't create a field. (lower_rec_input_clauses): Do nothing for global shared variables. Emit a barrier at the end of ILIST if there were any decls in both firstprivate and lastprivate clauses. (lower_send_clauses): Do nothing for global variables except for COPYIN. * testsuite/libgomp.c/pr26943-1.c: New test. * testsuite/libgomp.c/pr26943-2.c: New test. * testsuite/libgomp.c/pr26943-3.c: New test. * testsuite/libgomp.c/pr26943-4.c: New test. * testsuite/libgomp.c++/pr27337.C: Remove barrier. * testsuite/libgomp.c++/pr26943.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@113483 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgomp/testsuite/libgomp.c++')
-rw-r--r--libgomp/testsuite/libgomp.c++/pr26943.C62
-rw-r--r--libgomp/testsuite/libgomp.c++/pr27337.C6
2 files changed, 63 insertions, 5 deletions
diff --git a/libgomp/testsuite/libgomp.c++/pr26943.C b/libgomp/testsuite/libgomp.c++/pr26943.C
new file mode 100644
index 00000000000..07b7b5dbf74
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/pr26943.C
@@ -0,0 +1,62 @@
+// PR c++/26943
+// { dg-do run }
+
+#include <assert.h>
+#include <unistd.h>
+
+struct S
+{
+ public:
+ int x;
+ S () : x(-1) { }
+ S (const S &);
+ S& operator= (const S &);
+ void test ();
+};
+
+static volatile int hold;
+
+S::S (const S &s)
+{
+ #pragma omp master
+ sleep (1);
+
+ assert (s.x == -1);
+ x = 0;
+}
+
+S&
+S::operator= (const S& s)
+{
+ assert (s.x == 1);
+ x = 2;
+ return *this;
+}
+
+void
+S::test ()
+{
+ assert (x == 0);
+ x = 1;
+}
+
+static S x;
+
+void
+foo ()
+{
+ #pragma omp sections firstprivate(x) lastprivate(x)
+ {
+ x.test();
+ }
+}
+
+int
+main ()
+{
+ #pragma omp parallel num_threads(2)
+ foo();
+
+ assert (x.x == 2);
+ return 0;
+}
diff --git a/libgomp/testsuite/libgomp.c++/pr27337.C b/libgomp/testsuite/libgomp.c++/pr27337.C
index c12154e02b6..6db2465ec3a 100644
--- a/libgomp/testsuite/libgomp.c++/pr27337.C
+++ b/libgomp/testsuite/libgomp.c++/pr27337.C
@@ -48,11 +48,7 @@ foo ()
#pragma omp parallel for firstprivate (ret) lastprivate (ret) \
schedule (static, 1) num_threads (4)
for (i = 0; i < 4; i++)
- {
- ret.i += omp_get_thread_num ();
- // FIXME: The following barrier should be unnecessary.
-#pragma omp barrier
- }
+ ret.i += omp_get_thread_num ();
return ret;
}