OSDN Git Service

PR target/35364
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 4 Apr 2008 17:48:45 +0000 (17:48 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 4 Apr 2008 17:48:45 +0000 (17:48 +0000)
* tree-cfg.c (remove_useless_stmts_1): Handle OMP_* containers.

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

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@133905 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/gomp/pr35364.C [new file with mode: 0644]
gcc/tree-cfg.c

index f52f12b..79fb773 100644 (file)
@@ -1,3 +1,8 @@
+2008-04-04  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/35364
+       * tree-cfg.c (remove_useless_stmts_1): Handle OMP_* containers.
+
 2008-04-04  H.J. Lu  <hongjiu.lu@intel.com>
 
        * config.gcc (extra_headers): Add wmmintrin.h for x86 and x86-64.
index 1ec1c2d..5a203d1 100644 (file)
@@ -1,3 +1,8 @@
+2008-04-04  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/35364
+       * g++.dg/gomp/pr35364.C: New test.
+
 2008-04-04  H.J. Lu  <hongjiu.lu@intel.com>
 
        * g++.dg/other/i386-2.C: Include <wmmintrin.h>.
diff --git a/gcc/testsuite/g++.dg/gomp/pr35364.C b/gcc/testsuite/g++.dg/gomp/pr35364.C
new file mode 100644 (file)
index 0000000..da60d5d
--- /dev/null
@@ -0,0 +1,50 @@
+// PR target/35364
+// { dg-do compile }
+// { dg-options "-O2 -fopenmp" }
+
+template <typename T>
+struct E
+{
+  E ();
+  ~E ();
+};
+
+template <typename T, typename U>
+struct C
+{
+  C (const U &y) : u (y) {}
+  ~C () {}
+  const U &u;
+};
+
+template <typename T, typename U = E<T> >
+struct B : public C<T, U>
+{
+  B (int x, const T &z = T (), const U &y = U ()) : C<T, U> (y) {}
+  ~B () {}
+};
+
+void
+foo ()
+{
+#pragma omp parallel
+  {
+    B<double> x (1);
+  }
+#pragma omp for
+  for (int i = 0; i < 10; i++)
+    {
+      B<int> x (i);
+    }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+      B<int> x (6);
+    }
+  }
+#pragma omp single
+  {
+    B<int> x (16);
+  }
+}
index cea11b8..7eea2e1 100644 (file)
@@ -1917,6 +1917,33 @@ remove_useless_stmts_1 (tree *tp, struct rus_data *data)
       data->last_goto = NULL;
       break;
 
+    case OMP_PARALLEL:
+      /* Make sure the outermost BIND_EXPR in OMP_BODY isn't removed
+        as useless.  */
+      remove_useless_stmts_1 (&BIND_EXPR_BODY (OMP_BODY (*tp)), data);
+      data->last_goto = NULL;
+      break;
+
+    case OMP_SECTIONS:
+    case OMP_SINGLE:
+    case OMP_SECTION:
+    case OMP_MASTER :
+    case OMP_ORDERED:
+    case OMP_CRITICAL:
+      remove_useless_stmts_1 (&OMP_BODY (*tp), data);
+      data->last_goto = NULL;
+      break;
+
+    case OMP_FOR:
+      remove_useless_stmts_1 (&OMP_FOR_BODY (*tp), data);
+      data->last_goto = NULL;
+      if (OMP_FOR_PRE_BODY (*tp))
+       {
+         remove_useless_stmts_1 (&OMP_FOR_PRE_BODY (*tp), data);
+         data->last_goto = NULL;
+       }
+      break;
+
     default:
       data->last_goto = NULL;
       break;