]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
utils2.c (build_cond_expr): Take the address and dereference if the result type is...
authorEric Botcazou <ebotcazou@adacore.com>
Sun, 11 Apr 2010 11:23:32 +0000 (11:23 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Sun, 11 Apr 2010 11:23:32 +0000 (11:23 +0000)
* gcc-interface/utils2.c (build_cond_expr): Take the address and
dereference if the result type is passed by reference.

From-SVN: r158201

gcc/ada/ChangeLog
gcc/ada/gcc-interface/utils2.c

index 364381179e8912bb5cd7ae35970f65f2521091dd..626eb4f8b274febcde1d49ad4932eafe5ef2c404 100644 (file)
@@ -1,3 +1,8 @@
+2010-04-11  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/utils2.c (build_cond_expr): Take the address and
+       dereference if the result type is passed by reference.
+
 2010-04-11  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc-interface/trans.c (Case_Statement_to_gnu): Bool-ify variable.
index a6ec65fd54d0f52457eee6b17c46a4d7e1cc1458..29d60daf3460cab9f31e27df55635f6ca4c8acbd 100644 (file)
@@ -1291,10 +1291,12 @@ 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 our result.  */
+  /* 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 (TREE_CODE (result_type) == UNCONSTRAINED_ARRAY_TYPE
-      || CONTAINS_PLACEHOLDER_P (TYPE_SIZE (result_type)))
+      || CONTAINS_PLACEHOLDER_P (TYPE_SIZE (result_type))
+      || (AGGREGATE_TYPE_P (result_type) && TYPE_BY_REFERENCE_P (result_type)))
     {
       result_type = build_pointer_type (result_type);
       true_operand = build_unary_op (ADDR_EXPR, result_type, true_operand);