]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/29955 (ICE with -fopenmp -fexceptions)
authorJakub Jelinek <jakub@redhat.com>
Fri, 24 Nov 2006 21:28:38 +0000 (22:28 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 24 Nov 2006 21:28:38 +0000 (22:28 +0100)
PR c/29955
* c-tree.h (c_maybe_initialize_eh): New prototype.
* c-decl.c (finish_decl): Move EH initialization...
(c_maybe_initialize_eh): ... here.  New function.
* c-parser.c (c_parser_omp_construct): Call c_maybe_initialize_eh
if not #pragma omp atomic.

* gcc.dg/gomp/pr29955.c: New test.

From-SVN: r119168

gcc/ChangeLog
gcc/c-decl.c
gcc/c-parser.c
gcc/c-tree.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/gomp/pr29955.c [new file with mode: 0644]

index b92949e202e90fa30138d5173610f6bee749ca01..24ee5793d7a0dd15e85509dad8e124dd330bb900 100644 (file)
@@ -1,5 +1,12 @@
 2006-11-24  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c/29955
+       * c-tree.h (c_maybe_initialize_eh): New prototype.
+       * c-decl.c (finish_decl): Move EH initialization...
+       (c_maybe_initialize_eh): ... here.  New function.
+       * c-parser.c (c_parser_omp_construct): Call c_maybe_initialize_eh
+       if not #pragma omp atomic.
+
        PR c/29736
        * c-common.c (handle_vector_size_attribute): Disallow VECTOR_TYPE
        or UNION_TYPE inner types.
index 80f1a1a621f61da66373951f5b797b73d2b5b022..fa1c3406d95338b37d7a571644663b137c012f16 100644 (file)
@@ -3385,6 +3385,23 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs,
   return tem;
 }
 
+/* Initialize EH if not initialized yet and exceptions are enabled.  */
+
+void
+c_maybe_initialize_eh (void)
+{
+  if (!flag_exceptions || c_eh_initialized_p)
+    return;
+
+  c_eh_initialized_p = true;
+  eh_personality_libfunc
+    = init_one_libfunc (USING_SJLJ_EXCEPTIONS
+                       ? "__gcc_personality_sj0"
+                       : "__gcc_personality_v0");
+  default_init_unwind_resume_libfunc ();
+  using_eh_for_cleanups ();
+}
+
 /* Finish processing of a declaration;
    install its initial value.
    If the length of an array type is not known before,
@@ -3676,16 +3693,7 @@ finish_decl (tree decl, tree init, tree asmspec_tree)
          TREE_USED (cleanup_decl) = 1;
 
          /* Initialize EH, if we've been told to do so.  */
-         if (flag_exceptions && !c_eh_initialized_p)
-           {
-             c_eh_initialized_p = true;
-             eh_personality_libfunc
-               = init_one_libfunc (USING_SJLJ_EXCEPTIONS
-                                   ? "__gcc_personality_sj0"
-                                   : "__gcc_personality_v0");
-             default_init_unwind_resume_libfunc ();
-             using_eh_for_cleanups ();
-           }
+         c_maybe_initialize_eh ();
 
          push_cleanup (decl, cleanup, false);
        }
index 852025392833ceb813663d00f0978fd16a8b96c1..c6be63918f668ba9f82d42afd83056b1d3e4bbaf 100644 (file)
@@ -7755,6 +7755,12 @@ c_parser_omp_construct (c_parser *parser)
   p_kind = c_parser_peek_token (parser)->pragma_kind;
   c_parser_consume_pragma (parser);
 
+  /* For all constructs below except #pragma omp atomic
+     MUST_NOT_THROW catch handlers are needed when exceptions
+     are enabled.  */
+  if (p_kind != PRAGMA_OMP_ATOMIC)
+    c_maybe_initialize_eh ();
+
   switch (p_kind)
     {
     case PRAGMA_OMP_ATOMIC:
index 5785e1cb96f06161fca909e294321f53415f15fa..87af5cbae9ddc1530851da8c9d48de78de0cc7f1 100644 (file)
@@ -456,6 +456,7 @@ extern void declare_parm_level (void);
 extern void undeclared_variable (tree, location_t);
 extern tree declare_label (tree);
 extern tree define_label (location_t, tree);
+extern void c_maybe_initialize_eh (void);
 extern void finish_decl (tree, tree, tree);
 extern tree finish_enum (tree, tree, tree);
 extern void finish_function (void);
index 473307a7d3ef5de17ead103b4210756bc2635e48..937291468e7fd10b8b9913c59183d151e6c23af9 100644 (file)
@@ -1,5 +1,8 @@
 2006-11-24  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c/29955
+       * gcc.dg/gomp/pr29955.c: New test.
+
        PR c/29736
        * gcc.dg/pr29736.c: New test.
 
diff --git a/gcc/testsuite/gcc.dg/gomp/pr29955.c b/gcc/testsuite/gcc.dg/gomp/pr29955.c
new file mode 100644 (file)
index 0000000..e49c11c
--- /dev/null
@@ -0,0 +1,14 @@
+/* PR c/29955 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fopenmp -fexceptions" } */
+
+extern void bar (int);
+
+void
+foo (int n)
+{
+  int i;
+#pragma omp parallel for schedule(dynamic)
+  for (i = 0; i < n; i++)
+    bar (0);
+}