Commit 5c386a95 by Jakub Jelinek Committed by Jakub Jelinek

re PR c/29955 (ICE with -fopenmp -fexceptions)

	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
parent 23856459
2006-11-24 Jakub Jelinek <jakub@redhat.com> 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 PR c/29736
* c-common.c (handle_vector_size_attribute): Disallow VECTOR_TYPE * c-common.c (handle_vector_size_attribute): Disallow VECTOR_TYPE
or UNION_TYPE inner types. or UNION_TYPE inner types.
......
...@@ -3385,6 +3385,23 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs, ...@@ -3385,6 +3385,23 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs,
return tem; 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; /* Finish processing of a declaration;
install its initial value. install its initial value.
If the length of an array type is not known before, If the length of an array type is not known before,
...@@ -3676,16 +3693,7 @@ finish_decl (tree decl, tree init, tree asmspec_tree) ...@@ -3676,16 +3693,7 @@ finish_decl (tree decl, tree init, tree asmspec_tree)
TREE_USED (cleanup_decl) = 1; TREE_USED (cleanup_decl) = 1;
/* Initialize EH, if we've been told to do so. */ /* Initialize EH, if we've been told to do so. */
if (flag_exceptions && !c_eh_initialized_p) c_maybe_initialize_eh ();
{
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 ();
}
push_cleanup (decl, cleanup, false); push_cleanup (decl, cleanup, false);
} }
......
...@@ -7755,6 +7755,12 @@ c_parser_omp_construct (c_parser *parser) ...@@ -7755,6 +7755,12 @@ c_parser_omp_construct (c_parser *parser)
p_kind = c_parser_peek_token (parser)->pragma_kind; p_kind = c_parser_peek_token (parser)->pragma_kind;
c_parser_consume_pragma (parser); 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) switch (p_kind)
{ {
case PRAGMA_OMP_ATOMIC: case PRAGMA_OMP_ATOMIC:
......
...@@ -456,6 +456,7 @@ extern void declare_parm_level (void); ...@@ -456,6 +456,7 @@ extern void declare_parm_level (void);
extern void undeclared_variable (tree, location_t); extern void undeclared_variable (tree, location_t);
extern tree declare_label (tree); extern tree declare_label (tree);
extern tree define_label (location_t, tree); extern tree define_label (location_t, tree);
extern void c_maybe_initialize_eh (void);
extern void finish_decl (tree, tree, tree); extern void finish_decl (tree, tree, tree);
extern tree finish_enum (tree, tree, tree); extern tree finish_enum (tree, tree, tree);
extern void finish_function (void); extern void finish_function (void);
......
2006-11-24 Jakub Jelinek <jakub@redhat.com> 2006-11-24 Jakub Jelinek <jakub@redhat.com>
PR c/29955
* gcc.dg/gomp/pr29955.c: New test.
PR c/29736 PR c/29736
* gcc.dg/pr29736.c: New test. * gcc.dg/pr29736.c: New test.
/* 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);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment