aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2023-04-11 12:15:22 +0200
committerEric Botcazou <ebotcazou@adacore.com>2023-09-27 10:16:27 +0200
commitfc6774344c98306a14138892e63587575d9e5ec3 (patch)
tree553bad09b9587071000f5d8854d51862219b3f29 /gcc
parentc9af18f8677998e407b9f2e7fd977122969735aa (diff)
downloadgcc-fc6774344c98306a14138892e63587575d9e5ec3.zip
gcc-fc6774344c98306a14138892e63587575d9e5ec3.tar.gz
gcc-fc6774344c98306a14138892e63587575d9e5ec3.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/exp_util.adb19
1 files changed, 17 insertions, 2 deletions
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index 91e3587..177dce5 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.