public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-4545] [Ada] Crash on object of protected type with defaulted access component
@ 2021-10-20 10:18 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-10-20 10:18 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:9267014b351edf5aa0d0951545ec405edec5e3f5
commit r12-4545-g9267014b351edf5aa0d0951545ec405edec5e3f5
Author: Justin Squirek <squirek@adacore.com>
Date: Tue Oct 12 14:04:16 2021 -0400
[Ada] Crash on object of protected type with defaulted access component
gcc/ada/
* exp_ch7.adb (Make_Final_Call): Detect expanded protected types
and use original protected type in order to calculate
appropriate finalization routine.
Diff:
---
gcc/ada/exp_ch7.adb | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb
index 59c9c446037..cd9ff214e25 100644
--- a/gcc/ada/exp_ch7.adb
+++ b/gcc/ada/exp_ch7.adb
@@ -8953,11 +8953,12 @@ package body Exp_Ch7 is
Typ : Entity_Id;
Skip_Self : Boolean := False) return Node_Id
is
- Loc : constant Source_Ptr := Sloc (Obj_Ref);
- Atyp : Entity_Id;
- Fin_Id : Entity_Id := Empty;
- Ref : Node_Id;
- Utyp : Entity_Id;
+ Loc : constant Source_Ptr := Sloc (Obj_Ref);
+ Atyp : Entity_Id;
+ Prot_Typ : Entity_Id := Empty;
+ Fin_Id : Entity_Id := Empty;
+ Ref : Node_Id;
+ Utyp : Entity_Id;
begin
Ref := Obj_Ref;
@@ -9035,6 +9036,19 @@ package body Exp_Ch7 is
Set_Assignment_OK (Ref);
end if;
+ -- Detect if Typ is a protected type or an expanded protected type and
+ -- store the relevant type within Prot_Typ for later processing.
+
+ if Is_Protected_Type (Typ) then
+ Prot_Typ := Typ;
+
+ elsif Ekind (Typ) = E_Record_Type
+ and then Present (Corresponding_Concurrent_Type (Typ))
+ and then Is_Protected_Type (Corresponding_Concurrent_Type (Typ))
+ then
+ Prot_Typ := Corresponding_Concurrent_Type (Typ);
+ end if;
+
-- The underlying type may not be present due to a missing full view. In
-- this case freezing did not take place and there is no [Deep_]Finalize
-- primitive to call.
@@ -9080,7 +9094,7 @@ package body Exp_Ch7 is
-- Protected types: these also require finalization even though they
-- are not marked controlled explicitly.
- elsif Is_Protected_Type (Typ) then
+ elsif Present (Prot_Typ) then
-- Protected objects do not need to be finalized on restricted
-- runtimes.
@@ -9090,7 +9104,7 @@ package body Exp_Ch7 is
-- ??? Only handle the simple case for now. Will not support a record
-- or array containing protected objects.
- elsif Is_Simple_Protected_Type (Typ) then
+ elsif Is_Simple_Protected_Type (Prot_Typ) then
Fin_Id := RTE (RE_Finalize_Protection);
else
raise Program_Error;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-10-20 10:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-20 10:18 [gcc r12-4545] [Ada] Crash on object of protected type with defaulted access component 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).