[Ada] Improve checking for invalid index values when accessing array elements

Pierre-Marie de Rodat derodat@adacore.com
Mon Oct 4 08:47:27 GMT 2021


Two improvements to the previous change on this topic:

1) Add a guard to prevent a call to Number_Of_Dimensions that would pass
   in a non-array type. This is needed in error cases (see ACATS test
   B95094C).

2) Do not generate the new validity checks in the case where the
   index type in question has a specified Default_Initial_Value aspect
   (which rules out the possibility that an object is invalid because it
   is uninitialized).

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* exp_ch4.adb (Expand_N_Indexed_Component): The two improvements
	described above.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: text/x-diff
Size: 2410 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20211004/ddb44c10/attachment.bin>


More information about the Gcc-patches mailing list