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.
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,
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);
}
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:
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);
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.
--- /dev/null
+/* 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);
+}