From: Andrew Pinski Date: Sat, 5 Jul 2008 19:37:48 +0000 (+0000) Subject: ptrmemfield.C: New testcase. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0e4b00d683943bc1620bb025149918f844e88d41;p=gcc.git ptrmemfield.C: New testcase. 2008-07-05 Andrew Pinski * g++.dg/tree-ssa/ptrmemfield.C: New testcase. 2008-07-05 Andrew Pinski * fold-const.c (fold_convert_const): Treat OFFSET_TYPE the same as integral and pointer types. From-SVN: r137510 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0b9f0c3a0bb..b769f6857b5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2008-07-05 Andrew Pinski + + * fold-const.c (fold_convert_const): Treat OFFSET_TYPE the same as + integral and pointer types. + 2008-07-04 Roger Sayle * config/rs6000/host-darwin.c (darwin_rs6000_extra_siganls): Cast diff --git a/gcc/fold-const.c b/gcc/fold-const.c index fc72b9b38a2..e1e04bb625d 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 2cf3a6282d3..7eb21a42d71 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2008-07-05 Andrew Pinski + + * g++.dg/tree-ssa/ptrmemfield.C: New testcase. + 2008-07-05 Joseph Myers * 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 00000000000..38189eb43af --- /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" } } */ +