diff options
author | Ronan Desplanques <desplanques@adacore.com> | 2024-02-23 09:53:32 +0100 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2024-05-21 09:27:56 +0200 |
commit | a687d5da7015042fa7ff047430e3c5cb57524a7c (patch) | |
tree | 60e36ffaf725f458d70eba97d5f73ae981e63509 | |
parent | 3f4485608f1b4e2e0e91d2da8fa0a815110c5f8e (diff) | |
download | gcc-a687d5da7015042fa7ff047430e3c5cb57524a7c.zip gcc-a687d5da7015042fa7ff047430e3c5cb57524a7c.tar.gz gcc-a687d5da7015042fa7ff047430e3c5cb57524a7c.tar.bz2 |
ada: Fix crash with aliased array and if expression
The way if expressions were translated led the gimplifying phase
to attempt to create a temporary of a variable-sized type in some
cases. This patch fixes this by adding an address indirection layer
in those cases.
gcc/ada/
* gcc-interface/utils2.cc (build_cond_expr): Also apply an
indirection when the result type is variable-sized.
-rw-r--r-- | gcc/ada/gcc-interface/utils2.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/gcc/ada/gcc-interface/utils2.cc b/gcc/ada/gcc-interface/utils2.cc index 64712cb..161f0f1 100644 --- a/gcc/ada/gcc-interface/utils2.cc +++ b/gcc/ada/gcc-interface/utils2.cc @@ -1711,11 +1711,13 @@ build_cond_expr (tree result_type, tree condition_operand, true_operand = convert (result_type, true_operand); false_operand = convert (result_type, false_operand); - /* If the result type is unconstrained, take the address of the operands and - then dereference the result. Likewise if the result type is passed by - reference, because creating a temporary of this type is not allowed. */ + /* If the result type is unconstrained or variable-sized, take the address + of the operands and 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_contains_placeholder_p (result_type) + || !TREE_CONSTANT (TYPE_SIZE (result_type)) || TYPE_IS_BY_REFERENCE_P (result_type)) { result_type = build_pointer_type (result_type); |