aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@gcc.gnu.org>2020-05-09 22:36:11 +0200
committerEric Botcazou <ebotcazou@gcc.gnu.org>2020-05-09 22:36:11 +0200
commitb9364a56d107083858267a52f162391d8cabb2f7 (patch)
tree598b18de55ad4f41f3ff21c5c20957f938d3e11b
parent40bd5a536257aabc0f3899d661debc13dee18d75 (diff)
downloadgcc-b9364a56d107083858267a52f162391d8cabb2f7.zip
gcc-b9364a56d107083858267a52f162391d8cabb2f7.tar.gz
gcc-b9364a56d107083858267a52f162391d8cabb2f7.tar.bz2
Accept qualified aggregates in memset path
Aggregates can be surrounded by a qualified expression and this prepares the support code in gigi for accepting them. * gcc-interface/trans.c (gnat_to_gnu) <N_Assignment_Statement>: Deal with qualified "others" aggregates in the memset case.
-rw-r--r--gcc/ada/ChangeLog5
-rw-r--r--gcc/ada/gcc-interface/trans.c28
2 files changed, 21 insertions, 12 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 20662be..6aec0ee 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,10 @@
2020-05-09 Eric Botcazou <ebotcazou@adacore.com>
+ * gcc-interface/trans.c (gnat_to_gnu) <N_Assignment_Statement>: Deal
+ with qualified "others" aggregates in the memset case.
+
+2020-05-09 Eric Botcazou <ebotcazou@adacore.com>
+
* gcc-interface/decl.c (gnat_to_gnu_param): Also back-annotate the
mechanism in the case of an Out parameter only passed by copy-out.
diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
index 20529e1..5de04ab 100644
--- a/gcc/ada/gcc-interface/trans.c
+++ b/gcc/ada/gcc-interface/trans.c
@@ -7813,25 +7813,29 @@ gnat_to_gnu (Node_Id gnat_node)
else
{
const Node_Id gnat_expr = Expression (gnat_node);
+ const Node_Id gnat_inner
+ = Nkind (gnat_expr) == N_Qualified_Expression
+ ? Expression (gnat_expr)
+ : gnat_expr;
const Entity_Id gnat_type
= Underlying_Type (Etype (Name (gnat_node)));
const bool regular_array_type_p
- = (Is_Array_Type (gnat_type) && !Is_Bit_Packed_Array (gnat_type));
+ = Is_Array_Type (gnat_type) && !Is_Bit_Packed_Array (gnat_type);
const bool use_memset_p
- = (regular_array_type_p
- && Nkind (gnat_expr) == N_Aggregate
- && Is_Others_Aggregate (gnat_expr));
+ = regular_array_type_p
+ && Nkind (gnat_inner) == N_Aggregate
+ && Is_Others_Aggregate (gnat_inner);
- /* If we'll use memset, we need to find the inner expression. */
+ /* If we use memset, we need to find the innermost expression. */
if (use_memset_p)
{
- Node_Id gnat_inner
- = Expression (First (Component_Associations (gnat_expr)));
- while (Nkind (gnat_inner) == N_Aggregate
- && Is_Others_Aggregate (gnat_inner))
- gnat_inner
- = Expression (First (Component_Associations (gnat_inner)));
- gnu_rhs = gnat_to_gnu (gnat_inner);
+ gnat_temp = gnat_inner;
+ do {
+ gnat_temp
+ = Expression (First (Component_Associations (gnat_temp)));
+ } while (Nkind (gnat_temp) == N_Aggregate
+ && Is_Others_Aggregate (gnat_temp));
+ gnu_rhs = gnat_to_gnu (gnat_temp);
}
else
gnu_rhs = maybe_unconstrained_array (gnat_to_gnu (gnat_expr));