summaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/utils2.c
diff options
context:
space:
mode:
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2016-10-11 10:19:39 +0000
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2016-10-11 10:19:39 +0000
commit5852b0a407b84f6698f5b6cbad16adb64e4e6ebb (patch)
tree17830370fb0bc223697052c20038f600115efa0e /gcc/ada/gcc-interface/utils2.c
parent070b207449232243e6aa091c2175393ed08b53d8 (diff)
* gcc-interface/utils2.c (build_binary_op): Add a NO_FOLD
argument. Disable folding when true. * gcc-interface/gigi.h (choices_to_gnu): Remove declaration. (build_binary_op): Update signature and comment. * gcc-interface/decl.c (choices_to_gnu): Make static. Disable folding for all calls to build_binary_op. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@240978 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/gcc-interface/utils2.c')
-rw-r--r--gcc/ada/gcc-interface/utils2.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c
index b820fea28b75..9ace387b85aa 100644
--- a/gcc/ada/gcc-interface/utils2.c
+++ b/gcc/ada/gcc-interface/utils2.c
@@ -834,6 +834,7 @@ build_load_modify_store (tree dest, tree src, Node_Id gnat_node)
in that type. For INIT_EXPR and MODIFY_EXPR, RESULT_TYPE must be
NULL_TREE. For ARRAY_REF, RESULT_TYPE may be NULL_TREE, in which
case the type to be used will be derived from the operands.
+ Don't fold the result if NO_FOLD is true.
This function is very much unlike the ones for C and C++ since we
have already done any type conversion and matching required. All we
@@ -841,7 +842,8 @@ build_load_modify_store (tree dest, tree src, Node_Id gnat_node)
tree
build_binary_op (enum tree_code op_code, tree result_type,
- tree left_operand, tree right_operand)
+ tree left_operand, tree right_operand,
+ bool no_fold)
{
tree left_type = TREE_TYPE (left_operand);
tree right_type = TREE_TYPE (right_operand);
@@ -1283,10 +1285,16 @@ build_binary_op (enum tree_code op_code, tree result_type,
else if (TREE_CODE (right_operand) == NULL_EXPR)
return build1 (NULL_EXPR, operation_type, TREE_OPERAND (right_operand, 0));
else if (op_code == ARRAY_REF || op_code == ARRAY_RANGE_REF)
- result = fold (build4 (op_code, operation_type, left_operand,
- right_operand, NULL_TREE, NULL_TREE));
+ {
+ result = build4 (op_code, operation_type, left_operand, right_operand,
+ NULL_TREE, NULL_TREE);
+ if (!no_fold)
+ result = fold (result);
+ }
else if (op_code == INIT_EXPR || op_code == MODIFY_EXPR)
result = build2 (op_code, void_type_node, left_operand, right_operand);
+ else if (no_fold)
+ result = build2 (op_code, operation_type, left_operand, right_operand);
else
result
= fold_build2 (op_code, operation_type, left_operand, right_operand);
@@ -1307,8 +1315,13 @@ build_binary_op (enum tree_code op_code, tree result_type,
/* If we are working with modular types, perform the MOD operation
if something above hasn't eliminated the need for it. */
if (modulus)
- result = fold_build2 (FLOOR_MOD_EXPR, operation_type, result,
- convert (operation_type, modulus));
+ {
+ modulus = convert (operation_type, modulus);
+ if (no_fold)
+ result = build2 (FLOOR_MOD_EXPR, operation_type, result, modulus);
+ else
+ result = fold_build2 (FLOOR_MOD_EXPR, operation_type, result, modulus);
+ }
if (result_type && result_type != operation_type)
result = convert (result_type, result);