From 8be71a90b15916a966553c47857e1579ca22d507 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Tue, 12 Apr 2022 21:56:35 +0200 Subject: [Ada] Avoid copy operation for returns involving function calls The underlying issue is that the front-end does not create transient scopes for return statements, so objects copied for these statements can never be finalized properly. gcc/ada/ * exp_ch6.adb (Expand_Call_Helper): Adjust comment. (Expand_Simple_Function_Return): For the case of a type which needs finalization and is returned on the primary stack, do not create a copy if the expression originates from a function call. * exp_ch7.adb (Transient Scope Management): Adjust comment. * exp_util.ads (Is_Related_To_Func_Return): Add WARNING line. * fe.h (Is_Related_To_Func_Return): Declare. --- gcc/ada/fe.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'gcc/ada/fe.h') diff --git a/gcc/ada/fe.h b/gcc/ada/fe.h index 4be9d94..bfd9054 100644 --- a/gcc/ada/fe.h +++ b/gcc/ada/fe.h @@ -183,9 +183,11 @@ extern Boolean Is_Init_Proc (Entity_Id); /* exp_util: */ #define Is_Fully_Repped_Tagged_Type exp_util__is_fully_repped_tagged_type +#define Is_Related_To_Func_Return exp_util__is_related_to_func_return #define Find_Interface_Tag exp_util__find_interface_tag -extern Boolean Is_Fully_Repped_Tagged_Type (Entity_Id); +extern Boolean Is_Fully_Repped_Tagged_Type (Entity_Id); +extern Boolean Is_Related_To_Func_Return (Entity_Id); extern Entity_Id Find_Interface_Tag (Entity_Id, Entity_Id); /* lib: */ -- cgit v1.1