* [COMMITTED] ada: Too-strict conformance checking for formal discriminated type
@ 2023-11-30 10:19 Marc Poulhiès
0 siblings, 0 replies; only message in thread
From: Marc Poulhiès @ 2023-11-30 10:19 UTC (permalink / raw)
To: gcc-patches; +Cc: Steve Baird
From: Steve Baird <baird@adacore.com>
The discriminant subtype conformance check for an actual parameter
corresponding to a generic formal discriminated type was too strict and
could incorrectly reject legal instantiations.
gcc/ada/
* sem_ch12.adb (Validate_Discriminated_Formal_Type): Replace
Entity_Id equality test with a call to Subtypes_Match. Distinct
subtypes which are statically matching should pass this test.
(Check_Discriminated_Formal): Replace Entity_Id equality test with
a call to Subtypes_Statically_Match (preceded by a check that the
preconditions for the call are satisfied).
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/sem_ch12.adb | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb
index 7c645c490ae..ea85e88d753 100644
--- a/gcc/ada/sem_ch12.adb
+++ b/gcc/ada/sem_ch12.adb
@@ -14001,9 +14001,10 @@ package body Sem_Ch12 is
and then (Ekind (Base_Type (Etype (Actual_Discr)))) =
E_Anonymous_Access_Type
and then
- Get_Instance_Of
- (Designated_Type (Base_Type (Formal_Subt))) =
- Designated_Type (Base_Type (Etype (Actual_Discr)))
+ Subtypes_Match
+ (Get_Instance_Of
+ (Designated_Type (Base_Type (Formal_Subt))),
+ Designated_Type (Base_Type (Etype (Actual_Discr))))
then
null;
@@ -17322,8 +17323,14 @@ package body Sem_Ch12 is
and then (Ekind (Base_Type (Etype (Actual_Discr)))) =
E_Anonymous_Access_Type
and then
- Designated_Type (Base_Type (Formal_Subt)) =
- Designated_Type (Base_Type (Etype (Actual_Discr)))
+ Base_Type
+ (Designated_Type (Base_Type (Formal_Subt))) =
+ Base_Type
+ (Designated_Type (Base_Type (Etype (Actual_Discr))))
+ and then
+ Subtypes_Statically_Match
+ (Designated_Type (Base_Type (Formal_Subt)),
+ Designated_Type (Base_Type (Etype (Actual_Discr))))
then
null;
--
2.42.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-11-30 10:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-30 10:19 [COMMITTED] ada: Too-strict conformance checking for formal discriminated type Marc Poulhiès
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).