aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@gcc.gnu.org>2020-05-09 22:56:14 +0200
committerEric Botcazou <ebotcazou@gcc.gnu.org>2020-05-09 22:56:14 +0200
commit2448ee85a89f313e48ee40eaed0d645c4c027944 (patch)
tree4359ad4a72a81748938f787b46ccf8fd78e6c9e3
parente92f85c792c8c5e7846ba2bc7f5e24f08dcdfece (diff)
downloadgcc-2448ee85a89f313e48ee40eaed0d645c4c027944.zip
gcc-2448ee85a89f313e48ee40eaed0d645c4c027944.tar.gz
gcc-2448ee85a89f313e48ee40eaed0d645c4c027944.tar.bz2
Fix tree sharing issue with slices
This can happen because we build an array type on the fly in case there is an apparent type inconsistency in the construct. * gcc-interface/utils2.c (build_binary_op) <ARRAY_RANGE_REF>: Use build_nonshared_array_type to build the common type and declare it.
-rw-r--r--gcc/ada/ChangeLog5
-rw-r--r--gcc/ada/gcc-interface/utils2.c11
2 files changed, 14 insertions, 2 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 6ee4942..81108bf 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,10 @@
2020-05-09 Eric Botcazou <ebotcazou@adacore.com>
+ * gcc-interface/utils2.c (build_binary_op) <ARRAY_RANGE_REF>: Use
+ build_nonshared_array_type to build the common type and declare it.
+
+2020-05-09 Eric Botcazou <ebotcazou@adacore.com>
+
* gcc-interface/misc.c (gnat_init_gcc_eh): Do not override the user
for -fnon-call-exceptions in default mode.
diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c
index 2ff8654..0d61205 100644
--- a/gcc/ada/gcc-interface/utils2.c
+++ b/gcc/ada/gcc-interface/utils2.c
@@ -1040,8 +1040,15 @@ build_binary_op (enum tree_code op_code, tree result_type,
/* For a range, make sure the element type is consistent. */
if (op_code == ARRAY_RANGE_REF
&& TREE_TYPE (operation_type) != TREE_TYPE (left_type))
- operation_type = build_array_type (TREE_TYPE (left_type),
- TYPE_DOMAIN (operation_type));
+ {
+ operation_type
+ = build_nonshared_array_type (TREE_TYPE (left_type),
+ TYPE_DOMAIN (operation_type));
+ /* Declare it now since it will never be declared otherwise. This
+ is necessary to ensure that its subtrees are properly marked. */
+ create_type_decl (TYPE_NAME (operation_type), operation_type, true,
+ false, Empty);
+ }
/* Then convert the right operand to its base type. This will prevent
unneeded sign conversions when sizetype is wider than integer. */