summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-ssa/foldcast-1.c
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2006-05-11 08:29:40 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2006-05-11 08:29:40 +0000
commit219dad967d620f9b4ee558fb5ba3bf5fb8c4cabc (patch)
tree17f244ccd429a0d120041c3e273cdd7bc9688376 /gcc/testsuite/gcc.dg/tree-ssa/foldcast-1.c
parent26ff41d3eb1a3d9514af82a7bccd9dfc1fb49eb4 (diff)
downloadgcc-219dad967d620f9b4ee558fb5ba3bf5fb8c4cabc.tar.gz
2006-05-11 Richard Guenther <rguenther@suse.de>
PR middle-end/27529 * fold-const.c (fold_unary): Handle intermediate conversion to a pointer type like intermediate conversion to an integer type in folding of (T1)(T2)var to var. Match the code to the comment in the final conversion for (T1)(T2)var to (T1)var regarding to type precision. Rather than disallow T1 being of pointer type, assert that both T1 and var are of pointer type or not. Make sure not to fall over the frontends lazyness wrt array to pointer decay though. * gcc.dg/tree-ssa/foldcast-1.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@113692 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/tree-ssa/foldcast-1.c')
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/foldcast-1.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/foldcast-1.c b/gcc/testsuite/gcc.dg/tree-ssa/foldcast-1.c
new file mode 100644
index 00000000000..a0626ea10d9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/foldcast-1.c
@@ -0,0 +1,16 @@
+/* { dg-do "compile" } */
+/* { dg-options "-fdump-tree-original" } */
+
+typedef int ssize_t __attribute__((mode(pointer)));
+ssize_t foo (ssize_t x)
+{
+ return (ssize_t)(char *)x;
+}
+
+char *bar (char *x)
+{
+ return (char *)(ssize_t)x;
+}
+
+/* { dg-final { scan-tree-dump-times "return x;" 2 "original" } } */
+/* { dg-final { cleanup-tree-dump "original" } } */