diff options
author | Richard Guenther <rguenther@suse.de> | 2010-06-16 14:11:03 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2010-06-16 14:11:03 +0000 |
commit | 33766b66e131cbab54238cbecb8b8c669565deff (patch) | |
tree | 63916a1fbe023b77d6796bff4194bbf6922091c3 | |
parent | 3e15518bc4c70b541b667e9f6bf3dfb80053b5ae (diff) | |
download | gcc-33766b66e131cbab54238cbecb8b8c669565deff.zip gcc-33766b66e131cbab54238cbecb8b8c669565deff.tar.gz gcc-33766b66e131cbab54238cbecb8b8c669565deff.tar.bz2 |
re PR c/44555 (Pointer evalutions, is that expected ?)
2010-06-16 Richard Guenther <rguenther@suse.de>
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: r160836
-rw-r--r-- | gcc/c-family/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c-family/c-common.c | 18 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/pr44555.c | 16 |
4 files changed, 28 insertions, 17 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 41b73b8..433d699 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2010-06-16 Richard Guenther <rguenther@suse.de> + + PR c/44555 + * c-common.c (c_common_truthvalue_conversion): Remove + premature and wrong optimization concering ADDR_EXPRs. + 2010-06-15 Arnaud Charlet <charlet@adacore.com> * c-ada-spec.c (dump_sloc): Remove column info. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index f1dfe71..63cd728 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -3825,23 +3825,7 @@ c_common_truthvalue_conversion (location_t location, 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)) - { - expr = build2 (COMPOUND_EXPR, truthvalue_type_node, - inner, truthvalue_true_node); - goto ret; - } - else - return truthvalue_true_node; + break; } case COMPLEX_EXPR: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 931f91d..e58ee40 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-06-16 Richard Guenther <rguenther@suse.de> + + PR c/44555 + * gcc.c-torture/execute/pr44555.c: New testcase. + 2010-06-16 Janus Weil <janus@gcc.gnu.org> PR fortran/44549 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 0000000..6ba8e49 --- /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; +} |