* [Ada] Do not create useless itype in Constrain_Access
@ 2022-05-11 8:54 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-05-11 8:54 UTC (permalink / raw)
To: gcc-patches; +Cc: Etienne Servais
[-- Attachment #1: Type: text/plain, Size: 480 bytes --]
In the case of a constrained access definition for a record component we
are calling create_itype twice the former not being updated. This leads
to a malformed node that crashes -gnatG when predicates are activated.
Instead of creating a default Itype for Desig_Subtype, create it with
the correct scope in each case.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_ch3.adb (Constrain_Access): Call Desig_Subtype in each if
branch to avoid calling it twice.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 1205 bytes --]
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -13345,11 +13345,12 @@ package body Sem_Ch3 is
is
T : constant Entity_Id := Entity (Subtype_Mark (S));
Desig_Type : constant Entity_Id := Designated_Type (T);
- Desig_Subtype : Entity_Id := Create_Itype (E_Void, Related_Nod);
+ Desig_Subtype : Entity_Id;
Constraint_OK : Boolean := True;
begin
if Is_Array_Type (Desig_Type) then
+ Desig_Subtype := Create_Itype (E_Void, Related_Nod);
Constrain_Array (Desig_Subtype, S, Related_Nod, Def_Id, 'P');
elsif (Is_Record_Type (Desig_Type)
@@ -13445,12 +13446,14 @@ package body Sem_Ch3 is
end;
end if;
+ Desig_Subtype := Create_Itype (E_Void, Related_Nod);
Constrain_Discriminated_Type (Desig_Subtype, S, Related_Nod,
For_Access => True);
elsif Is_Concurrent_Type (Desig_Type)
and then not Is_Constrained (Desig_Type)
then
+ Desig_Subtype := Create_Itype (E_Void, Related_Nod);
Constrain_Concurrent (Desig_Subtype, S, Related_Nod, Desig_Type, ' ');
else
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-11 8:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-11 8:54 [Ada] Do not create useless itype in Constrain_Access Pierre-Marie de Rodat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).