This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Representing EH in GENERIC


In order to simplify C++, we need to decide how to represent the various EH
constructs in GENERIC/GIMPLE.  Currently, the only EH concept represented
in GENERIC is TRY_CATCH_EXPR, which corresponds to ERT_CLEANUP in the
backend EH code.  We have no representation for catch handlers (ERT_CATCH),
exception specifications (ERT_ALLOWED_EXCEPTIONS), or ERT_MUST_NOT_THROW.

The question is, which of these do we want to be able to represent directly
in GENERIC/GIMPLE?  If we simplify, the backend needs to re-derive which of
the above region types we actually want to encode.

The last is easy to simplify; a TRY_CATCH_EXPR with a handler which just
calls terminate will do the trick.

Exception specifications can be modeled in terms of try/catch:

  void f () throw (int)
  { ... }

becomes

  void f ()
  {
    try
      {
        ...
      }
    catch (int) { throw; }
    catch (...) { std::unexpected (); }
  }

though this starts to get complex, and the expanders will need to
deconstruct all of this again in order to call the right library routines.
Trying to simplify catches still further doesn't seem to make any sense; I
definitely think they should be represented directly, perhaps using a
sequence of CATCH_EXPRs.

It probably makes sense to always represent an EH region with a
TRY_CATCH_EXPR, and distinguish between the different varieties based on
the handler operand.

Thoughts?

Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]