From: Richard Guenther Date: Wed, 11 Aug 2010 12:59:47 +0000 (+0000) Subject: re PR c/44555 (Pointer evalutions, is that expected ?) X-Git-Tag: releases/gcc-4.3.6~384 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d0de26e6739175f968b470b8115cdd5d05b029a1;p=thirdparty%2Fgcc.git re PR c/44555 (Pointer evalutions, is that expected ?) 2010-08-11 Richard Guenther PR c/44555 * c-common.c (c_common_truthvalue_conversion): Remove premature and wrong optimization concering ADDR_EXPRs. * gcc.c-torture/execute/pr44555.c: New testcase. From-SVN: r163098 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 48cb95ea00a7..bec37a0c9b45 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2010-08-11 Richard Guenther + + PR c/44555 + * c-common.c (c_common_truthvalue_conversion): Remove + premature and wrong optimization concering ADDR_EXPRs. + 2010-08-10 John David Anglin PR boehm-gc/34544 diff --git a/gcc/c-common.c b/gcc/c-common.c index 4b2ee065ad9c..e809332c7904 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -3013,20 +3013,7 @@ c_common_truthvalue_conversion (tree expr) inner); return truthvalue_true_node; } - - /* If we still have a decl, it is possible for its address to - be NULL, so we cannot optimize. */ - if (DECL_P (inner)) - { - gcc_assert (DECL_WEAK (inner)); - break; - } - - if (TREE_SIDE_EFFECTS (inner)) - return build2 (COMPOUND_EXPR, truthvalue_type_node, - inner, truthvalue_true_node); - else - return truthvalue_true_node; + break; } case COMPLEX_EXPR: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 44021f1cdd12..3394b20a873a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-08-11 Richard Guenther + + PR c/44555 + * gcc.c-torture/execute/pr44555.c: New testcase. + 2010-06-13 Uros Bizjak PR target/44481 diff --git a/gcc/testsuite/gcc.c-torture/execute/pr44555.c b/gcc/testsuite/gcc.c-torture/execute/pr44555.c new file mode 100644 index 000000000000..6ba8e491971d --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr44555.c @@ -0,0 +1,16 @@ +struct a { + char b[100]; +}; +int foo(struct a *a) +{ + if (&a->b) + return 1; + return 0; +} +extern void abort (void); +int main() +{ + if (foo((struct a *)0) != 0) + abort (); + return 0; +}