aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2001-05-30 08:44:56 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2001-05-30 08:44:56 +0000
commite97c94888969b416c239fcaa027770d9b0157323 (patch)
tree8ba2f374e395671acbd26e6ad707d17c8c1f9df2 /gcc
parentb86ee4a56ded8c3a4090f7eff5b3efd0f95e4bde (diff)
downloadgcc-e97c94888969b416c239fcaa027770d9b0157323.zip
gcc-e97c94888969b416c239fcaa027770d9b0157323.tar.gz
gcc-e97c94888969b416c239fcaa027770d9b0157323.tar.bz2
re PR c++/2936 (gcc gives me an internal error when compiling mozilla with --enable-optimization="-O3")
cp: PR g++/2936 * decl.c (finish_anon_union): Copy context. * optimize.c (remap_decl): Remap anonymous aggregate members too. testsuite: * g++.old-deja/g++.other/optimize3.C: New file. From-SVN: r42705
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/optimize.c23
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/optimize3.C38
4 files changed, 69 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 2792f45..e78635c 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2001-05-30 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR g++/2936
+ * decl.c (finish_anon_union): Copy context.
+ * optimize.c (remap_decl): Remap anonymous aggregate members too.
+
2001-05-26 Nathan Sidwell <nathan@codesourcery.com>
PR g++/2823
diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c
index f81d7e3..8676dd8 100644
--- a/gcc/cp/optimize.c
+++ b/gcc/cp/optimize.c
@@ -106,8 +106,7 @@ static void update_cloned_parm PARAMS ((tree, tree));
decisions about when a function is too big to inline. */
#define INSNS_PER_STMT (10)
-/* Remap DECL during the copying of the BLOCK tree for the function.
- DATA is really an `inline_data *'. */
+/* Remap DECL during the copying of the BLOCK tree for the function. */
static tree
remap_decl (decl, id)
@@ -149,6 +148,26 @@ remap_decl (decl, id)
copy_body_r, id, NULL);
}
+ if (!DECL_NAME (t) && TREE_TYPE (t)
+ && ANON_AGGR_TYPE_P (TREE_TYPE ((t))))
+ {
+ /* For a VAR_DECL of anonymous type, we must also copy the
+ member VAR_DECLS here and rechain the
+ DECL_ANON_UNION_ELEMS. */
+ tree members = NULL;
+ tree src;
+
+ for (src = DECL_ANON_UNION_ELEMS (t); src;
+ src = TREE_CHAIN (src))
+ {
+ tree member = remap_decl (TREE_VALUE (src), id);
+
+ my_friendly_assert (!TREE_PURPOSE (src), 20010529);
+ members = tree_cons (NULL, member, members);
+ }
+ DECL_ANON_UNION_ELEMS (t) = nreverse (members);
+ }
+
/* Remember it, so that if we encounter this local entity
again we can reuse this copy. */
n = splay_tree_insert (id->decl_map,
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 49d5a43..c5126b7 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2001-05-30 Nathan Sidwell <nathan@codesourcery.com>
+
+ * g++.old-deja/g++.other/optimize3.C: New file.
+
2001-05-29 Jeffrey Oldham <oldham@codesourcery.com>
* gcc.c-torture/compile/20010518-2.x: New file to compile, not
diff --git a/gcc/testsuite/g++.old-deja/g++.other/optimize3.C b/gcc/testsuite/g++.old-deja/g++.other/optimize3.C
new file mode 100644
index 0000000..737aabb
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.other/optimize3.C
@@ -0,0 +1,38 @@
+// Special g++ Options: -O2
+//
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 29 May 2001 <nathan@codesourcery.com>
+
+// Bug 2936. We ICE'd on tree inlining a function with an anonymous
+// union decl.
+
+inline const unsigned char *Foo (const char *string)
+{
+ union
+ {
+ const char *p1;
+ const unsigned char *p2;
+ };
+ p1 = 0;
+ p2 = 0;
+
+
+ p1 = string;
+ return p2;
+
+}
+
+const unsigned char *Baz (const char *string)
+{
+ return Foo (string);
+}
+
+int main ()
+{
+ const char *string = "s";
+ const unsigned char *result;
+
+ result = Baz (string);
+ return (static_cast <const void *> (result)
+ != static_cast <const void *> (string));
+}