aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2007-09-12 15:52:57 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2007-09-12 15:52:57 +0000
commitb693daa7a91aed74c366852d3359b97ad52a3c9b (patch)
treed3296b3ce3b3597b782252a07d76392ade05f4a4 /gcc/ada
parent94dabea7286d9e974c309c8b0a2e3b98d4c09891 (diff)
downloadgcc-b693daa7a91aed74c366852d3359b97ad52a3c9b.zip
gcc-b693daa7a91aed74c366852d3359b97ad52a3c9b.tar.gz
gcc-b693daa7a91aed74c366852d3359b97ad52a3c9b.tar.bz2
re PR ada/26797 (ACATS cxh1001 fails)
PR ada/26797 PR ada/32407 * utils.c (unchecked_convert): Use a subtype as the intermediate type in the special VIEW_CONVERT_EXPR case. From-SVN: r128441
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog7
-rw-r--r--gcc/ada/utils.c27
2 files changed, 19 insertions, 15 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 303f5d9..a0bf512 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,10 @@
+2007-09-12 Eric Botcazou <ebotcazou@adacore.com>
+
+ PR ada/26797
+ PR ada/32407
+ * utils.c (unchecked_convert): Use a subtype as the intermediate type
+ in the special VIEW_CONVERT_EXPR case.
+
2007-09-12 Robert Dewar <dewar@adacore.com>
* types.ads, a-charac.ads, freeze.adb: Minor reformatting.
diff --git a/gcc/ada/utils.c b/gcc/ada/utils.c
index 56d4900..0db4e78 100644
--- a/gcc/ada/utils.c
+++ b/gcc/ada/utils.c
@@ -3808,7 +3808,7 @@ unchecked_convert (tree type, tree expr, bool notrunc_p)
TYPE_MAIN_VARIANT (rtype) = rtype;
}
- /* We have another special case. If we are unchecked converting subtype
+ /* We have another special case: if we are unchecked converting subtype
into a base type, we need to ensure that VRP doesn't propagate range
information since this conversion may be done precisely to validate
that the object is within the range it is supposed to have. */
@@ -3818,21 +3818,18 @@ unchecked_convert (tree type, tree expr, bool notrunc_p)
|| TREE_CODE (etype) == ENUMERAL_TYPE
|| TREE_CODE (etype) == BOOLEAN_TYPE))
{
- /* ??? The pattern to be "preserved" by the middle-end and the
- optimizers is a VIEW_CONVERT_EXPR between a pair of different
- "base" types (integer types without TREE_TYPE). But this may
- raise addressability/aliasing issues because VIEW_CONVERT_EXPR
- gets gimplified as an lvalue, thus causing the address of its
- operand to be taken if it is deemed addressable and not already
- in GIMPLE form. */
+ /* The optimization barrier is a VIEW_CONVERT_EXPR node; moreover,
+ in order not to be deemed an useless type conversion, it must
+ be from subtype to base type.
+
+ ??? This may raise addressability and/or aliasing issues because
+ VIEW_CONVERT_EXPR gets gimplified as an lvalue, thus causing the
+ address of its operand to be taken if it is deemed addressable
+ and not already in GIMPLE form. */
rtype = gnat_type_for_mode (TYPE_MODE (type), TYPE_UNSIGNED (type));
-
- if (rtype == type)
- {
- rtype = copy_type (rtype);
- TYPE_MAIN_VARIANT (rtype) = rtype;
- }
-
+ rtype = copy_type (rtype);
+ TYPE_MAIN_VARIANT (rtype) = rtype;
+ TREE_TYPE (rtype) = type;
final_unchecked = true;
}