From 59387d2e310983bced3bf86cb759a1dbc1520277 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Fri, 13 Jul 2001 21:40:43 +0100 Subject: c-common.c (decl_attributes): Take a pointer to the node to which attributes are to be attached... * c-common.c (decl_attributes): Take a pointer to the node to which attributes are to be attached, and a flags argument. * c-common.h (enum attribute_flags): New. (decl_attributes): Update prototype. * c-decl.c (start_decl, push_parm_decl, finish_struct, finish_enum, start_function): Update calls to decl_attributes. * c-parse.in (component_declarator, component_notype_declarator, label): Update calls to decl_attributes. cp: * decl2.c (cplus_decl_attributes): Take a pointer to the node to which attributes are to be attached, and a flags argument. Update call to decl_attributes. (grokfield): Update call to decl_attributes. * class.c (finish_struct): Update call to cplus_decl_attributes. * cp-tree.h (cplus_decl_attributes): Update prototype. * decl.c (start_decl, grokdeclarator, start_function): Update calls to decl_attributes and cplus_decl_attributes. * friend.c (do_friend): Update call to cplus_decl_attributes. * parse.y (parse_bitfield): Update call to cplus_decl_attributes. From-SVN: r43995 --- gcc/c-common.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'gcc/c-common.c') diff --git a/gcc/c-common.c b/gcc/c-common.c index 0213843..751ba26 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -723,12 +723,19 @@ default_valid_lang_attribute (attr_name, attr_args, decl, type) int (*valid_lang_attribute) PARAMS ((tree, tree, tree, tree)) = default_valid_lang_attribute; -/* Process the attributes listed in ATTRIBUTES and install them in NODE, - which is either a DECL (including a TYPE_DECL) or a TYPE. */ +/* Process the attributes listed in ATTRIBUTES and install them in *NODE, + which is either a DECL (including a TYPE_DECL) or a TYPE. If a DECL, + it should be modified in place; if a TYPE, a copy should be created. + FLAGS gives further information, in the form of a bitwise OR of flags + in enum attribute_flags from c-common.h. Depending on these flags, + some attributes may be returned to be applied at a later stage (for + example, to apply a decl attribute to the declaration rather than to + its type). */ -void -decl_attributes (node, attributes) - tree node, attributes; +tree +decl_attributes (node, attributes, flags) + tree *node, attributes; + int flags ATTRIBUTE_UNUSED; { tree decl = 0, type = 0; int is_type = 0; @@ -737,16 +744,16 @@ decl_attributes (node, attributes) if (attrtab_idx == 0) init_attributes (); - if (DECL_P (node)) + if (DECL_P (*node)) { - decl = node; + decl = *node; type = TREE_TYPE (decl); - is_type = TREE_CODE (node) == TYPE_DECL; + is_type = TREE_CODE (*node) == TYPE_DECL; } - else if (TYPE_P (node)) - type = node, is_type = 1; + else if (TYPE_P (*node)) + type = *node, is_type = 1; - (*targetm.insert_attributes) (node, &attributes); + (*targetm.insert_attributes) (*node, &attributes); for (a = attributes; a; a = TREE_CHAIN (a)) { @@ -979,16 +986,16 @@ decl_attributes (node, attributes) else if (DECL_SECTION_NAME (decl) != NULL_TREE && strcmp (TREE_STRING_POINTER (DECL_SECTION_NAME (decl)), TREE_STRING_POINTER (TREE_VALUE (args))) != 0) - error_with_decl (node, + error_with_decl (*node, "section of `%s' conflicts with previous declaration"); else DECL_SECTION_NAME (decl) = TREE_VALUE (args); } else - error_with_decl (node, + error_with_decl (*node, "section attribute not allowed for `%s'"); #else - error_with_decl (node, + error_with_decl (*node, "section attributes are not supported for this target"); #endif break; @@ -1140,6 +1147,7 @@ decl_attributes (node, attributes) break; } } + return NULL_TREE; } /* Split SPECS_ATTRS, a list of declspecs and prefix attributes, into two -- cgit v1.1