aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@gcc.gnu.org>2016-02-05 14:05:17 -0800
committerRichard Henderson <rth@gcc.gnu.org>2016-02-05 14:05:17 -0800
commitbe2083eab7d8d276bafcd63b02fbf8ed0748e8d4 (patch)
tree9256eb829d4d9384df1f7ec1343fb1516759dc3d /gcc/tree.c
parent711d7c231fc6a5a04f65568cf17a47c270527a09 (diff)
downloadgcc-be2083eab7d8d276bafcd63b02fbf8ed0748e8d4.zip
gcc-be2083eab7d8d276bafcd63b02fbf8ed0748e8d4.tar.gz
gcc-be2083eab7d8d276bafcd63b02fbf8ed0748e8d4.tar.bz2
re PR middle-end/69643 (Address space discarded)
PR c/69643 * tree.c (tree_nop_conversion_p): Do not strip casts into or out of non-standard address spaces. testsuite/ * gcc.target/i386/addr-space-4.c: New. * gcc.target/i386/addr-space-5.c: New. From-SVN: r233189
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index fa7646b..07cb9d9 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -12219,6 +12219,23 @@ block_ultimate_origin (const_tree block)
bool
tree_nop_conversion_p (const_tree outer_type, const_tree inner_type)
{
+ /* Do not strip casts into or out of differing address spaces. */
+ if (POINTER_TYPE_P (outer_type)
+ && TYPE_ADDR_SPACE (TREE_TYPE (outer_type)) != ADDR_SPACE_GENERIC)
+ {
+ if (!POINTER_TYPE_P (inner_type)
+ || (TYPE_ADDR_SPACE (TREE_TYPE (outer_type))
+ != TYPE_ADDR_SPACE (TREE_TYPE (inner_type))))
+ return false;
+ }
+ else if (POINTER_TYPE_P (inner_type)
+ && TYPE_ADDR_SPACE (TREE_TYPE (inner_type)) != ADDR_SPACE_GENERIC)
+ {
+ /* We already know that outer_type is not a pointer with
+ a non-generic address space. */
+ return false;
+ }
+
/* Use precision rather then machine mode when we can, which gives
the correct answer even for submode (bit-field) types. */
if ((INTEGRAL_TYPE_P (outer_type)