public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-7880] ada: Fix visibility error with DIC or Type_Invariant aspect on generic type
@ 2023-09-27 8:26 Eric Botcazou
0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2023-09-27 8:26 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:fc6774344c98306a14138892e63587575d9e5ec3
commit r13-7880-gfc6774344c98306a14138892e63587575d9e5ec3
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 91e3587d719..177dce5d7f4 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-09-27 8:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-27 8:26 [gcc r13-7880] ada: Fix visibility error with DIC or Type_Invariant aspect on generic type Eric Botcazou
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).