]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Fix expansion of attribute Priority
authorPiotr Trojanek <trojanek@adacore.com>
Fri, 30 Oct 2020 23:01:43 +0000 (00:01 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 5 Sep 2022 07:21:00 +0000 (09:21 +0200)
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
gcc/ada/exp_ch5.adb

index ad7545353e37f32fe3f5684bb782f0ebbedf8c4f..c3e7fd214eef28ade566d281c330723d41b9e60c 100644 (file)
@@ -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)
index 9a2a1101de9cbefe48cc030a63ed040889a4c6d2..382302cfd65458a1a9ae2aedbc7deea881d5d04f 100644 (file)
@@ -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;