public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-4295] [Ada] Simplify detection of record components with default initialization
@ 2021-10-11 13:39 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-10-11 13:39 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:b52e15202c8a0ed1afeff92bba72fd2811c9dac1
commit r12-4295-gb52e15202c8a0ed1afeff92bba72fd2811c9dac1
Author: Piotr Trojanek <trojanek@adacore.com>
Date: Wed Sep 29 12:16:38 2021 +0200
[Ada] Simplify detection of record components with default initialization
gcc/ada/
* exp_aggr.adb (Has_Default_Init_Comps): Simplify.
Diff:
---
gcc/ada/exp_aggr.adb | 43 +++++++++++++++++++------------------------
1 file changed, 19 insertions(+), 24 deletions(-)
diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb
index 06cdafda418..187bb5f47b6 100644
--- a/gcc/ada/exp_aggr.adb
+++ b/gcc/ada/exp_aggr.adb
@@ -8897,46 +8897,41 @@ package body Exp_Aggr is
----------------------------
function Has_Default_Init_Comps (N : Node_Id) return Boolean is
- Comps : constant List_Id := Component_Associations (N);
- C : Node_Id;
+ Assoc : Node_Id;
Expr : Node_Id;
+ -- Component association and expression, respectively
begin
pragma Assert (Nkind (N) in N_Aggregate | N_Extension_Aggregate);
- if No (Comps) then
- return False;
- end if;
-
if Has_Self_Reference (N) then
return True;
end if;
- -- Check if any direct component has default initialized components
+ Assoc := First (Component_Associations (N));
+ while Present (Assoc) loop
+ -- Each component association has either a box or an expression
- C := First (Comps);
- while Present (C) loop
- if Box_Present (C) then
- return True;
- end if;
+ pragma Assert (Box_Present (Assoc) xor Present (Expression (Assoc)));
- Next (C);
- end loop;
+ -- Check if any direct component has default initialized components
- -- Recursive call in case of aggregate expression
+ if Box_Present (Assoc) then
+ return True;
- C := First (Comps);
- while Present (C) loop
- Expr := Expression (C);
+ -- Recursive call in case of aggregate expression
- if Present (Expr)
- and then Nkind (Expr) in N_Aggregate | N_Extension_Aggregate
- and then Has_Default_Init_Comps (Expr)
- then
- return True;
+ else
+ Expr := Expression (Assoc);
+
+ if Nkind (Expr) in N_Aggregate | N_Extension_Aggregate
+ and then Has_Default_Init_Comps (Expr)
+ then
+ return True;
+ end if;
end if;
- Next (C);
+ Next (Assoc);
end loop;
return False;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-10-11 13:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-11 13:39 [gcc r12-4295] [Ada] Simplify detection of record components with default initialization Pierre-Marie de Rodat
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).