diff options
author | Olivier Hainque <hainque@adacore.com> | 2018-05-23 10:23:09 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2018-05-23 10:23:09 +0000 |
commit | b682fcf0d9c3c221c4adfdd0b077504c6ac0a8fc (patch) | |
tree | cf83ccb7dcb04c4941be53b51cf9c020640b608c /gcc/ada/libgnat | |
parent | ac450fb2ab71dfd5bc57ea60bc00cc749d7485af (diff) | |
download | gcc-b682fcf0d9c3c221c4adfdd0b077504c6ac0a8fc.zip gcc-b682fcf0d9c3c221c4adfdd0b077504c6ac0a8fc.tar.gz gcc-b682fcf0d9c3c221c4adfdd0b077504c6ac0a8fc.tar.bz2 |
[Ada] Add a Is_Foreign_Exception predicate to GNAT.Exception_Actions
Useful to check if an occurrence caught by a "when others" choice originates
from a foreign language, e.g. C++.
2018-05-23 Olivier Hainque <hainque@adacore.com>
gcc/ada/
* libgnat/g-excact.ads (Is_Foreign_Exception): New predicate.
* libgnat/g-excact.adb: Implement.
From-SVN: r260588
Diffstat (limited to 'gcc/ada/libgnat')
-rw-r--r-- | gcc/ada/libgnat/g-excact.adb | 13 | ||||
-rw-r--r-- | gcc/ada/libgnat/g-excact.ads | 10 |
2 files changed, 21 insertions, 2 deletions
diff --git a/gcc/ada/libgnat/g-excact.adb b/gcc/ada/libgnat/g-excact.adb index 3fd738c..c70ecab 100644 --- a/gcc/ada/libgnat/g-excact.adb +++ b/gcc/ada/libgnat/g-excact.adb @@ -91,6 +91,19 @@ package body GNAT.Exception_Actions is procedure Core_Dump (Occurrence : Exception_Occurrence) is separate; + -------------------------- + -- Is_Foreign_Exception -- + -------------------------- + + function Is_Foreign_Exception (E : Exception_Occurrence) return Boolean is + Foreign_Exception : aliased Exception_Data; + pragma Import + (Ada, Foreign_Exception, "system__exceptions__foreign_exception"); + begin + return (To_Data (Exception_Identity (E)) + = Foreign_Exception'Unchecked_Access); + end Is_Foreign_Exception; + ---------------- -- Name_To_Id -- ---------------- diff --git a/gcc/ada/libgnat/g-excact.ads b/gcc/ada/libgnat/g-excact.ads index 3c21c154..dd75bb9 100644 --- a/gcc/ada/libgnat/g-excact.ads +++ b/gcc/ada/libgnat/g-excact.ads @@ -29,9 +29,11 @@ -- -- ------------------------------------------------------------------------------ --- This package provides support for callbacks on exceptions +-- This package provides support for callbacks on exceptions as well as +-- exception-related utility subprograms of possible interest together with +-- exception actions or more generally. --- These callbacks are called immediately when either a specific exception, +-- The callbacks are called immediately when either a specific exception, -- or any exception, is raised, before any other actions taken by raise, in -- particular before any unwinding of the stack occurs. @@ -85,6 +87,10 @@ package GNAT.Exception_Actions is -- Note: All non-predefined exceptions will return Null_Id for programs -- compiled with pragma Restriction (No_Exception_Registration) + function Is_Foreign_Exception (E : Exception_Occurrence) return Boolean; + -- Tell whether the exception occurrence E represents a foreign exception, + -- such as one raised in C++ and caught by a when others choice in Ada. + function Registered_Exceptions_Count return Natural; -- Return the number of exceptions that have been registered so far. -- Exceptions declared locally will not appear in this list until their |