From: Eric Botcazou <[email protected]>
The registration can be skipped altogether, because the name of the tag is
quite unlikely to conflict with a user-declared tag.
gcc/ada/ChangeLog:
* sem_ch12.adb (Build_Structural_Instantiation): Temporarily disable
registration of tagged types when analyzing the instantiation.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/sem_ch12.adb | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb
index 08ee37547fb..1ebda12cde2 100644
--- a/gcc/ada/sem_ch12.adb
+++ b/gcc/ada/sem_ch12.adb
@@ -7418,10 +7418,21 @@ package body Sem_Ch12 is
-- reasons pertaining to freezing (see the Freeze_Package_Instance and
-- Freeze_Subprogram_Instance procedures).
- Add_Local_Declaration (Inst, N, Scop => Empty);
- if Error_Posted (Inst) then
- return Empty;
- end if;
+ -- We also need to temporarily disable registration of tagged types,
+ -- lest there be multiple instantiations in the partition, since it
+ -- is performed even though the generic unit is preelaborated.
+
+ declare
+ S_Restrictions : constant Save_Cunit_Boolean_Restrictions :=
+ Cunit_Boolean_Restrictions_Save;
+ begin
+ Set_Restriction (No_Tagged_Type_Registration, N);
+ Add_Local_Declaration (Inst, N, Scop => Empty);
+ Cunit_Boolean_Restrictions_Restore (S_Restrictions);
+ if Error_Posted (Inst) then
+ return Empty;
+ end if;
+ end;
-- If the structural instance had already been created, this occurrence
-- has been turned into a renaming of it.
--
2.53.0