re PR middle-end/46844 (regrename.c:312:22: error: unused parameter 'reg')
authorRichard Guenther <rguenther@suse.de>
Thu, 9 Dec 2010 17:00:19 +0000 (17:00 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 9 Dec 2010 17:00:19 +0000 (17:00 +0000)
2010-12-09  Richard Guenther  <rguenther@suse.de>

PR middle-end/46844
* gimple-fold.c (canonicalize_constructor_val): Canonicalize
addresses.

* gcc.c-torture/compile/pr46866.c: New testcase.

From-SVN: r167649

gcc/ChangeLog
gcc/gimple-fold.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr46866.c [new file with mode: 0644]

index 29c1c32ba83e36142900cb90aa49e9c9f2ba47c3..9dec6e7132728b9da38f70674ccb65448a6fd5ec 100644 (file)
@@ -1,3 +1,9 @@
+2010-12-09  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/46844
+       * gimple-fold.c (canonicalize_constructor_val): Canonicalize
+       addresses.
+
 2010-12-09  Joseph Myers  <joseph@codesourcery.com>
 
        * config/i386/netware.h (TARGET_POSIX_IO): Define.
index ae4771c903a052fa5183dbed2a57b0c7221cf6ae..ba51ee8d853bf90b7ad16c51eeebcb0670d836d8 100644 (file)
@@ -132,6 +132,10 @@ canonicalize_constructor_val (tree cval)
        return NULL_TREE;
       if (base && TREE_CODE (base) == VAR_DECL)
        add_referenced_var (base);
+      /* We never have the chance to fixup types in global initializers
+         during gimplification.  Do so here.  */
+      if (TREE_TYPE (TREE_TYPE (cval)) != TREE_TYPE (TREE_OPERAND (cval, 0)))
+       cval = build_fold_addr_expr (TREE_OPERAND (cval, 0));
     }
   return cval;
 }
index ae01a31ee10474d0c46306390cdf59236410da70..e1317fb5045db2a3030e6ddd4f4b91d0bef5d143 100644 (file)
@@ -1,3 +1,8 @@
+2010-12-09  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/46844
+       * gcc.c-torture/compile/pr46866.c: New testcase.
+
 2010-12-09  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
 
        PR testsuite/45068
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr46866.c b/gcc/testsuite/gcc.c-torture/compile/pr46866.c
new file mode 100644 (file)
index 0000000..4941148
--- /dev/null
@@ -0,0 +1,19 @@
+extern void *malloc(__SIZE_TYPE__);
+typedef struct T T;
+struct T {
+    void (*destroy)(void *);
+};
+void destroy(union { void *this; } __attribute__((transparent_union)));
+static const typeof(destroy) *_destroy  = (const typeof(destroy)*)destroy;
+void destroy(void *this);
+static T *create_empty(void)
+{
+  T *this = malloc(sizeof(*this));
+  *this = (typeof(*this)){ _destroy };
+  return this;
+}
+void openssl_crl_load(void)
+{
+  T *this = create_empty();
+  destroy(this);
+}