another exception handling question.... (was Re: trying to glue M odula-3 onto egcs table based exception handl ing support)

Mike Stump
Thu Jun 1 19:44:00 GMT 2000

> From: Marc Fiuczynski <>
> To: "''" <>
> Date: Thu, 1 Jun 2000 15:32:36 -0700 

> I got regular try-except blocks to work from my Modula-3 front-end with
> the table-based exception handling support in gcc 2.95.2.

> What I need to do now is provide support for try-finally statements.  A
> try-finally block looks like this:
>   guarded statements
>   final statements

> And the "final statements" will always be executed, regardless if an
> exception was raised or not in the "guarded statements" above.

> I am trying to figure out what to use from except.c.  It seems that
> add_partial_protect() and end_protect_partials() are kinda what I want,
> which are used for "cleanups".   However, it seems that these cleanups
> are also only executed in an exceptional situation, which is not exactly
> what I want.  Further, I'd like the code that gets generated for the
> "final statements" to be immediately follow the guarded statements.  I
> don't really see the right stuff in except.c to handle this.

add_partial_protect isn't what you want.

expand_decl_cleanup(NULL_TREE, cleanup) is the usual tree based approach.

Be sure to set using_eh_for_cleanups_p, this must be set in all
languages, unless they don't want to fit into the gcc exception
handling scheme.  Unfortunately, someone saw fit to choose the wrong
default for this flag.  I suspect you'll be burned by it.

To use it, call it at the top of the TRY, and end the contour at the FINALLY.

More information about the Gcc mailing list