Fix uninitialized variable in Atree.Size_In_Slots
authorBob Duff <duff@adacore.com>
Wed, 12 May 2021 09:56:47 +0000 (11:56 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Wed, 12 May 2021 10:15:55 +0000 (12:15 +0200)
commitac18ded230f1559f271f8d66121b2f16805f0b27
treef4bd24814c747e04b2268d864479cdada523bfbb
parent3835aa0eb90292d652dd6b200f302f3cac7e643f
Fix uninitialized variable in Atree.Size_In_Slots

Size_In_Slots uses the Nkind to look up the size in a table indexed
by Nkind.  This patch fixes a couple of places where the Nkind is
wrong (uninitialized or zeroed out) so Size_In_Slots cannot be used.

gcc/ada/
PR ada/100564
* atree.adb (Change_Node): Do not call Zero_Slots on a Node_Id
when the Nkind has not yet been set; call the other Zero_Slots
that takes a range of slot offsets.  Call the new Mutate_Kind
that takes an Old_Size, for the same reason -- the size cannot
be computed without the Nkind.
(Mutate_Nkind): New function that allows specifying the Old_Size.
(Size_In_Slots): Assert that the Nkind has proper (nonzero) value.
* atree.ads: Minor reformatting.
gcc/ada/atree.adb
gcc/ada/atree.ads