]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/doc/gccint/gimple/exception-handling.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / doc / gccint / gimple / exception-handling.rst
CommitLineData
c63539ff
ML
1..
2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
5
6.. index:: GIMPLE Exception Handling
7
8.. _gimple-exception-handling:
9
10Exception Handling
11******************
12
13Other exception handling constructs are represented using
14``GIMPLE_TRY_CATCH``. ``GIMPLE_TRY_CATCH`` has two operands. The
15first operand is a sequence of statements to execute. If executing
16these statements does not throw an exception, then the second operand
17is ignored. Otherwise, if an exception is thrown, then the second
18operand of the ``GIMPLE_TRY_CATCH`` is checked. The second
19operand may have the following forms:
20
21* A sequence of statements to execute. When an exception occurs,
22 these statements are executed, and then the exception is rethrown.
23
24* A sequence of ``GIMPLE_CATCH`` statements. Each
25 ``GIMPLE_CATCH`` has a list of applicable exception types and
26 handler code. If the thrown exception matches one of the caught
27 types, the associated handler code is executed. If the handler
28 code falls off the bottom, execution continues after the original
29 ``GIMPLE_TRY_CATCH``.
30
31* A ``GIMPLE_EH_FILTER`` statement. This has a list of
32 permitted exception types, and code to handle a match failure. If the
33 thrown exception does not match one of the allowed types, the
34 associated match failure code is executed. If the thrown exception
35 does match, it continues unwinding the stack looking for the next
36 handler.
37
38Currently throwing an exception is not directly represented in
39GIMPLE, since it is implemented by calling a function. At some
40point in the future we will want to add some way to express that
41the call will throw an exception of a known type.
42
43Just before running the optimizers, the compiler lowers the
44high-level EH constructs above into a set of ``goto`` s, magic
45labels, and EH regions. Continuing to unwind at the end of a
3ed1b4ce 46cleanup is represented with a ``GIMPLE_RESX``.