aboutsummaryrefslogtreecommitdiff
path: root/libgomp
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2006-05-02 10:44:55 +0000
committerJakub Jelinek <jakub@redhat.com>2006-05-02 10:44:55 +0000
commitb991d74da76e9d57c0786013051eba6dc7401731 (patch)
treee7fe929b16a97446edb70447a1000494b145b0dd /libgomp
parentb428f4042d75c4445cc97f52a2562ae8f978b0a6 (diff)
PR middle-end/27337
* gimplify.c (gimplify_scan_omp_clauses): Handle INDIRECT_REF around RESULT_DECL for result passed by reference. (gimplify_expr): Call omp_notice_variable when RESULT_DECL is seen. * omp-low.c (use_pointer_for_field): Don't look at DECL_HAS_VALUE_EXPR_P for RESULT_DECLs. (scan_omp_1): Call remap_decl on RESULT_DECLs. (lower_rec_input_clauses): Don't allocate VLA memory for the second time or var for passing by reference for OMP_CLAUSE_LASTPRIVATE_FIRSTPRIVATE clauses. Allow creation of TREE_ADDRESSABLE variables when passing by reference. * omp-low.c (dump_omp_region): Fix output formatting. cp/ * cp-gimplify.c (cxx_omp_privatize_by_reference): New function. * cp-tree.h (cxx_omp_privatize_by_reference): New prototype. * cp-objcp-common.h (LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE): Define. testsuite/ * g++.dg/gomp/pr27337-1.C: New test. * g++.dg/gomp/pr27337-2.C: New test. libgomp/ * testsuite/libgomp.c++/pr27337.C: New test. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@113456 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgomp')
-rw-r--r--libgomp/ChangeLog5
-rw-r--r--libgomp/testsuite/libgomp.c++/pr27337.C91
2 files changed, 96 insertions, 0 deletions
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 657b7ea0425..754d0f91df6 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,3 +1,8 @@
+2006-05-02 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/27337
+ * testsuite/libgomp.c++/pr27337.C: New test.
+
2006-04-26 Jakub Jelinek <jakub@redhat.com>
PR c/26171
diff --git a/libgomp/testsuite/libgomp.c++/pr27337.C b/libgomp/testsuite/libgomp.c++/pr27337.C
new file mode 100644
index 00000000000..c12154e02b6
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/pr27337.C
@@ -0,0 +1,91 @@
+// PR middle-end/27337
+// { dg-do run }
+
+#include <omp.h>
+
+extern "C" void abort (void);
+
+struct S
+{
+ S ();
+ ~S ();
+ S (const S &);
+ int i;
+};
+
+int n[3];
+
+S::S () : i(18)
+{
+ if (omp_get_thread_num () != 0)
+#pragma omp atomic
+ n[0]++;
+}
+
+S::~S ()
+{
+ if (omp_get_thread_num () != 0)
+#pragma omp atomic
+ n[1]++;
+}
+
+S::S (const S &x)
+{
+ if (x.i != 18)
+ abort ();
+ i = 118;
+ if (omp_get_thread_num () != 0)
+#pragma omp atomic
+ n[2]++;
+}
+
+S
+foo ()
+{
+ int i;
+ S ret;
+
+#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
+ }
+
+ return ret;
+}
+
+S
+bar ()
+{
+ int i;
+ S ret;
+
+#pragma omp parallel for num_threads (4)
+ for (i = 0; i < 4; i++)
+#pragma omp atomic
+ ret.i += omp_get_thread_num () + 1;
+
+ return ret;
+}
+
+S x;
+
+int
+main (void)
+{
+ omp_set_dynamic (false);
+ x = foo ();
+ if (n[0] != 0 || n[1] != 3 || n[2] != 3)
+ abort ();
+ if (x.i != 118 + 3)
+ abort ();
+ x = bar ();
+ if (n[0] != 0 || n[1] != 3 || n[2] != 3)
+ abort ();
+ if (x.i != 18 + 0 + 1 + 2 + 3 + 4)
+ abort ();
+ return 0;
+}