]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Avoid temporary for conditional expression of discriminated record type
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 6 Feb 2024 11:57:38 +0000 (12:57 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 21 May 2024 07:27:56 +0000 (09:27 +0200)
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.

gcc/ada/gcc-interface/utils2.cc

index a953b070ed88b545d2f0aa7ebbcb213c078541cf..fb0ccf592249c9110529a97580561898a759fdeb 100644 (file)
@@ -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);