diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2019-01-26 15:59:34 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2019-01-26 15:59:34 +0000 |
commit | e54b62687aca823aebb15000d33ca59947204881 (patch) | |
tree | c2e68c9bb82f728bbb67b15006f98b911bb05121 /gcc/ada/gcc-interface | |
parent | 685ae5b8717e08e0d7b5f147ed4c6bfeff10c4f6 (diff) | |
download | gcc-e54b62687aca823aebb15000d33ca59947204881.zip gcc-e54b62687aca823aebb15000d33ca59947204881.tar.gz gcc-e54b62687aca823aebb15000d33ca59947204881.tar.bz2 |
trans.c (gnat_to_gnu): Use DECL_SIZE_UNIT instead of TYPE_SIZE_UNIT for the size to be assigned by a...
* gcc-interface/trans.c (gnat_to_gnu) <N_Assignment_Statement>: Use
DECL_SIZE_UNIT instead of TYPE_SIZE_UNIT for the size to be assigned
by a call to memset if the LHS is a DECL.
From-SVN: r268296
Diffstat (limited to 'gcc/ada/gcc-interface')
-rw-r--r-- | gcc/ada/gcc-interface/trans.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index be5ce1c..db8e4c2 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -7742,12 +7742,17 @@ gnat_to_gnu (Node_Id gnat_node) = real_zerop (gnu_rhs) ? integer_zero_node : fold_convert (integer_type_node, gnu_rhs); - tree to = gnu_lhs; - tree type = TREE_TYPE (to); - tree size - = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TYPE_SIZE_UNIT (type), to); - tree to_ptr = build_fold_addr_expr (to); + tree dest = build_fold_addr_expr (gnu_lhs); tree t = builtin_decl_explicit (BUILT_IN_MEMSET); + /* Be extra careful not to write too much data. */ + tree size; + if (TREE_CODE (gnu_lhs) == COMPONENT_REF) + size = DECL_SIZE_UNIT (TREE_OPERAND (gnu_lhs, 1)); + else if (DECL_P (gnu_lhs)) + size = DECL_SIZE_UNIT (gnu_lhs); + else + size = TYPE_SIZE_UNIT (TREE_TYPE (gnu_lhs)); + size = SUBSTITUTE_PLACEHOLDER_IN_EXPR (size, gnu_lhs); if (TREE_CODE (value) == INTEGER_CST && !integer_zerop (value)) { tree mask @@ -7755,7 +7760,7 @@ gnat_to_gnu (Node_Id gnat_node) ((HOST_WIDE_INT) 1 << BITS_PER_UNIT) - 1); value = int_const_binop (BIT_AND_EXPR, value, mask); } - gnu_result = build_call_expr (t, 3, to_ptr, value, size); + gnu_result = build_call_expr (t, 3, dest, value, size); } /* Otherwise build a regular assignment. */ |