summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2007-10-05 16:33:25 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2007-10-05 16:33:25 +0000
commit0fd56ba63aedc691ef1dae70f621639b77274b91 (patch)
tree7e671b5aaa5937f432deacc82380c31465101592
parentf211ad17ba6a558a290dceb84cbafd2c9d61de34 (diff)
downloadppe42-gcc-0fd56ba63aedc691ef1dae70f621639b77274b91.tar.gz
ppe42-gcc-0fd56ba63aedc691ef1dae70f621639b77274b91.zip
2007-10-05 Richard Guenther <rguenther@suse.de>
PR middle-end/33666 * fold-const.c (fold_unary): Do not fold (long long)(int)ptr to (long long)ptr. * gcc.dg/pr33666.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@129036 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/fold-const.c6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr33666.c11
4 files changed, 24 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8c6c7737c52..800e19636df 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2007-10-05 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/33666
+ * fold-const.c (fold_unary): Do not fold (long long)(int)ptr
+ to (long long)ptr.
+
2007-10-05 Michael Matz <matz@suse.de>
PR inline-asm/33600
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 62cbfd11ee0..46e0e3348a5 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -8128,7 +8128,7 @@ fold_unary (enum tree_code code, tree type, tree op0)
(for integers). Avoid this if the final type is a pointer
since then we sometimes need the inner conversion. Likewise if
the outer has a precision not equal to the size of its mode. */
- if ((((inter_int || inter_ptr) && (inside_int || inside_ptr))
+ if (((inter_int && inside_int)
|| (inter_float && inside_float)
|| (inter_vec && inside_vec))
&& inter_prec >= inside_prec
@@ -8158,7 +8158,6 @@ fold_unary (enum tree_code code, tree type, tree op0)
intermediate and final types differ, or
- the final type is a pointer type and the precisions of the
initial and intermediate types differ.
- - the final type is a pointer type and the initial type not
- the initial type is a pointer to an array and the final type
not. */
if (! inside_float && ! inter_float && ! final_float
@@ -8173,8 +8172,7 @@ fold_unary (enum tree_code code, tree type, tree op0)
&& ! (final_ptr && inside_prec != inter_prec)
&& ! (final_prec != GET_MODE_BITSIZE (TYPE_MODE (type))
&& TYPE_MODE (type) == TYPE_MODE (inter_type))
- && final_ptr == inside_ptr
- && ! (inside_ptr
+ && ! (inside_ptr && final_ptr
&& TREE_CODE (TREE_TYPE (inside_type)) == ARRAY_TYPE
&& TREE_CODE (TREE_TYPE (type)) != ARRAY_TYPE))
return fold_build1 (code, type, TREE_OPERAND (op0, 0));
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6b06d140c31..d73bde39a46 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2007-10-05 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/33666
+ * gcc.dg/pr33666.c: New testcase.
+
2007-10-05 Michael Matz <matz@suse.de>
PR inline-asm/33600
diff --git a/gcc/testsuite/gcc.dg/pr33666.c b/gcc/testsuite/gcc.dg/pr33666.c
new file mode 100644
index 00000000000..1f27b136d36
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr33666.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options { -std=c99 } } */
+
+/* This used to fail with type-checking enabled because we stripped
+ the inner conversion to unsigned int. */
+
+void __lock_get_list(void *dp)
+{
+ if (((__SIZE_TYPE__)dp + 1) & ~1ULL)
+ ;
+}
OpenPOWER on IntegriCloud