aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2024-12-12 23:08:30 +0100
committerMarc Poulhiès <dkm@gcc.gnu.org>2025-01-06 10:14:49 +0100
commit0d736433f9261fb9705f860a2e41cc407ecd972c (patch)
treebd9fcab966bf318c777fabb0bb0b593637cc4b6d /gcc
parent06bc21f49d9a11b2b53108c95d9c991e51f3a785 (diff)
downloadgcc-0d736433f9261fb9705f860a2e41cc407ecd972c.zip
gcc-0d736433f9261fb9705f860a2e41cc407ecd972c.tar.gz
gcc-0d736433f9261fb9705f860a2e41cc407ecd972c.tar.bz2
ada: Fix predicate involving array indexing rejected in generic package
The indexing is rejected with the message: error: reference to current instance of type does not denote a type when it is applied to a prefix which is the current instance of the type to which the predicate is applied. There is already a specific handling of component selection for this case present in Find_Selected_Component, so this adds an equivalent specific handling of indexing for this case to Analyze_Indexed_Component_Form. gcc/ada/ChangeLog: PR ada/117569 * sem_ch4.adb (Analyze_Indexed_Component_Form): Do not rewrite the node as a type conversion if it is the current instance of a type in a generic unit. * sem_ch8.adb (Find_Selected_Component): Restrict the special case of the current instance of a type to a generic unit.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/sem_ch4.adb10
-rw-r--r--gcc/ada/sem_ch8.adb9
2 files changed, 13 insertions, 6 deletions
diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
index 94e4342..7bd30d6 100644
--- a/gcc/ada/sem_ch4.adb
+++ b/gcc/ada/sem_ch4.adb
@@ -3064,10 +3064,14 @@ package body Sem_Ch4 is
if Is_Entity_Name (P) and then Present (Entity (P)) then
U_N := Entity (P);
- if Is_Type (U_N) then
-
- -- Reformat node as a type conversion
+ -- If the prefix is a type name, then reformat the node as a type
+ -- conversion, but not if it is the current instance of type name,
+ -- e.g. the expression of a type aspect, when it is analyzed within
+ -- a generic unit.
+ if Is_Type (U_N)
+ and then not (Inside_A_Generic and then Is_Current_Instance (P))
+ then
E := Remove_Head (Exprs);
if Present (First (Exprs)) then
diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb
index d038a2d..533b62a 100644
--- a/gcc/ada/sem_ch8.adb
+++ b/gcc/ada/sem_ch8.adb
@@ -8498,11 +8498,14 @@ package body Sem_Ch8 is
-- It is not an error if the prefix is the current instance of
-- type name, e.g. the expression of a type aspect, when it is
- -- analyzed within a generic unit. We still have to verify that a
- -- component of that name exists, and decorate the node
+ -- analyzed within a generic unit. We still have to verify that
+ -- a component of that name exists, and decorate the node
-- accordingly.
- elsif Is_Entity_Name (P) and then Is_Current_Instance (P) then
+ elsif Inside_A_Generic
+ and then Is_Entity_Name (P)
+ and then Is_Current_Instance (P)
+ then
declare
Comp : Entity_Id;