]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Enforce checks on access to interface type conversions
authorJavier Miranda <miranda@adacore.com>
Thu, 2 Oct 2025 06:41:32 +0000 (06:41 +0000)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 18 Nov 2025 15:05:10 +0000 (16:05 +0100)
commitfb97610cfdd26f08915fe083d3ab566c151ba320
tree9004a99577e5e6908186d39271bc3192a720895e
parent54afa29ebfaa0fec0de85b1976fa881343762653
ada: Enforce checks on access to interface type conversions

The patch enforces checks on access to interface type conversions
internally generated by the frontend to displace the pointer to
a tagged type object (pointer named "this" in the C++ terminology)
from a dispatch table to a another dispatch table.

gcc/ada/ChangeLog:

* exp_util.ads (Flag_Interface_Pointer_Displacement): New subprogram.
* exp_util.adb (Flag_Interface_Pointer_Displacement): Ditto.
* exp_attr.adb (Add_Implicit_Interface_Type_Conversion): Flag type
conversions internally added to displace the pointer to the object.
(Expand_N_Attribute_Reference): Ditto.
* exp_ch4.adb (Displace_Allocator_Pointer): Ditto.
* exp_ch6.adb (Expand_Simple_Function_Return): Ditto.
(Make_Build_In_Place_Call_In_Allocator): Ditto.
(Make_CPP_Constructor_Call_In_Allocator): Ditto.
* exp_disp.adb (Expand_Interface_Actuals): Ditto.
* exp_intr.adb (Expand_Dispatching_Constructor_Call): Ditto.
* sem_ch6.adb (Analyze_Function_Return): Ditto.
* sem_disp.adb (Propagate_Tag): Ditto.
* sem_res.adb (Resolve_Actuals): Ditto.
(Valid_Conversion): Rely on the new flag to handle the type conversion
as a conversion added to displace the pointer to the object. Factorize
code handling general and anonymous access types.
* sem_type.adb (Interface_Present_In_Ancestor): For concurrent types
add missing handling of class-wide types. Noticed working on this
issue.
* sinfo.ads (Is_Interface_Pointer_Displacement): Document this new flag.
* gen_il-fields.ads (Is_Interface_Pointer_Displacement): New flag.
* gen_il-gen-gen_nodes.adb (Is_Interface_Pointer_Displacement): New
flag on N_Type_Conversion nodes.
* gen_il-internals.adb (Image): Add Is_Interface_Pointer_Displacement
flag image.
15 files changed:
gcc/ada/exp_attr.adb
gcc/ada/exp_ch4.adb
gcc/ada/exp_ch6.adb
gcc/ada/exp_disp.adb
gcc/ada/exp_intr.adb
gcc/ada/exp_util.adb
gcc/ada/exp_util.ads
gcc/ada/gen_il-fields.ads
gcc/ada/gen_il-gen-gen_nodes.adb
gcc/ada/gen_il-internals.adb
gcc/ada/sem_ch6.adb
gcc/ada/sem_disp.adb
gcc/ada/sem_res.adb
gcc/ada/sem_type.adb
gcc/ada/sinfo.ads