diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/fold-const.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/tree-ssa/ptrmemfield.C | 27 |
4 files changed, 38 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0b9f0c3..b769f68 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2008-07-05 Andrew Pinski <andrew_pinski@playstation.sony.com> + + * fold-const.c (fold_convert_const): Treat OFFSET_TYPE the same as + integral and pointer types. + 2008-07-04 Roger Sayle <roger@eyesopen.com> * config/rs6000/host-darwin.c (darwin_rs6000_extra_siganls): Cast diff --git a/gcc/fold-const.c b/gcc/fold-const.c index fc72b9b..e1e04bb 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -2396,7 +2396,8 @@ fold_convert_const (enum tree_code code, tree type, tree arg1) if (TREE_TYPE (arg1) == type) return arg1; - if (POINTER_TYPE_P (type) || INTEGRAL_TYPE_P (type)) + if (POINTER_TYPE_P (type) || INTEGRAL_TYPE_P (type) + || TREE_CODE (type) == OFFSET_TYPE) { if (TREE_CODE (arg1) == INTEGER_CST) return fold_convert_const_int_from_int (type, arg1); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2cf3a62..7eb21a4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2008-07-05 Andrew Pinski <andrew_pinski@playstation.sony.com> + + * g++.dg/tree-ssa/ptrmemfield.C: New testcase. + 2008-07-05 Joseph Myers <joseph@codesourcery.com> * lib/gcc-dg.exp (remove-build-file): Remove files on remote host diff --git a/gcc/testsuite/g++.dg/tree-ssa/ptrmemfield.C b/gcc/testsuite/g++.dg/tree-ssa/ptrmemfield.C new file mode 100644 index 0000000..38189eb --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/ptrmemfield.C @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +// { dg-options "-O2 -fdump-tree-final_cleanup" } + + +struct f +{ + char m; + char m1; +}; + +static inline char f:: *g(int a) +{ + return a?0:&f::m; +} + +int h(void) +{ + char f:: *a = g(0); + return a == 0; +} + +/* We should have no cast to offset_type. */ +/* { dg-final { scan-tree-dump-times "offset_type" 0 "final_cleanup"} } */ +// And we should optimized this code to just return 0 +/* { dg-final { scan-tree-dump-times "return 0" 1 "final_cleanup"} } */ +/* { dg-final { cleanup-tree-dump "final_cleanup" } } */ + |