aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2024-02-06 12:57:38 +0100
committerMarc Poulhiès <poulhies@adacore.com>2024-05-21 09:27:56 +0200
commite49eac82e805ede5dd9b3c5d4ae9f8d90b0cc034 (patch)
tree314aae31c0f351e97e7da178341a465b0304d17d
parent448157fbf9f2261ad1a2e98139603c002f86c7bf (diff)
downloadgcc-e49eac82e805ede5dd9b3c5d4ae9f8d90b0cc034.zip
gcc-e49eac82e805ede5dd9b3c5d4ae9f8d90b0cc034.tar.gz
gcc-e49eac82e805ede5dd9b3c5d4ae9f8d90b0cc034.tar.bz2
ada: Avoid temporary for conditional expression of discriminated record type
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.
-rw-r--r--gcc/ada/gcc-interface/utils2.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/ada/gcc-interface/utils2.cc b/gcc/ada/gcc-interface/utils2.cc
index a953b07..fb0ccf5 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);