aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2003-08-20 08:24:18 -0400
committerJason Merrill <jason@gcc.gnu.org>2003-08-20 08:24:18 -0400
commit3acef2ae63e40303a73a7559939689c397c0450d (patch)
tree5de64ab02077a2ceccd6dd2c4e277f161bd8ac99
parent8f7d850c97a24f9809bfc3f9505d508e8b011000 (diff)
downloadgcc-3acef2ae63e40303a73a7559939689c397c0450d.zip
gcc-3acef2ae63e40303a73a7559939689c397c0450d.tar.gz
gcc-3acef2ae63e40303a73a7559939689c397c0450d.tar.bz2
stor-layout.c (do_type_align): Only copy DECL_USER_ALIGN from TYPE_USER_ALIGN for FIELD_DECLs.
* stor-layout.c (do_type_align): Only copy DECL_USER_ALIGN from TYPE_USER_ALIGN for FIELD_DECLs. * attribs.c (decl_attributes): Rebuild the function pointer type after changing the target type. * tree.c (get_qualified_type): Also check that the attributes match. From-SVN: r70597
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/attribs.c29
-rw-r--r--gcc/stor-layout.c3
-rw-r--r--gcc/tree.c3
4 files changed, 39 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1cc883a..ff2a9f7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2003-08-20 Jason Merrill <jason@redhat.com>
+
+ * stor-layout.c (do_type_align): Only copy DECL_USER_ALIGN from
+ TYPE_USER_ALIGN for FIELD_DECLs.
+
+ * attribs.c (decl_attributes): Rebuild the function pointer type after
+ changing the target type.
+ * tree.c (get_qualified_type): Also check that the attributes match.
+
2003-08-19 Matt Kraai <kraai@alumni.cmu.edu>
* Makefile.in (STAGESTUFF): Move cc1obj$(exeext) from here ...
diff --git a/gcc/attribs.c b/gcc/attribs.c
index 38a4308..a40fea7 100644
--- a/gcc/attribs.c
+++ b/gcc/attribs.c
@@ -154,6 +154,7 @@ decl_attributes (tree *node, tree attributes, int flags)
tree *anode = node;
const struct attribute_spec *spec = NULL;
bool no_add_attrs = 0;
+ tree fn_ptr_tmp = NULL_TREE;
size_t i;
for (i = 0; i < ARRAY_SIZE (attribute_tables); i++)
@@ -222,9 +223,18 @@ decl_attributes (tree *node, tree attributes, int flags)
&& (TREE_CODE (TREE_TYPE (*anode)) == FUNCTION_TYPE
|| TREE_CODE (TREE_TYPE (*anode)) == METHOD_TYPE))
{
- if (!(flags & (int) ATTR_FLAG_TYPE_IN_PLACE))
- *anode = build_type_copy (*anode);
- anode = &TREE_TYPE (*anode);
+ /* OK, this is a bit convoluted. We can't just make a copy
+ of the pointer type and modify its TREE_TYPE, because if
+ we change the attributes of the target type the pointer
+ type needs to have a different TYPE_MAIN_VARIANT. So we
+ pull out the target type now, frob it as appropriate, and
+ rebuild the pointer type later.
+
+ This would all be simpler if attributes were part of the
+ declarator, grumble grumble. */
+ fn_ptr_tmp = TREE_TYPE (*anode);
+ anode = &fn_ptr_tmp;
+ flags &= ~(int) ATTR_FLAG_TYPE_IN_PLACE;
}
else if (flags & (int) ATTR_FLAG_FUNCTION_NEXT)
{
@@ -291,6 +301,19 @@ decl_attributes (tree *node, tree attributes, int flags)
old_attrs));
}
}
+
+ if (fn_ptr_tmp)
+ {
+ /* Rebuild the function pointer type and put it in the
+ appropriate place. */
+ fn_ptr_tmp = build_pointer_type (fn_ptr_tmp);
+ if (DECL_P (*node))
+ TREE_TYPE (*node) = fn_ptr_tmp;
+ else if (TREE_CODE (*node) == POINTER_TYPE)
+ *node = fn_ptr_tmp;
+ else
+ abort ();
+ }
}
return returned_attrs;
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index 54e6a56..afd830d 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -344,7 +344,8 @@ do_type_align (tree type, tree decl)
if (TYPE_ALIGN (type) > DECL_ALIGN (decl))
{
DECL_ALIGN (decl) = TYPE_ALIGN (type);
- DECL_USER_ALIGN (decl) = TYPE_USER_ALIGN (type);
+ if (TREE_CODE (decl) == FIELD_DECL)
+ DECL_USER_ALIGN (decl) = TYPE_USER_ALIGN (type);
}
}
diff --git a/gcc/tree.c b/gcc/tree.c
index 8418767..3bae512 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -2849,7 +2849,8 @@ get_qualified_type (tree type, int type_quals)
preserve the TYPE_NAME, since there is code that depends on this. */
for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t))
if (TYPE_QUALS (t) == type_quals && TYPE_NAME (t) == TYPE_NAME (type)
- && TYPE_CONTEXT (t) == TYPE_CONTEXT (type))
+ && TYPE_CONTEXT (t) == TYPE_CONTEXT (type)
+ && attribute_list_equal (TYPE_ATTRIBUTES (t), TYPE_ATTRIBUTES (type)))
return t;
return NULL_TREE;