+2020-05-12 Eric Botcazou <ebotcazou@adacore.com>
+
+ * sem_aggr.ads (Is_Single_Aggregate): New function.
+ * sem_aggr.adb (Is_Others_Aggregate): Use local variable.
+ (Is_Single_Aggregate): New function to recognize an aggregate with
+ a single association containing a single choice.
+ * fe.h (Is_Others_Aggregate): Delete.
+ (Is_Single_Aggregate): New declaration.
+ * gcc-interface/trans.c (gnat_to_gnu) <N_Assignment_Statement>: Call
+ Is_Single_Aggregate instead of Is_Others_Aggregate.
+
2020-05-12 Eric Botcazou <ebotcazou@adacore.com>
PR ada/95035
/* sem_aggr: */
-#define Is_Others_Aggregate sem_aggr__is_others_aggregate
+#define Is_Single_Aggregate sem_aggr__is_single_aggregate
-extern Boolean Is_Others_Aggregate (Node_Id);
+extern Boolean Is_Single_Aggregate (Node_Id);
/* sem_aux: */
const bool use_memset_p
= regular_array_type_p
&& Nkind (gnat_inner) == N_Aggregate
- && Is_Others_Aggregate (gnat_inner);
+ && Is_Single_Aggregate (gnat_inner);
/* If we use memset, we need to find the innermost expression. */
if (use_memset_p)
gnat_temp
= Expression (First (Component_Associations (gnat_temp)));
} while (Nkind (gnat_temp) == N_Aggregate
- && Is_Others_Aggregate (gnat_temp));
+ && Is_Single_Aggregate (gnat_temp));
gnu_rhs = gnat_to_gnu (gnat_temp);
}
else
-------------------------
function Is_Others_Aggregate (Aggr : Node_Id) return Boolean is
+ Assoc : constant List_Id := Component_Associations (Aggr);
+
begin
return No (Expressions (Aggr))
- and then
- Nkind (First (Choice_List (First (Component_Associations (Aggr))))) =
- N_Others_Choice;
+ and then Nkind (First (Choice_List (First (Assoc)))) = N_Others_Choice;
end Is_Others_Aggregate;
+ -------------------------
+ -- Is_Single_Aggregate --
+ -------------------------
+
+ function Is_Single_Aggregate (Aggr : Node_Id) return Boolean is
+ Assoc : constant List_Id := Component_Associations (Aggr);
+
+ begin
+ return No (Expressions (Aggr))
+ and then No (Next (First (Assoc)))
+ and then No (Next (First (Choice_List (First (Assoc)))));
+ end Is_Single_Aggregate;
+
----------------------------
-- Is_Top_Level_Aggregate --
----------------------------
function Is_Others_Aggregate (Aggr : Node_Id) return Boolean;
-- Returns True is aggregate Aggr consists of a single OTHERS choice
+ function Is_Single_Aggregate (Aggr : Node_Id) return Boolean;
+ -- Returns True is aggregate Aggr consists of a single choice
+
-- WARNING: There is a matching C declaration of this subprogram in fe.h
end Sem_Aggr;