]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Fix usage of Table.Table in Sem_Ch12
authorRonan Desplanques <desplanques@adacore.com>
Thu, 25 Sep 2025 09:33:13 +0000 (11:33 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 28 Oct 2025 10:24:05 +0000 (11:24 +0100)
commit720aa07da3fa491d2453552820016345bcda4be3
treea2520f0a90b4b87ab55f406a05cccbd8d077e8a8
parent36dc851484949c2e5d4fbfe33b8b336699a46104
ada: Fix usage of Table.Table in Sem_Ch12

Before this patch, Sem_Ch12 jumped through questionable hoops in the way
it used its Generics_Renaming table that involved defensive calls to the
'Valid attribute. No known bug has been caused by this, but valgrind
reported incorrect memory operations because of it.

After analysis, the problem seems to be a mix 0-based and 1-based
indexing in the uses of Generic_Renamings and a convoluted interface for
the Set_Instance_Of procedure, leading to an unclear status for
Generic_Renamings.Table (0).

This patch fixes those problems and removes the accompanying defensive
code.

gcc/ada/ChangeLog:

* sem_ch12.adb (Build_Local_Package)
(Analyze_Package_Instantiation, Analyze_Subprogram_Instantiation):
Fix Set_Last calls.
(Set_Instance_Of): Use Table.Table.Append.
(Save_And_Reset): Remove useless call. Remove defensive code.
(Restore): Remove incorrect Set_Last call and adapt to
Set_Instance_Of change.
gcc/ada/sem_ch12.adb