This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] GIMPLE_OMP_CRITICAL has substatements (PR c++/37436)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 3 Sep 2008 09:07:42 -0400
- Subject: [PATCH] GIMPLE_OMP_CRITICAL has substatements (PR c++/37436)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
GIMPLE_OMP_CRITICAL was unintentionally omitted from
gimple_has_substatements, eventhough it has substatements, which means
that remap_gimple_seq (e.g. for C++ ctors/dtors) kept their bodies
not remapped and shared between two or more functions, which lead
to all kinds of interesting errors.
Fixed thusly, regtested on x86_64-linux, committed to trunk.
2008-09-03 Jakub Jelinek <jakub@redhat.com>
PR c++/37436
* gimple.h (gimple_has_substatements): GIMPLE_OMP_CRITICAL has
substatements.
* tree-inline.c (remap_gimple_stmt): Handle GIMPLE_OMP_CRITICAL.
* g++.dg/gomp/pr37436.C: New test.
--- gcc/gimple.h.jj 2008-09-02 20:31:27.000000000 +0200
+++ gcc/gimple.h 2008-09-03 13:59:38.000000000 +0200
@@ -1052,6 +1052,7 @@ gimple_has_substatements (gimple g)
case GIMPLE_OMP_TASK:
case GIMPLE_OMP_SECTIONS:
case GIMPLE_OMP_SINGLE:
+ case GIMPLE_OMP_CRITICAL:
case GIMPLE_WITH_CLEANUP_EXPR:
return true;
--- gcc/tree-inline.c.jj 2008-09-01 21:07:12.000000000 +0200
+++ gcc/tree-inline.c 2008-09-03 14:12:27.000000000 +0200
@@ -1156,6 +1156,12 @@ remap_gimple_stmt (gimple stmt, copy_bod
(s1, gimple_omp_single_clauses (stmt));
break;
+ case GIMPLE_OMP_CRITICAL:
+ s1 = remap_gimple_seq (gimple_omp_body (stmt), id);
+ copy
+ = gimple_build_omp_critical (s1, gimple_omp_critical_name (stmt));
+ break;
+
default:
gcc_unreachable ();
}
--- gcc/testsuite/g++.dg/gomp/pr37436.C.jj 2008-09-03 14:19:33.000000000 +0200
+++ gcc/testsuite/g++.dg/gomp/pr37436.C 2008-09-03 14:19:05.000000000 +0200
@@ -0,0 +1,15 @@
+// PR c++/37436
+// { dg-do compile }
+// { dg-options "-fopenmp" }
+
+struct A
+{
+ A ();
+ int i;
+};
+
+A::A ()
+{
+#pragma omp critical
+ i++;
+}
Jakub