]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/44555 (Pointer evalutions, is that expected ?)
authorRichard Guenther <rguenther@suse.de>
Wed, 11 Aug 2010 12:59:47 +0000 (12:59 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 11 Aug 2010 12:59:47 +0000 (12:59 +0000)
2010-08-11  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: r163098

gcc/ChangeLog
gcc/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr44555.c [new file with mode: 0644]

index 48cb95ea00a7c47af8d171d033c1e49c83ead4fe..bec37a0c9b45aee3b95f089e9e6b340ea42e77b1 100644 (file)
@@ -1,3 +1,9 @@
+2010-08-11  Richard Guenther  <rguenther@suse.de>
+
+       PR c/44555
+       * c-common.c (c_common_truthvalue_conversion): Remove
+       premature and wrong optimization concering ADDR_EXPRs.
+
 2010-08-10  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
 
        PR boehm-gc/34544
index 4b2ee065ad9c9749e2e9e070f8215413ad8552d0..e809332c7904e0a929cd6e2892a171f1c2982b15 100644 (file)
@@ -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:
index 44021f1cdd12f1aec53dbc419c0ebc142d7873c8..3394b20a873acb25c64c234a2ebb28cf72f9bfc4 100644 (file)
@@ -1,3 +1,8 @@
+2010-08-11  Richard Guenther  <rguenther@suse.de>
+
+       PR c/44555
+       * gcc.c-torture/execute/pr44555.c: New testcase.
+
 2010-06-13  Uros Bizjak  <ubizjak@gmail.com>
 
        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 (file)
index 0000000..6ba8e49
--- /dev/null
@@ -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;
+}