aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@adacore.com>2020-04-07 11:05:59 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2020-06-16 09:07:15 -0400
commitd51bf619f723292fd1475deb58b7b14144495648 (patch)
tree379b3136c732eac2b97401a2e7789b4d3084adb8 /gcc
parent3c9a82fec0e08b24ee49c94c3cdfd6c426042f64 (diff)
downloadgcc-d51bf619f723292fd1475deb58b7b14144495648.zip
gcc-d51bf619f723292fd1475deb58b7b14144495648.tar.gz
gcc-d51bf619f723292fd1475deb58b7b14144495648.tar.bz2
[Ada] ACATS C452005/C452006 memberships use wrong equality operation
2020-06-16 Arnaud Charlet <charlet@adacore.com> gcc/ada/ * sem_aux.ads, sem_aux.adb (Is_Record_Or_Limited_Type): New function. * exp_ch4.adb, sem_ch4.adb (Analyze_Membership_Op, Expand_Set_Membership.Make_Cond): Choose between primitive and predefined equality for membership tests.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/exp_ch4.adb9
-rw-r--r--gcc/ada/sem_aux.adb9
-rw-r--r--gcc/ada/sem_aux.ads3
-rw-r--r--gcc/ada/sem_ch4.adb10
4 files changed, 25 insertions, 6 deletions
diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index f5ad90a..3d706bf 100644
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -12717,10 +12717,13 @@ package body Exp_Ch4 is
Left_Opnd => L,
Right_Opnd => R);
- -- We reset the Entity since we do not want to bypass the operator
- -- resolution.
+ if Is_Record_Or_Limited_Type (Etype (Alt)) then
- Set_Entity (Cond, Empty);
+ -- We reset the Entity in order to use the primitive equality
+ -- of the type, as per RM 4.5.2 (28.1/4).
+
+ Set_Entity (Cond, Empty);
+ end if;
end if;
return Cond;
diff --git a/gcc/ada/sem_aux.adb b/gcc/ada/sem_aux.adb
index 0cd538a..dbff7d8 100644
--- a/gcc/ada/sem_aux.adb
+++ b/gcc/ada/sem_aux.adb
@@ -1330,6 +1330,15 @@ package body Sem_Aux is
N_Protected_Definition);
end Is_Protected_Operation;
+ -------------------------------
+ -- Is_Record_Or_Limited_Type --
+ -------------------------------
+
+ function Is_Record_Or_Limited_Type (Typ : Entity_Id) return Boolean is
+ begin
+ return Is_Record_Type (Typ) or else Is_Limited_Type (Typ);
+ end Is_Record_Or_Limited_Type;
+
----------------------
-- Nearest_Ancestor --
----------------------
diff --git a/gcc/ada/sem_aux.ads b/gcc/ada/sem_aux.ads
index 41ce3f0..c15c271 100644
--- a/gcc/ada/sem_aux.ads
+++ b/gcc/ada/sem_aux.ads
@@ -362,6 +362,9 @@ package Sem_Aux is
-- Given a subprogram or entry, determines whether E is a protected entry
-- or subprogram.
+ function Is_Record_Or_Limited_Type (Typ : Entity_Id) return Boolean;
+ -- Return True if Typ requires is a record or limited type.
+
function Nearest_Ancestor (Typ : Entity_Id) return Entity_Id;
-- Given a subtype Typ, this function finds out the nearest ancestor from
-- which constraints and predicates are inherited. There is no simple link
diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
index 445122f..fe8aed5 100644
--- a/gcc/ada/sem_ch4.adb
+++ b/gcc/ada/sem_ch4.adb
@@ -3018,10 +3018,14 @@ package body Sem_Ch4 is
Op := Make_Op_Ne (Loc, Left_Opnd => L, Right_Opnd => R);
end if;
- -- We reset the Entity since we do not want to bypass the operator
- -- resolution.
+ if Is_Record_Or_Limited_Type (Etype (L)) then
+
+ -- We reset the Entity in order to use the primitive equality
+ -- of the type, as per RM 4.5.2 (28.1/4).
+
+ Set_Entity (Op, Empty);
+ end if;
- Set_Entity (Op, Empty);
Rewrite (N, Op);
Analyze (N);
return;