Hi!

This patch fixes missing CLEANUP_POINT_EXPR around OMP_ATOMIC,
which resulted in ICEs.  Bootstrapped/regtested on x86_64-linux and
i686-linux, committed to trunk and 4.8 branch.

2013-11-28  Jakub Jelinek  <ja...@redhat.com>

        PR c++/59297
        * semantics.c (finish_omp_atomic): Call finish_expr_stmt
        rather than add_stmt.

        * g++.dg/gomp/pr59297.C: New test.

--- gcc/cp/semantics.c.jj       2013-11-27 18:02:43.000000000 +0100
+++ gcc/cp/semantics.c  2013-11-28 17:37:13.563664150 +0100
@@ -6548,7 +6548,7 @@ finish_omp_atomic (enum tree_code code,
       stmt = build2 (OMP_ATOMIC, void_type_node, integer_zero_node, stmt);
       OMP_ATOMIC_SEQ_CST (stmt) = seq_cst;
     }
-  add_stmt (stmt);
+  finish_expr_stmt (stmt);
 }
 
 void
--- gcc/testsuite/g++.dg/gomp/pr59297.C.jj      2013-11-28 17:39:05.449075129 
+0100
+++ gcc/testsuite/g++.dg/gomp/pr59297.C 2013-11-28 17:38:51.000000000 +0100
@@ -0,0 +1,25 @@
+// PR c++/59297
+// { dg-do compile }
+// { dg-options "-fopenmp" }
+
+template <typename T>
+struct A
+{
+  ~A ();
+  const T &operator[] (int) const;
+};
+
+struct B
+{
+  int &operator () (A <int>);
+};
+
+void
+foo (B &x, int &z)
+{
+  A<A<int> > y;
+  #pragma omp atomic
+  x (y[0]) += 1;
+  #pragma omp atomic
+  z += x(y[1]);
+}

        Jakub

Reply via email to