Pragma Propagate_Exceptions

Syntax:

pragma Propagate_Exceptions (subprogram_LOCAL_NAME);

This pragma indicates that the given entity, which is the name of an
imported foreign-language subprogram may receive an Ada exception,
and that the exception should be propagated. It is relevant only if
zero cost exception handling is in use, and is thus never needed if
the alternative longjmp / setjmp implementation of
exceptions is used (although it is harmless to use it in such cases).

The implementation of fast exceptions always properly propagates
exceptions through Ada code, as described in the Ada Reference Manual.
However, this manual is silent about the propagation of exceptions
through foreign code. For example, consider the
situation where P1 calls
P2, and P2 calls P3, where
P1 and P3 are in Ada, but P2 is in C.
P3 raises an Ada exception. The question is whether or not
it will be propagated through P2 and can be handled in
P1.

For the longjmp / setjmp implementation of exceptions,
the answer is always yes. For some targets on which zero cost exception
handling is implemented, the answer is also always yes. However, there
are some targets, notably in the current version all x86 architecture
targets, in which the answer is that such propagation does not
happen automatically. If such propagation is required on these
targets, it is mandatory to use Propagate_Exceptions to
name all foreign language routines through which Ada exceptions
may be propagated.