From d118bc58f56a7aa0bcd4e0371782e59ffb8cde73 Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Sat, 22 Jan 2022 19:38:10 +0100 Subject: [Ada] Reuse Is_Rewrite_Substitution where possible Replace comparisons of Original_Node with semantically equivalent but high-level calls to Is_Rewrite_Substitution. Offending occurrences found with: $ grep -n "Original_Node (\([A-Za-z_]\+\)) /\?= \1" *.adb Code cleanup only; semantics is unaffected. gcc/ada/ * atree.adb, exp_ch6.adb, exp_ch9.adb, ghost.adb, sem_ch3.adb, sem_ch4.adb, sem_res.adb, sem_util.adb: Use Is_Rewrite_Substitution where possible. --- gcc/ada/sem_ch3.adb | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'gcc/ada/sem_ch3.adb') diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 2ab273b..53b0ec9 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -20185,20 +20185,14 @@ package body Sem_Ch3 is => return not Comes_From_Source (Exp) and then - -- If the conversion has been rewritten, check Original_Node + -- If the conversion has been rewritten, check Original_Node; + -- otherwise, check the expression of the compiler-generated + -- conversion (which is a conversion that we want to ignore + -- for purposes of the limited-initialization restrictions). - ((Original_Node (Exp) /= Exp - and then - OK_For_Limited_Init_In_05 (Typ, Original_Node (Exp))) - - -- Otherwise, check the expression of the compiler-generated - -- conversion (which is a conversion that we want to ignore - -- for purposes of the limited-initialization restrictions). - - or else - (Original_Node (Exp) = Exp - and then - OK_For_Limited_Init_In_05 (Typ, Expression (Exp)))); + (if Is_Rewrite_Substitution (Exp) + then OK_For_Limited_Init_In_05 (Typ, Original_Node (Exp)) + else OK_For_Limited_Init_In_05 (Typ, Expression (Exp))); when N_Explicit_Dereference | N_Indexed_Component @@ -20547,7 +20541,7 @@ package body Sem_Ch3 is -- its Original_Node points to the old Discr and the access type -- for Discr_Type has already been created. - if Original_Node (Discr) /= Discr then + if Is_Rewrite_Substitution (Discr) then Discr_Type := Etype (Discriminant_Type (Discr)); else Discr_Type := -- cgit v1.1