aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_ch3.adb
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2022-01-22 19:38:10 +0100
committerPierre-Marie de Rodat <derodat@adacore.com>2022-05-10 08:19:28 +0000
commitd118bc58f56a7aa0bcd4e0371782e59ffb8cde73 (patch)
tree4ea0a431e04d8264bb3a2556c1078bfa1157d128 /gcc/ada/sem_ch3.adb
parentb814f0bdf1c1f6bcb628567c8e0e95fd68425657 (diff)
downloadgcc-d118bc58f56a7aa0bcd4e0371782e59ffb8cde73.zip
gcc-d118bc58f56a7aa0bcd4e0371782e59ffb8cde73.tar.gz
gcc-d118bc58f56a7aa0bcd4e0371782e59ffb8cde73.tar.bz2
[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.
Diffstat (limited to 'gcc/ada/sem_ch3.adb')
-rw-r--r--gcc/ada/sem_ch3.adb22
1 files changed, 8 insertions, 14 deletions
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 :=