[gcc r12-3728] [Ada] Refine patch for spurious link error involving discriminated types
Pierre-Marie de Rodat
pmderodat@gcc.gnu.org
Tue Sep 21 15:25:53 GMT 2021
https://gcc.gnu.org/g:c36332031cff305ceb0d1924ee4b2cedbd85023a
commit r12-3728-gc36332031cff305ceb0d1924ee4b2cedbd85023a
Author: Ed Schonberg <schonberg@adacore.com>
Date: Wed Jun 30 18:11:11 2021 -0400
[Ada] Refine patch for spurious link error involving discriminated types
gcc/ada/
* sem_ch3.adb (Process_Discriminant_Expressions): If the
constraint is for a Component_Definition that appears in a
Component_Declaration, the entity to be used to create the
potentially global symbol is the Defining_Identifier of the
Component_Declaration.
Diff:
---
gcc/ada/sem_ch3.adb | 29 +++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index 6a938706968..b233c563a2d 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -10502,13 +10502,30 @@ package body Sem_Ch3 is
if Expander_Active
and then Comes_From_Source (Def)
and then not Is_Subprogram (Current_Scope)
- and then Nkind (Parent (Def)) in
- N_Object_Declaration | N_Component_Declaration
then
- Force_Evaluation (
- Discr_Expr (J),
- Related_Id => Defining_Identifier (Parent (Def)),
- Discr_Number => J);
+ declare
+ Id : Entity_Id := Empty;
+ begin
+ if Nkind (Parent (Def)) = N_Object_Declaration then
+ Id := Defining_Identifier (Parent (Def));
+
+ elsif Nkind (Parent (Def)) = N_Component_Definition
+ and then
+ Nkind (Parent (Parent (Def)))
+ = N_Component_Declaration
+ then
+ Id := Defining_Identifier (Parent (Parent (Def)));
+ end if;
+
+ if Present (Id) then
+ Force_Evaluation (
+ Discr_Expr (J),
+ Related_Id => Id,
+ Discr_Number => J);
+ else
+ Force_Evaluation (Discr_Expr (J));
+ end if;
+ end;
else
Force_Evaluation (Discr_Expr (J));
end if;
More information about the Gcc-cvs
mailing list