aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-inline.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2005-10-12 16:34:09 -0700
committerRichard Henderson <rth@gcc.gnu.org>2005-10-12 16:34:09 -0700
commit52dd234b210c06bea54ef726995e1fce035329be (patch)
treee0ba09b20b9401b57ddfd7bb96ac65cafde86a0b /gcc/tree-inline.c
parent6deb03391308dcffb9bb4a4155cd27d7e60329f9 (diff)
downloadgcc-52dd234b210c06bea54ef726995e1fce035329be.zip
gcc-52dd234b210c06bea54ef726995e1fce035329be.tar.gz
gcc-52dd234b210c06bea54ef726995e1fce035329be.tar.bz2
re PR c/24255 (__transparent_union__ mishandled)
PR c/24255 * tree.h (DECL_TRANSPARENT_UNION): Remove. * function.c (assign_parm_find_data_types): Don't support it. * print-tree.c (print_node): Likewise. * c-common.c (handle_transparent_union_attribute): Likewise. Use build_duplicate_type. * tree-inline.c (remap_type_1): Split out of remap_type; properly remap aggregate fields. (build_duplicate_type): New. * doc/extend.texi (Variable Attributes): Remove documentation for transparent_union. From-SVN: r105338
Diffstat (limited to 'gcc/tree-inline.c')
-rw-r--r--gcc/tree-inline.c74
1 files changed, 56 insertions, 18 deletions
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index f22785c..0f7ea97 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -257,26 +257,10 @@ remap_decl (tree decl, inline_data *id)
}
static tree
-remap_type (tree type, inline_data *id)
+remap_type_1 (tree type, inline_data *id)
{
- splay_tree_node node;
tree new, t;
- if (type == NULL)
- return type;
-
- /* See if we have remapped this type. */
- node = splay_tree_lookup (id->decl_map, (splay_tree_key) type);
- if (node)
- return (tree) node->value;
-
- /* The type only needs remapping if it's variably modified. */
- if (! variably_modified_type_p (type, id->callee))
- {
- insert_decl_map (id, type, type);
- return type;
- }
-
/* We do need a copy. build and register it now. If this is a pointer or
reference type, remap the designated type and make a new pointer or
reference type. */
@@ -353,7 +337,18 @@ remap_type (tree type, inline_data *id)
case RECORD_TYPE:
case UNION_TYPE:
case QUAL_UNION_TYPE:
- walk_tree (&TYPE_FIELDS (new), copy_body_r, id, NULL);
+ {
+ tree f, nf = NULL;
+
+ for (f = TYPE_FIELDS (new); f ; f = TREE_CHAIN (f))
+ {
+ t = remap_decl (f, id);
+ DECL_CONTEXT (t) = new;
+ TREE_CHAIN (t) = nf;
+ nf = t;
+ }
+ TYPE_FIELDS (new) = nreverse (nf);
+ }
break;
case OFFSET_TYPE:
@@ -369,6 +364,29 @@ remap_type (tree type, inline_data *id)
}
static tree
+remap_type (tree type, inline_data *id)
+{
+ splay_tree_node node;
+
+ if (type == NULL)
+ return type;
+
+ /* See if we have remapped this type. */
+ node = splay_tree_lookup (id->decl_map, (splay_tree_key) type);
+ if (node)
+ return (tree) node->value;
+
+ /* The type only needs remapping if it's variably modified. */
+ if (! variably_modified_type_p (type, id->callee))
+ {
+ insert_decl_map (id, type, type);
+ return type;
+ }
+
+ return remap_type_1 (type, id);
+}
+
+static tree
remap_decls (tree decls, inline_data *id)
{
tree old_var;
@@ -2959,3 +2977,23 @@ inlining_p (inline_data * id)
{
return (!id->saving_p && !id->cloning_p && !id->versioning_p);
}
+
+/* Duplicate a type, fields and all. */
+
+tree
+build_duplicate_type (tree type)
+{
+ inline_data id;
+
+ memset (&id, 0, sizeof (id));
+ id.callee = current_function_decl;
+ id.caller = current_function_decl;
+ id.callee_cfun = cfun;
+ id.decl_map = splay_tree_new (splay_tree_compare_pointers, NULL, NULL);
+
+ type = remap_type_1 (type, &id);
+
+ splay_tree_delete (id.decl_map);
+
+ return type;
+}