diff options
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r-- | gcc/cp/decl.c | 108 |
1 files changed, 49 insertions, 59 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 9244272..60938a7 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -45,7 +45,7 @@ Boston, MA 02111-1307, USA. */ #include "tm_p.h" #include "target.h" -extern int (*valid_lang_attribute) PARAMS ((tree, tree, tree, tree)); +extern const struct attribute_spec *lang_attribute_table; #ifndef BOOL_TYPE_SIZE /* `bool' has size and alignment `1', on all platforms. */ @@ -3438,7 +3438,7 @@ duplicate_decls (newdecl, olddecl) /* Copy all the DECL_... slots specified in the new decl except for any that we copy here from the old type. */ - DECL_MACHINE_ATTRIBUTES (newdecl) + DECL_ATTRIBUTES (newdecl) = (*targetm.merge_decl_attributes) (olddecl, newdecl); if (TREE_CODE (newdecl) == TEMPLATE_DECL) @@ -3746,7 +3746,7 @@ duplicate_decls (newdecl, olddecl) /* NEWDECL contains the merged attribute lists. Update OLDDECL to be the same. */ - DECL_MACHINE_ATTRIBUTES (olddecl) = DECL_MACHINE_ATTRIBUTES (newdecl); + DECL_ATTRIBUTES (olddecl) = DECL_ATTRIBUTES (newdecl); return 1; } @@ -6493,7 +6493,7 @@ init_decl_processing () /* Show we use EH for cleanups. */ using_eh_for_cleanups (); - valid_lang_attribute = cp_valid_lang_attribute; + lang_attribute_table = cp_attribute_table; /* Maintain consistency. Perhaps we should just complain if they say -fwritable-strings? */ @@ -6986,7 +6986,7 @@ shadow_tag (declspecs) if (TYPE_FIELDS (t)) { tree decl = grokdeclarator (NULL_TREE, declspecs, NORMAL, 0, - NULL_TREE); + NULL); finish_anon_union (decl); } } @@ -7002,7 +7002,7 @@ groktypename (typename) return typename; return grokdeclarator (TREE_VALUE (typename), TREE_PURPOSE (typename), - TYPENAME, 0, NULL_TREE); + TYPENAME, 0, NULL); } /* Decode a declarator in an ordinary declaration or data definition. @@ -7031,7 +7031,6 @@ start_decl (declarator, declspecs, initialized, attributes, prefix_attributes) tree context; extern int have_extern_spec; extern int used_extern_spec; - tree attrlist; #if 0 /* See code below that used this. */ @@ -7046,13 +7045,10 @@ start_decl (declarator, declspecs, initialized, attributes, prefix_attributes) used_extern_spec = 1; } - if (attributes || prefix_attributes) - attrlist = build_tree_list (attributes, prefix_attributes); - else - attrlist = NULL_TREE; + attributes = chainon (attributes, prefix_attributes); decl = grokdeclarator (declarator, declspecs, NORMAL, initialized, - attrlist); + &attributes); if (decl == NULL_TREE || TREE_CODE (decl) == VOID_TYPE) return NULL_TREE; @@ -7119,7 +7115,7 @@ start_decl (declarator, declspecs, initialized, attributes, prefix_attributes) } /* Set attributes here so if duplicate decl, will have proper attributes. */ - cplus_decl_attributes (&decl, attributes, prefix_attributes, 0); + cplus_decl_attributes (&decl, attributes, 0); if (context && COMPLETE_TYPE_P (complete_type (context))) { @@ -8482,7 +8478,7 @@ start_handler_parms (declspecs, declarator) if (declspecs) { decl = grokdeclarator (declarator, declspecs, CATCHPARM, - 1, NULL_TREE); + 1, NULL); if (decl == NULL_TREE) error ("invalid catch parameter"); } @@ -9425,8 +9421,9 @@ check_special_function_return_type (sfk, type, optype) BITFIELD for a field with specified width. INITIALIZED is 1 if the decl has an initializer. - ATTRLIST is a TREE_LIST node with prefix attributes in TREE_VALUE and - normal attributes in TREE_PURPOSE, or NULL_TREE. + ATTRLIST is a pointer to the list of attributes, which may be NULL + if there are none; *ATTRLIST may be modified if attributes from inside + the declarator should be applied to the declaration. In the TYPENAME case, DECLARATOR is really an abstract declarator. It may also be so in the PARM case, for a prototype where the @@ -9464,7 +9461,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) tree declarator; enum decl_context decl_context; int initialized; - tree attrlist; + tree *attrlist; { RID_BIT_TYPE specbits; int nclasses = 0; @@ -9487,7 +9484,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) int bitfield = 0; #if 0 /* See the code below that used this. */ - tree decl_machine_attr = NULL_TREE; + tree decl_attr = NULL_TREE; #endif /* Set this to error_mark_node for FIELD_DECLs we could not handle properly. All FIELD_DECLs we build here have `init' put into their DECL_INITIAL. */ @@ -9506,8 +9503,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) tree raises = NULL_TREE; int template_count = 0; tree in_namespace = NULL_TREE; - tree inner_attrs; - int ignore_attrs; + tree returned_attrs = NULL_TREE; RIDBIT_RESET_ALL (specbits); if (decl_context == FUNCDEF) @@ -9598,24 +9594,22 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) cp_finish_decl so we can get the variable initialized... */ - tree attributes, prefix_attributes; + tree attributes; *next = TREE_OPERAND (decl, 0); init = CALL_DECLARATOR_PARMS (decl); if (attrlist) { - attributes = TREE_PURPOSE (attrlist); - prefix_attributes = TREE_VALUE (attrlist); + attributes = *attrlist; } else { attributes = NULL_TREE; - prefix_attributes = NULL_TREE; } decl = start_decl (declarator, declspecs, 1, - attributes, prefix_attributes); + attributes, NULL_TREE); decl_type_access_control (decl); if (decl) { @@ -9953,7 +9947,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) type = TREE_TYPE (t); #if 0 /* See the code below that used this. */ - decl_machine_attr = DECL_MACHINE_ATTRIBUTES (id); + decl_attr = DECL_ATTRIBUTES (id); #endif typedef_decl = t; } @@ -10312,9 +10306,6 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) Descend through it, creating more complex types, until we reach the declared identifier (or NULL_TREE, in an absolute declarator). */ - inner_attrs = NULL_TREE; - ignore_attrs = 0; - while (declarator && TREE_CODE (declarator) != IDENTIFIER_NODE && TREE_CODE (declarator) != TEMPLATE_ID_EXPR) { @@ -10363,28 +10354,30 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) } } - /* See the comment for the TREE_LIST case, below. */ - if (ignore_attrs) - ignore_attrs = 0; - else if (inner_attrs) - { - decl_attributes (&type, inner_attrs, 0); - inner_attrs = NULL_TREE; - } - switch (TREE_CODE (declarator)) { case TREE_LIST: { /* We encode a declarator with embedded attributes using - a TREE_LIST. The attributes apply to the declarator - directly inside them, so we have to skip an iteration - before applying them to the type. If the declarator just - inside is the declarator-id, we apply the attrs to the - decl itself. */ - inner_attrs = TREE_PURPOSE (declarator); - ignore_attrs = 1; + a TREE_LIST. */ + tree attrs = TREE_PURPOSE (declarator); + tree inner_decl; declarator = TREE_VALUE (declarator); + inner_decl = declarator; + while (inner_decl != NULL_TREE + && TREE_CODE (inner_decl) == TREE_LIST) + inner_decl = TREE_VALUE (inner_decl); + int attr_flags = 0; + if (inner_decl == NULL_TREE + || TREE_CODE (inner_decl) == IDENTIFIER_NODE) + attr_flags |= (int) ATTR_FLAG_DECL_NEXT; + if (TREE_CODE (inner_decl) == CALL_EXPR) + attr_flags |= (int) ATTR_FLAG_FUNCTION_NEXT; + if (TREE_CODE (inner_decl) == ARRAY_REF) + attr_flags |= (int) ATTR_FLAG_ARRAY_NEXT; + returned_attrs = decl_attributes (&type, + chainon (returned_attrs, attrs), + attr_flags); } break; @@ -10883,15 +10876,12 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) } } - /* See the comment for the TREE_LIST case, above. */ - if (inner_attrs) + if (returned_attrs) { - if (! ignore_attrs) - decl_attributes (&type, inner_attrs, 0); - else if (attrlist) - TREE_VALUE (attrlist) = chainon (inner_attrs, TREE_VALUE (attrlist)); + if (attrlist) + *attrlist = chainon (returned_attrs, *attrlist); else - attrlist = build_tree_list (NULL_TREE, inner_attrs); + attrlist = &returned_attrs; } /* Now TYPE has the actual type. */ @@ -11302,8 +11292,8 @@ friend declaration requires class-key, i.e. `friend %#T'", return decl; #if 0 /* This clobbers the attrs stored in `decl' from `attrlist'. */ - /* The decl and setting of decl_machine_attr is also turned off. */ - decl = build_decl_attribute_variant (decl, decl_machine_attr); + /* The decl and setting of decl_attr is also turned off. */ + decl = build_decl_attribute_variant (decl, decl_attr); #endif /* [class.conv.ctor] @@ -11401,7 +11391,7 @@ friend declaration requires class-key, i.e. `friend %#T'", } t = do_friend (ctype, declarator, decl, - last_function_parms, attrlist, flags, quals, + last_function_parms, *attrlist, flags, quals, funcdef_flag); } if (t && funcdef_flag) @@ -11838,7 +11828,7 @@ grokparms (first_parm) break; decl = grokdeclarator (TREE_VALUE (decl), TREE_PURPOSE (decl), - PARM, init != NULL_TREE, NULL_TREE); + PARM, init != NULL_TREE, NULL); if (! decl || TREE_TYPE (decl) == error_mark_node) continue; @@ -13269,7 +13259,7 @@ start_function (declspecs, declarator, attrs, flags) } else { - decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, 1, NULL_TREE); + decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, 1, NULL); /* If the declarator is not suitable for a function definition, cause a syntax error. */ if (decl1 == NULL_TREE || TREE_CODE (decl1) != FUNCTION_DECL) return 0; @@ -13554,7 +13544,7 @@ start_function (declspecs, declarator, attrs, flags) pushlevel (0); current_binding_level->parm_flag = 1; - cplus_decl_attributes (&decl1, NULL_TREE, attrs, 0); + cplus_decl_attributes (&decl1, attrs, 0); /* Promote the value to int before returning it. */ if (c_promoting_integer_type_p (restype)) @@ -14056,7 +14046,7 @@ start_method (declspecs, declarator, attrlist) tree declarator, declspecs, attrlist; { tree fndecl = grokdeclarator (declarator, declspecs, MEMFUNCDEF, 0, - attrlist); + &attrlist); /* Something too ugly to handle. */ if (fndecl == NULL_TREE) |