From c7dd10e8af0e71a901af1f0b06d2216d5e31d586 Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Sat, 31 Oct 2020 00:01:43 +0100 Subject: [PATCH] [Ada] Fix expansion of attribute Priority gcc/ada/ * exp_attr.adb (Expand_N_Attribute_Reference): Fix detection of the enclosing protected type and of the enclosing protected subprogram. * exp_ch5.adb (Expand_N_Assignment_Statement): Likewise. --- gcc/ada/exp_attr.adb | 10 ++++++---- gcc/ada/exp_ch5.adb | 9 ++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb index ad7545353e37..c3e7fd214eef 100644 --- a/gcc/ada/exp_attr.adb +++ b/gcc/ada/exp_attr.adb @@ -5675,10 +5675,10 @@ package body Exp_Attr is RT_Subprg_Name : Node_Id; begin - -- Look for the enclosing concurrent type + -- Look for the enclosing protected type Conctyp := Current_Scope; - while not Is_Concurrent_Type (Conctyp) loop + while not Is_Protected_Type (Conctyp) loop Conctyp := Scope (Conctyp); end loop; @@ -5687,13 +5687,15 @@ package body Exp_Attr is -- Generate the actual of the call Subprg := Current_Scope; - while not Present (Protected_Body_Subprogram (Subprg)) loop + while not (Is_Subprogram_Or_Entry (Subprg) + and then Present (Protected_Body_Subprogram (Subprg))) + loop Subprg := Scope (Subprg); end loop; -- Use of 'Priority inside protected entries and barriers (in both -- cases the type of the first formal of their expanded subprogram - -- is Address) + -- is Address). if Etype (First_Entity (Protected_Body_Subprogram (Subprg))) = RTE (RE_Address) diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb index 9a2a1101de9c..382302cfd654 100644 --- a/gcc/ada/exp_ch5.adb +++ b/gcc/ada/exp_ch5.adb @@ -2416,10 +2416,10 @@ package body Exp_Ch5 is if Is_Expanded_Priority_Attribute (Ent) then - -- Look for the enclosing concurrent type + -- Look for the enclosing protected type Conctyp := Current_Scope; - while not Is_Concurrent_Type (Conctyp) loop + while not Is_Protected_Type (Conctyp) loop Conctyp := Scope (Conctyp); end loop; @@ -2428,7 +2428,10 @@ package body Exp_Ch5 is -- Generate the first actual of the call Subprg := Current_Scope; - while not Present (Protected_Body_Subprogram (Subprg)) loop + while + not (Is_Subprogram_Or_Entry (Subprg) + and then Present (Protected_Body_Subprogram (Subprg))) + loop Subprg := Scope (Subprg); end loop; -- 2.47.2