]> git.ipfire.org Git - thirdparty/gcc.git/commit
[Ada] Improved checking for invalid index values when accessing array elements
authorSteve Baird <baird@adacore.com>
Thu, 12 Aug 2021 23:55:36 +0000 (16:55 -0700)
committerPierre-Marie de Rodat <derodat@adacore.com>
Fri, 1 Oct 2021 06:13:39 +0000 (06:13 +0000)
commite02c8dffe35f2763ec42a4ca5b2cf1af11f8e5d6
tree209c121d9f5ff39ec2a959de3bba42f8f63402dd
parentf5d4b3fbf62a4c49d5951fc7848127af32876b78
[Ada] Improved checking for invalid index values when accessing array elements

gcc/ada/

* checks.ads: Define a type Dimension_Set. Add an out-mode
parameter of this new type to Generate_Index_Checks so that
callers can know for which dimensions a check was generated. Add
an in-mode parameter of this new type to
Apply_Subscript_Validity_Checks so that callers can indicate
that no check is needed for certain dimensions.
* checks.adb (Generate_Index_Checks): Implement new
Checks_Generated parameter.
(Apply_Subscript_Validity_Checks): Implement new No_Check_Needed
parameter.
* exp_ch4.adb (Expand_N_Indexed_Component): Call
Apply_Subscript_Validity_Checks in more cases than before. This
includes declaring two new local functions,
(Is_Renamed_Variable_Name,
Type_Requires_Subscript_Validity_Checks_For_Reads): To help in
deciding whether to call Apply_Subscript_Validity_Checks.
Adjust to parameter profile changes in Generate_Index_Checks and
Apply_Subscript_Validity_Checks.
gcc/ada/checks.adb
gcc/ada/checks.ads
gcc/ada/exp_ch4.adb