summaryrefslogtreecommitdiff
path: root/gcc/attribs.c
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2003-08-20 12:24:18 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2003-08-20 12:24:18 +0000
commit79bdd5ffbdff5ef603a8d4ddac847c6cf0784592 (patch)
tree5de64ab02077a2ceccd6dd2c4e277f161bd8ac99 /gcc/attribs.c
parent7d299f3d716100d684ee81beeb2bb0086b575579 (diff)
downloadgcc-79bdd5ffbdff5ef603a8d4ddac847c6cf0784592.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@70597 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/attribs.c')
-rw-r--r--gcc/attribs.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/gcc/attribs.c b/gcc/attribs.c
index 38a4308bdaa..a40fea7e761 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;