]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Reduce footprint of C++ exception interoperation support
authorAlexandre Oliva <oliva@adacore.com>
Tue, 10 Dec 2024 12:06:57 +0000 (09:06 -0300)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Mon, 6 Jan 2025 09:14:49 +0000 (10:14 +0100)
commit2d2b018dcc4f5a822257688fb393fe0094d92d6d
treed71bb12c10da1d8c359e9402b69d5d2f8a8b1ba3
parentf49b098e7d19ea60b450b01e4434a00e7e5ca90b
ada: Reduce footprint of C++ exception interoperation support

The initial C++ base-type exception interoperation support change
brought all of GNAT.CPP* along with raise-gcc, because of
[__gnat_]Convert_Caught_Object.  Move that private but pragma-exported
function to GNAT.CPP.Std.Type_Info, so that it can rely on the C++
virtual/dispatch calls that justified the introduction of the Ada
wrapper type, to avoid emulating virtual calls in C or bringing in a
dependency on the C++ compiler and runtime.

Drop the CharPtr package instantiation, that brought a huge amount of
unnecessary code, and use string and storage primitives instead, using
the strcmp builtin directly for the C string compares.

Move the conversion to Ada String in Name to the wrapper interface in
GNAT.CPP.Std, adjusting the private internal type to shave off a few
more bytes from the only unit that raise-gcc will still need.

Finally, disable heap finalization for Type_Info_Ptr, to avoid
dragging in all of the finalization code.  Thank to Eric Botcazou for
the suggestion.

gcc/ada/ChangeLog:

* libgnat/g-cppexc.adb (Convert_Caught_Object): Move...
* libgnat/g-cstyin.adb (Convert_Caught_Object):  ... here.
Use object call notation.
(strcmp): New.
(Char_Arr, CharPtr, Char_Pointer, To_chars_ptr): Drop.  Do not
import Interfaces.C.Pointers.
(To_Pointer): Convert from System.Address.
(Name_Starts_With_Asterisk): Rename local variable.
(Name_Past_Asterisk): Rewrite with System.Address and strcmp.
Import System.Storage_Elements.
(Equals): Use strcmp.
(Before): Fix logic error.  Use strcmp.
(Name): Move conversion to String...
* libgnat/g-cppstd.adb (Name): ... here.  Import
Interfaces.C.Strings.
* libgnat/g-cppstd.ads (Type_Info_Ptr): Disable heap
finalization.
* libgnat/g-cstyin.ads (Name): Change return type.
gcc/ada/libgnat/g-cppexc.adb
gcc/ada/libgnat/g-cppstd.adb
gcc/ada/libgnat/g-cppstd.ads
gcc/ada/libgnat/g-cstyin.adb
gcc/ada/libgnat/g-cstyin.ads