public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-1373] ada: Fix visibility error with DIC or Type_Invariant aspect on generic type
@ 2023-05-30  7:17 Marc Poulhi?s
  0 siblings, 0 replies; only message in thread
From: Marc Poulhi?s @ 2023-05-30  7:17 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:3590b8e7850cc77324c0116718d3587401142d1c

commit r14-1373-g3590b8e7850cc77324c0116718d3587401142d1c
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Tue Apr 11 12:15:22 2023 +0200

    ada: Fix visibility error with DIC or Type_Invariant aspect on generic type
    
    The compiler fails to capture global references during the analysis of the
    aspect on the generic type because it analyzes a copy of the expression.
    
    gcc/ada/
    
            * exp_util.adb (Build_DIC_Procedure_Body.Add_Own_DIC): When inside
            a generic unit, preanalyze the expression directly.
            (Build_Invariant_Procedure_Body.Add_Own_Invariants): Likewise.

Diff:
---
 gcc/ada/exp_util.adb | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index 2582524b1dd..4c4844594d2 100644
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -1853,7 +1853,15 @@ package body Exp_Util is
 
       begin
          pragma Assert (Present (DIC_Expr));
-         Expr := New_Copy_Tree (DIC_Expr);
+
+         --  We need to preanalyze the expression itself inside a generic to
+         --  be able to capture global references present in it.
+
+         if Inside_A_Generic then
+            Expr := DIC_Expr;
+         else
+            Expr := New_Copy_Tree (DIC_Expr);
+         end if;
 
          --  Perform the following substitution:
 
@@ -3111,7 +3119,14 @@ package body Exp_Util is
                   return;
                end if;
 
-               Expr := New_Copy_Tree (Prag_Expr);
+               --  We need to preanalyze the expression itself inside a generic
+               --  to be able to capture global references present in it.
+
+               if Inside_A_Generic then
+                  Expr := Prag_Expr;
+               else
+                  Expr := New_Copy_Tree (Prag_Expr);
+               end if;
 
                --  Substitute all references to type T with references to the
                --  _object formal parameter.

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

only message in thread, other threads:[~2023-05-30  7:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-30  7:17 [gcc r14-1373] ada: Fix visibility error with DIC or Type_Invariant aspect on generic type Marc Poulhi?s

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).