From 967fb65e809daa9c8d5a233dab77dd5e61d8effc Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Fri, 5 Oct 2012 16:26:27 +0200 Subject: [multiple changes] 2012-10-05 Robert Dewar * sem_util.adb (Has_One_Matching_Field): Handle case of lone discriminant. 2012-10-05 Yannick Moy * checks.adb (Minimize_Eliminate_Overflow_Checks): Correct code for the division operation and exponent operation. Adjust bound for the mod and rem operations. From-SVN: r192126 --- gcc/ada/sem_util.adb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'gcc/ada/sem_util.adb') diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 2202c88..1c9eb64 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -13622,7 +13622,9 @@ package body Sem_Util is function Has_One_Matching_Field return Boolean; -- Determines if Expec_Type is a record type with a single component or -- discriminant whose type matches the found type or is one dimensional - -- array whose component type matches the found type. + -- array whose component type matches the found type. In the case of + -- one discriminant, we ignore the variant parts. That's not accurate, + -- but good enough for the warning. ---------------------------- -- Has_One_Matching_Field -- @@ -13664,10 +13666,10 @@ package body Sem_Util is if No (E) then return False; - elsif (Ekind (E) /= E_Discriminant - and then Ekind (E) /= E_Component) + elsif not Ekind_In (E, E_Discriminant, E_Component) or else (Chars (E) = Name_uTag - or else Chars (E) = Name_uParent) + or else + Chars (E) = Name_uParent) then Next_Entity (E); @@ -13679,7 +13681,10 @@ package body Sem_Util is if not Covers (Etype (E), Found_Type) then return False; - elsif Present (Next_Entity (E)) then + elsif Present (Next_Entity (E)) + and then (Ekind (E) = E_Component + or else Ekind (Next_Entity (E)) = E_Discriminant) + then return False; else -- cgit v1.1