[Ada] Avoid building malformed component constraints
authorSteve Baird <baird@adacore.com>
Fri, 3 Dec 2021 01:04:15 +0000 (17:04 -0800)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 6 Jan 2022 17:11:36 +0000 (17:11 +0000)
commitc60f23e13ecbc5a5b07adb7557f1da094246cb2a
tree10d6e8ce5a0d148f989fb583ec246a3a7d7956ae
parent41a7b9484a39657deab7cac7092c2bf634a39365
[Ada] Avoid building malformed component constraints

gcc/ada/

* sem_util.adb (Build_Actual_Subtype_Of_Component): Define a new
local function, Build_Discriminant_Reference, and call it in
each of the three cases where Make_Selected_Component was
previously being called to construct a discriminant reference (2
in Build_Actual_Array_Constraint and 1 in
Build_Actual_Record_Constraint). Instead of unconditionally
using the passed-in object name as the prefix for the new
selected component node, this new function checks to see if
perhaps a prefix of that name should be used instead.
gcc/ada/sem_util.adb