public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-6361] [Ada] Fix a couple of issues with pragma Inspection_Point
@ 2022-01-07 16:28 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-01-07 16:28 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:13e04137665e2e7cab689c280eab7875e4318e0d

commit r12-6361-g13e04137665e2e7cab689c280eab7875e4318e0d
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Sat Dec 18 22:25:20 2021 +0100

    [Ada] Fix a couple of issues with pragma Inspection_Point
    
    gcc/ada/
    
            * exp_prag.adb (Expand_Pragma_Inspection_Point): Do a single pass
            over the arguments of the pragma.  Set the Address_Taken flag on
            them and use the Has_Delayed_Freeze flag to spot those which have
            their elaboration delayed.  Reuse the location variable Loc.

Diff:
---
 gcc/ada/exp_prag.adb | 49 ++++++++++++++++++++++++++-----------------------
 1 file changed, 26 insertions(+), 23 deletions(-)

diff --git a/gcc/ada/exp_prag.adb b/gcc/ada/exp_prag.adb
index f19eedfaad7..267657fed0f 100644
--- a/gcc/ada/exp_prag.adb
+++ b/gcc/ada/exp_prag.adb
@@ -2354,12 +2354,13 @@ package body Exp_Prag is
 
    procedure Expand_Pragma_Inspection_Point (N : Node_Id) is
       Loc : constant Source_Ptr := Sloc (N);
+
       A     : List_Id;
       Assoc : Node_Id;
-      S     : Entity_Id;
       E     : Entity_Id;
+      Rip   : Boolean;
+      S     : Entity_Id;
 
-      Remove_Inspection_Point : Boolean := False;
    begin
       if No (Pragma_Argument_Associations (N)) then
          A := New_List;
@@ -2389,45 +2390,47 @@ package body Exp_Prag is
          Set_Pragma_Argument_Associations (N, A);
       end if;
 
-      --  Expand the arguments of the pragma. Expanding an entity reference
-      --  is a noop, except in a protected operation, where a reference may
-      --  have to be transformed into a reference to the corresponding prival.
-      --  Are there other pragmas that may require this ???
+      --  Process the arguments of the pragma and expand them. Expanding an
+      --  entity reference is a noop, except in a protected operation, where
+      --  a reference may have to be transformed into a reference to the
+      --  corresponding prival. Are there other pragmas that require this ???
 
+      Rip := False;
       Assoc := First (Pragma_Argument_Associations (N));
       while Present (Assoc) loop
-         Expand (Expression (Assoc));
-         Next (Assoc);
-      end loop;
+         --  The back end may need to take the address of the object
 
-      --  If any of the references have a freeze node, it must appear before
-      --  pragma Inspection_Point, otherwise the entity won't be available when
-      --  Gigi processes Inspection_Point.
-      --  When this requirement isn't met, turn the pragma into a no-op.
+         Set_Address_Taken (Entity (Expression (Assoc)));
 
-      Assoc := First (Pragma_Argument_Associations (N));
-      while Present (Assoc) loop
+         Expand (Expression (Assoc));
+
+         --  If any of the objects have a freeze node, it must appear before
+         --  pragma Inspection_Point, otherwise the entity won't be elaborated
+         --  when Gigi processes the pragma.
 
-         if Present (Freeze_Node (Entity (Expression (Assoc)))) and then
-           not Is_Frozen (Entity (Expression (Assoc)))
+         if Has_Delayed_Freeze (Entity (Expression (Assoc)))
+           and then not Is_Frozen (Entity (Expression (Assoc)))
          then
-            Error_Msg_NE ("??inspection point references unfrozen object &",
-              Assoc,
-              Entity (Expression (Assoc)));
-            Remove_Inspection_Point := True;
+            Error_Msg_NE
+              ("??inspection point references unfrozen object &",
+               Assoc,
+               Entity (Expression (Assoc)));
+            Rip := True;
          end if;
 
          Next (Assoc);
       end loop;
 
-      if Remove_Inspection_Point then
+      --  When the above requirement isn't met, turn the pragma into a no-op
+
+      if Rip then
          Error_Msg_N ("\pragma will be ignored", N);
 
          --  We can't just remove the pragma from the tree as it might be
          --  iterated over by the caller. Turn it into a null statement
          --  instead.
 
-         Rewrite (N, Make_Null_Statement (Sloc (N)));
+         Rewrite (N, Make_Null_Statement (Loc));
       end if;
    end Expand_Pragma_Inspection_Point;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-01-07 16:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-07 16:28 [gcc r12-6361] [Ada] Fix a couple of issues with pragma Inspection_Point 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).