]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Cleanup related to volatile objects in restricted contexts
authorPiotr Trojanek <trojanek@adacore.com>
Mon, 1 Mar 2021 15:36:08 +0000 (16:36 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 16 Jun 2021 08:43:02 +0000 (04:43 -0400)
gcc/ada/

* sem_res.adb (Is_Assignment_Or_Object_Expression): Whitespace
cleanup.
(Is_Attribute_Expression): Prevent AST climbing from going to
the root of the compilation unit.

gcc/ada/sem_res.adb

index e043085fbb971046dc1ed579db5af14ac2802428..69c3c13fec7e667a2da8928243c1944bd77cf28b 100644 (file)
@@ -7701,8 +7701,7 @@ package body Sem_Res is
          Expr    : Node_Id) return Boolean
       is
       begin
-         if Nkind (Context) in
-              N_Assignment_Statement | N_Object_Declaration
+         if Nkind (Context) in N_Assignment_Statement | N_Object_Declaration
            and then Expression (Context) = Expr
          then
             return True;
@@ -7744,6 +7743,11 @@ package body Sem_Res is
          while Present (N) loop
             if Nkind (N) = N_Attribute_Reference then
                return True;
+
+            --  Prevent the search from going too far
+
+            elsif Is_Body_Or_Package_Declaration (N) then
+               return False;
             end if;
 
             N := Parent (N);