diff mbox series

[COMMITTED,22/31] ada: Avoid temporary for conditional expression of discriminated record type

Message ID 20240521073035.314024-22-poulhies@adacore.com
State New
Headers show
Series [COMMITTED,01/31] ada: Add new Mingw task priority mapping | expand

Commit Message

Marc Poulhiès May 21, 2024, 7:30 a.m. UTC
From: Eric Botcazou <ebotcazou@adacore.com>

This just aligns the definite case (discriminants with default) with the
indefinite case (discriminants without default), the latter case having
been properly handled for long.  In the former case, the maximum size is
used so a temporary can be much larger than the actual data it contains.

gcc/ada/

	* gcc-interface/utils2.cc (build_cond_expr): Use the indirect path
	for all types containing a placeholder.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/gcc-interface/utils2.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/gcc/ada/gcc-interface/utils2.cc b/gcc/ada/gcc-interface/utils2.cc
index a953b070ed8..fb0ccf59224 100644
--- a/gcc/ada/gcc-interface/utils2.cc
+++ b/gcc/ada/gcc-interface/utils2.cc
@@ -1715,8 +1715,8 @@  build_cond_expr (tree result_type, tree condition_operand,
      then dereference the result.  Likewise if the result type is passed by
      reference, because creating a temporary of this type is not allowed.  */
   if (TREE_CODE (result_type) == UNCONSTRAINED_ARRAY_TYPE
-      || TYPE_IS_BY_REFERENCE_P (result_type)
-      || CONTAINS_PLACEHOLDER_P (TYPE_SIZE (result_type)))
+      || type_contains_placeholder_p (result_type)
+      || TYPE_IS_BY_REFERENCE_P (result_type))
     {
       result_type = build_pointer_type (result_type);
       true_operand = build_unary_op (ADDR_EXPR, result_type, true_operand);