From: Eric Botcazou Date: Tue, 13 Aug 2013 17:13:47 +0000 (+0000) Subject: trans.c (Call_to_gnu): Deal with specific conditional expressions for misaligned... X-Git-Tag: upstream/12.2.0~68412 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bb29e9ff3e42ee0bd23cf85cbce0e459213b19d0;p=platform%2Fupstream%2Fgcc.git trans.c (Call_to_gnu): Deal with specific conditional expressions for misaligned actual parameters. * gcc-interface/trans.c (Call_to_gnu): Deal with specific conditional expressions for misaligned actual parameters. From-SVN: r201700 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index e1f7363..5db69aa 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,10 @@ 2013-08-13 Eric Botcazou + * gcc-interface/trans.c (Call_to_gnu): Deal with specific conditional + expressions for misaligned actual parameters. + +2013-08-13 Eric Botcazou + * gcc-interface/trans.c (can_equal_min_or_max_val_p): Be prepared for values outside of the range of the type. diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index fdd59a8..5c1038a 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -4022,9 +4022,19 @@ Call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, tree gnu_target, /* Set up to move the copy back to the original if needed. */ if (!in_param) { - gnu_stmt = build_binary_op (MODIFY_EXPR, NULL_TREE, gnu_orig, - gnu_temp); + /* If the original is a COND_EXPR whose first arm isn't meant to + be further used, just deal with the second arm. This is very + likely the conditional expression built for a check. */ + if (TREE_CODE (gnu_orig) == COND_EXPR + && TREE_CODE (TREE_OPERAND (gnu_orig, 1)) == COMPOUND_EXPR + && integer_zerop + (TREE_OPERAND (TREE_OPERAND (gnu_orig, 1), 1))) + gnu_orig = TREE_OPERAND (gnu_orig, 2); + + gnu_stmt + = build_binary_op (MODIFY_EXPR, NULL_TREE, gnu_orig, gnu_temp); set_expr_location_from_node (gnu_stmt, gnat_node); + append_to_statement_list (gnu_stmt, &gnu_after_list); } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f962249..d1079e6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-08-13 Eric Botcazou + + * gnat.dg/valued_proc.adb: New test. + * gnat.dg/valued_proc_pkg.ads: New helper. + 2013-08-13 Jakub Jelinek PR tree-optimization/57661 diff --git a/gcc/testsuite/gnat.dg/valued_proc.adb b/gcc/testsuite/gnat.dg/valued_proc.adb new file mode 100644 index 0000000..7030b43 --- /dev/null +++ b/gcc/testsuite/gnat.dg/valued_proc.adb @@ -0,0 +1,12 @@ +-- { dg-do compile } +-- { dg-options "-gnatdm -gnatws" } + +with Valued_Proc_Pkg; use Valued_Proc_Pkg; +with System; use System; + +procedure Valued_Proc is + Status : UNSIGNED_LONGWORD; + Length : POSITIVE; +begin + GetMsg (Status, UNSIGNED_WORD(Length)); +end; diff --git a/gcc/testsuite/gnat.dg/valued_proc_pkg.ads b/gcc/testsuite/gnat.dg/valued_proc_pkg.ads new file mode 100644 index 0000000..d5197ab --- /dev/null +++ b/gcc/testsuite/gnat.dg/valued_proc_pkg.ads @@ -0,0 +1,15 @@ +pragma Extend_System (Aux_DEC); +with System; use System; + +package Valued_Proc_Pkg is + + procedure GETMSG (STATUS : out UNSIGNED_LONGWORD; + MSGLEN : out UNSIGNED_WORD); + + pragma Interface (EXTERNAL, GETMSG); + + pragma IMPORT_VALUED_PROCEDURE (GETMSG, "SYS$GETMSG", + (UNSIGNED_LONGWORD, UNSIGNED_WORD), + (VALUE, REFERENCE)); + +end Valued_Proc_Pkg;