aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2019-12-13 16:57:46 +0100
committerPierre-Marie de Rodat <derodat@adacore.com>2020-06-02 04:58:07 -0400
commit663091bc782563d7d9adc8b09e58afbac3656d13 (patch)
treefce9dff3753c23c8e4ae06565c85c4826bdf51ac
parent25d744bb6cf7e3b9a91930caff9f88814f2c36ca (diff)
downloadgcc-663091bc782563d7d9adc8b09e58afbac3656d13.zip
gcc-663091bc782563d7d9adc8b09e58afbac3656d13.tar.gz
gcc-663091bc782563d7d9adc8b09e58afbac3656d13.tar.bz2
[Ada] Fix small oversight in latest change for Replace_Discriminants
2020-06-02 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * sem_ch3.adb (Replace_Discriminants): Preserve the Etype of the Name of N_Variant_Part nodes when rewriting it.
-rw-r--r--gcc/ada/sem_ch3.adb13
1 files changed, 12 insertions, 1 deletions
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index e792072..3fa2dd8 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -22334,7 +22334,18 @@ package body Sem_Ch3 is
if Original_Record_Component (Comp) = Entity (Name (N))
or else Chars (Comp) = Chars (Name (N))
then
- Set_Name (N, New_Occurrence_Of (Comp, Sloc (N)));
+ -- Make sure to preserve the type coming from the parent on
+ -- the Name, even if the subtype of the discriminant can be
+ -- constrained, so that discrete choices inherited from the
+ -- parent in the variant part are not flagged as violating
+ -- the constraints of the subtype.
+
+ declare
+ Typ : constant Entity_Id := Etype (Name (N));
+ begin
+ Rewrite (Name (N), New_Occurrence_Of (Comp, Sloc (N)));
+ Set_Etype (Name (N), Typ);
+ end;
exit;
end if;