From f7a4cec096b0476bbe39b44fbe3391d11f598728 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Sun, 8 Jul 2001 20:58:19 +0100 Subject: [PATCH] c-common.c (decl_attributes): Only take a single attributes parameter. * c-common.c (decl_attributes): Only take a single attributes parameter. * c-common.h (decl_attributes): Update prototype. * c-decl.c (start_decl, start_function): Only take a single attributes parameter. Update calls to decl_attributes. (finish_struct, finish_enum): Update calls to decl_attributes. (push_parm_decl): Expect unified list of attributes. Update call to decl_attributes. * c-parse.in (fndef, initdcl, notype_initdcl, nested_function, notype_nested_function, component_declarator, component_notype_declarator, label): Update calls to decl_attributes. (absdcl_maybe_attribute, parm, firstparm, myparm): Unify attribute lists that are passed to push_parm_decl. * c-tree.h (start_function, start_decl): Update prototypes. * config/sh/sh-protos.h, config/sh/sh.c (sh_pragma_insert_attributes): Only take a single attributes parameter. * config/sh/sh.h (PRAGMA_INSERT_ATTRIBUTES): Likewise. * doc/tm.texi (INSERT_ATTRIBUTES): Update. * objc/objc-act.c (define_decl, generate_objc_symtab_decl, build_module_descriptor, generate_static_references, generate_strings, build_selector_translation_table, generate_descriptor_table, generate_protocols, generate_ivars_list, generate_dispatch_table, generate_protocol_list, generate_category, generate_shared_structures, really_start_method, add_objc_decls, generate_classref_translation_entry): Update calls to start_decl and start_function. (build_tmp_function_decl, start_method_def): Unify attribute lists that are passed to push_parm_decl. cp: * decl.c (grokdeclarator), decl2.c (cplus_decl_attributes): Update calls to decl_attributes. testsuite: * gcc.c-torture/compile/20010701-1.c, g++.old-deja/g++.ext/attrib6.C: New tests. From-SVN: r43850 --- gcc/ChangeLog | 34 ++++++++++ gcc/c-common.c | 16 ++--- gcc/c-common.h | 2 +- gcc/c-decl.c | 21 +++--- gcc/c-parse.in | 65 ++++++++----------- gcc/c-tree.h | 5 +- gcc/config/sh/sh-protos.h | 2 +- gcc/config/sh/sh.c | 3 +- gcc/config/sh/sh.h | 4 +- gcc/cp/ChangeLog | 5 ++ gcc/cp/decl.c | 4 +- gcc/cp/decl2.c | 2 +- gcc/doc/tm.texi | 10 +-- gcc/objc/objc-act.c | 56 ++++++++-------- gcc/testsuite/ChangeLog | 5 ++ gcc/testsuite/g++.old-deja/g++.ext/attrib6.C | 6 ++ .../gcc.c-torture/compile/20010701-1.c | 5 ++ 17 files changed, 142 insertions(+), 103 deletions(-) create mode 100644 gcc/testsuite/g++.old-deja/g++.ext/attrib6.C create mode 100644 gcc/testsuite/gcc.c-torture/compile/20010701-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 066f66cde2a..9269546037d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,37 @@ +2001-07-08 Joseph S. Myers + + * c-common.c (decl_attributes): Only take a single attributes + parameter. + * c-common.h (decl_attributes): Update prototype. + * c-decl.c (start_decl, start_function): Only take a single + attributes parameter. Update calls to decl_attributes. + (finish_struct, finish_enum): Update calls to decl_attributes. + (push_parm_decl): Expect unified list of attributes. Update call + to decl_attributes. + * c-parse.in (fndef, initdcl, notype_initdcl, nested_function, + notype_nested_function, component_declarator, + component_notype_declarator, label): Update calls to + decl_attributes. + (absdcl_maybe_attribute, parm, firstparm, myparm): Unify attribute + lists that are passed to push_parm_decl. + * c-tree.h (start_function, start_decl): Update prototypes. + * config/sh/sh-protos.h, config/sh/sh.c + (sh_pragma_insert_attributes): Only take a single attributes + parameter. + * config/sh/sh.h (PRAGMA_INSERT_ATTRIBUTES): Likewise. + * doc/tm.texi (INSERT_ATTRIBUTES): Update. + * objc/objc-act.c (define_decl, generate_objc_symtab_decl, + build_module_descriptor, generate_static_references, + generate_strings, build_selector_translation_table, + generate_descriptor_table, generate_protocols, + generate_ivars_list, generate_dispatch_table, + generate_protocol_list, generate_category, + generate_shared_structures, really_start_method, add_objc_decls, + generate_classref_translation_entry): Update calls to start_decl + and start_function. + (build_tmp_function_decl, start_method_def): Unify attribute lists + that are passed to push_parm_decl. + 2001-07-08 Neil Booth * final.c (no_asm_to_stream): New. diff --git a/gcc/c-common.c b/gcc/c-common.c index f398599138d..2d56b9e4234 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -722,14 +722,12 @@ 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 PREFIX_ATTRIBUTES - and install them in NODE, which is either a DECL (including a TYPE_DECL) - or a TYPE. PREFIX_ATTRIBUTES can appear after the declaration specifiers - and declaration modifiers but before the declaration proper. */ +/* Process the attributes listed in ATTRIBUTES and install them in NODE, + which is either a DECL (including a TYPE_DECL) or a TYPE. */ void -decl_attributes (node, attributes, prefix_attributes) - tree node, attributes, prefix_attributes; +decl_attributes (node, attributes) + tree node, attributes; { tree decl = 0, type = 0; int is_type = 0; @@ -752,15 +750,13 @@ decl_attributes (node, attributes, prefix_attributes) allow it to do so. Do this before allowing machine back ends to insert attributes, so that they have the opportunity to override anything done here. */ - PRAGMA_INSERT_ATTRIBUTES (node, & attributes, & prefix_attributes); + PRAGMA_INSERT_ATTRIBUTES (node, & attributes); #endif #ifdef INSERT_ATTRIBUTES - INSERT_ATTRIBUTES (node, & attributes, & prefix_attributes); + INSERT_ATTRIBUTES (node, & attributes); #endif - attributes = chainon (prefix_attributes, attributes); - for (a = attributes; a; a = TREE_CHAIN (a)) { tree name = TREE_PURPOSE (a); diff --git a/gcc/c-common.h b/gcc/c-common.h index 147ffa41eaa..eac227e48d2 100644 --- a/gcc/c-common.h +++ b/gcc/c-common.h @@ -498,7 +498,7 @@ extern void finish_fname_decls PARAMS ((void)); extern const char *fname_as_string PARAMS ((int)); extern tree fname_decl PARAMS ((unsigned, tree)); extern const char *fname_string PARAMS ((unsigned)); -extern void decl_attributes PARAMS ((tree, tree, tree)); +extern void decl_attributes PARAMS ((tree, tree)); extern void init_function_format_info PARAMS ((void)); extern void check_function_format PARAMS ((int *, tree, tree, tree)); extern void set_Wformat PARAMS ((int)); diff --git a/gcc/c-decl.c b/gcc/c-decl.c index deb47d174a6..eba9ee6295a 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -3336,10 +3336,10 @@ groktypename_in_parm_context (typename) grokfield and not through here. */ tree -start_decl (declarator, declspecs, initialized, attributes, prefix_attributes) +start_decl (declarator, declspecs, initialized, attributes) tree declarator, declspecs; int initialized; - tree attributes, prefix_attributes; + tree attributes; { register tree decl = grokdeclarator (declarator, declspecs, NORMAL, initialized); @@ -3452,7 +3452,7 @@ start_decl (declarator, declspecs, initialized, attributes, prefix_attributes) #endif /* Set attributes here so if duplicate decl, will have proper attributes. */ - decl_attributes (decl, attributes, prefix_attributes); + decl_attributes (decl, attributes); /* Add this decl to the current binding level. TEM may equal DECL or it may be a previous decl of the same name. */ @@ -3716,8 +3716,7 @@ push_parm_decl (parm) decl = grokdeclarator (TREE_VALUE (TREE_PURPOSE (parm)), TREE_PURPOSE (TREE_PURPOSE (parm)), PARM, 0); - decl_attributes (decl, TREE_VALUE (TREE_VALUE (parm)), - TREE_PURPOSE (TREE_VALUE (parm))); + decl_attributes (decl, TREE_VALUE (parm)); #if 0 if (DECL_NAME (decl)) @@ -5345,7 +5344,7 @@ finish_struct (t, fieldlist, attributes) TYPE_SIZE (t) = 0; - decl_attributes (t, attributes, NULL_TREE); + decl_attributes (t, attributes); /* Nameless union parm types are useful as GCC extension. */ if (! (TREE_CODE (t) == UNION_TYPE && TYPE_NAME (t) == 0) && !pedantic) @@ -5709,7 +5708,7 @@ finish_enum (enumtype, values, attributes) if (in_parm_level_p ()) warning ("enum defined inside parms"); - decl_attributes (enumtype, attributes, NULL_TREE); + decl_attributes (enumtype, attributes); /* Calculate the maximum value of any enumerator in this type. */ @@ -5893,7 +5892,7 @@ build_enumerator (name, value) /* Create the FUNCTION_DECL for a function definition. - DECLSPECS, DECLARATOR, PREFIX_ATTRIBUTES and ATTRIBUTES are the parts of + DECLSPECS, DECLARATOR and ATTRIBUTES are the parts of the declaration; they describe the function's name and the type it returns, but twisted together in a fashion that parallels the syntax of C. @@ -5905,8 +5904,8 @@ build_enumerator (name, value) yyparse to report a parse error. */ int -start_function (declspecs, declarator, prefix_attributes, attributes) - tree declarator, declspecs, prefix_attributes, attributes; +start_function (declspecs, declarator, attributes) + tree declarator, declspecs, attributes; { tree decl1, old_decl; tree restype; @@ -5933,7 +5932,7 @@ start_function (declspecs, declarator, prefix_attributes, attributes) return 0; } - decl_attributes (decl1, prefix_attributes, attributes); + decl_attributes (decl1, attributes); announce_function (decl1); diff --git a/gcc/c-parse.in b/gcc/c-parse.in index 9a7fe1cd34f..ad2d5f7f13d 100644 --- a/gcc/c-parse.in +++ b/gcc/c-parse.in @@ -378,7 +378,7 @@ datadef: fndef: declspecs_ts setspecs declarator { if (! start_function (current_declspecs, $3, - prefix_attributes, NULL_TREE)) + prefix_attributes)) YYERROR1; } old_style_parm_decls @@ -396,7 +396,7 @@ fndef: declspec_stack = TREE_CHAIN (declspec_stack); } | declspecs_nots setspecs notype_declarator { if (! start_function (current_declspecs, $3, - prefix_attributes, NULL_TREE)) + prefix_attributes)) YYERROR1; } old_style_parm_decls @@ -414,7 +414,7 @@ fndef: declspec_stack = TREE_CHAIN (declspec_stack); } | setspecs notype_declarator { if (! start_function (NULL_TREE, $2, - prefix_attributes, NULL_TREE)) + prefix_attributes)) YYERROR1; } old_style_parm_decls @@ -1436,7 +1436,7 @@ maybeasm: initdcl: declarator maybeasm maybe_attribute '=' { $$ = start_decl ($1, current_declspecs, 1, - $3, prefix_attributes); + chainon ($3, prefix_attributes)); start_init ($$, $2, global_bindings_p ()); } init /* Note how the declaration of the variable is in effect while its init is parsed! */ @@ -1444,7 +1444,7 @@ initdcl: finish_decl ($5, $6, $2); } | declarator maybeasm maybe_attribute { tree d = start_decl ($1, current_declspecs, 0, - $3, prefix_attributes); + chainon ($3, prefix_attributes)); finish_decl (d, NULL_TREE, $2); } ; @@ -1452,7 +1452,7 @@ initdcl: notype_initdcl: notype_declarator maybeasm maybe_attribute '=' { $$ = start_decl ($1, current_declspecs, 1, - $3, prefix_attributes); + chainon ($3, prefix_attributes)); start_init ($$, $2, global_bindings_p ()); } init /* Note how the declaration of the variable is in effect while its init is parsed! */ @@ -1460,7 +1460,7 @@ notype_initdcl: finish_decl ($5, $6, $2); } | notype_declarator maybeasm maybe_attribute { tree d = start_decl ($1, current_declspecs, 0, - $3, prefix_attributes); + chainon ($3, prefix_attributes)); finish_decl (d, NULL_TREE, $2); } ; /* the * rules are dummies to accept the Apollo extended syntax @@ -1594,7 +1594,7 @@ nested_function: push_function_context (); if (! start_function (current_declspecs, $1, - prefix_attributes, NULL_TREE)) + prefix_attributes)) { pop_function_context (); YYERROR1; @@ -1624,7 +1624,7 @@ notype_nested_function: push_function_context (); if (! start_function (current_declspecs, $1, - prefix_attributes, NULL_TREE)) + prefix_attributes)) { pop_function_context (); YYERROR1; @@ -1896,27 +1896,27 @@ components_notype: component_declarator: save_filename save_lineno declarator maybe_attribute { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE); - decl_attributes ($$, $4, prefix_attributes); } + decl_attributes ($$, chainon ($4, prefix_attributes)); } | save_filename save_lineno declarator ':' expr_no_commas maybe_attribute { $$ = grokfield ($1, $2, $3, current_declspecs, $5); - decl_attributes ($$, $6, prefix_attributes); } + decl_attributes ($$, chainon ($6, prefix_attributes)); } | save_filename save_lineno ':' expr_no_commas maybe_attribute { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4); - decl_attributes ($$, $5, prefix_attributes); } + decl_attributes ($$, chainon ($5, prefix_attributes)); } ; component_notype_declarator: save_filename save_lineno notype_declarator maybe_attribute { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE); - decl_attributes ($$, $4, prefix_attributes); } + decl_attributes ($$, chainon ($4, prefix_attributes)); } | save_filename save_lineno notype_declarator ':' expr_no_commas maybe_attribute { $$ = grokfield ($1, $2, $3, current_declspecs, $5); - decl_attributes ($$, $6, prefix_attributes); } + decl_attributes ($$, chainon ($6, prefix_attributes)); } | save_filename save_lineno ':' expr_no_commas maybe_attribute { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4); - decl_attributes ($$, $5, prefix_attributes); } + decl_attributes ($$, chainon ($5, prefix_attributes)); } ; /* We chain the enumerators in reverse order. @@ -1966,18 +1966,15 @@ absdcl_maybe_attribute: /* absdcl maybe_attribute, but not just attributes */ /* empty */ { $$ = build_tree_list (build_tree_list (current_declspecs, NULL_TREE), - build_tree_list (prefix_attributes, - NULL_TREE)); } + prefix_attributes); } | absdcl1 { $$ = build_tree_list (build_tree_list (current_declspecs, $1), - build_tree_list (prefix_attributes, - NULL_TREE)); } + prefix_attributes); } | absdcl1_noea attributes { $$ = build_tree_list (build_tree_list (current_declspecs, $1), - build_tree_list (prefix_attributes, - $2)); } + chainon ($2, prefix_attributes)); } ; absdcl1: /* a nonempty absolute declarator */ @@ -2450,7 +2447,7 @@ label: CASE expr_no_commas ':' stmt_count++; if (label) { - decl_attributes (label, $5, NULL_TREE); + decl_attributes (label, $5); $$ = add_stmt (build_stmt (LABEL_STMT, label)); } else @@ -2567,16 +2564,14 @@ parm: declspecs_ts setspecs parm_declarator maybe_attribute { $$ = build_tree_list (build_tree_list (current_declspecs, $3), - build_tree_list (prefix_attributes, - $4)); + chainon ($4, prefix_attributes)); current_declspecs = TREE_VALUE (declspec_stack); prefix_attributes = TREE_PURPOSE (declspec_stack); declspec_stack = TREE_CHAIN (declspec_stack); } | declspecs_ts setspecs notype_declarator maybe_attribute { $$ = build_tree_list (build_tree_list (current_declspecs, $3), - build_tree_list (prefix_attributes, - $4)); + chainon ($4, prefix_attributes)); current_declspecs = TREE_VALUE (declspec_stack); prefix_attributes = TREE_PURPOSE (declspec_stack); declspec_stack = TREE_CHAIN (declspec_stack); } @@ -2588,8 +2583,7 @@ parm: | declspecs_nots setspecs notype_declarator maybe_attribute { $$ = build_tree_list (build_tree_list (current_declspecs, $3), - build_tree_list (prefix_attributes, - $4)); + chainon ($4, prefix_attributes)); current_declspecs = TREE_VALUE (declspec_stack); prefix_attributes = TREE_PURPOSE (declspec_stack); declspec_stack = TREE_CHAIN (declspec_stack); } @@ -2607,16 +2601,14 @@ firstparm: declspecs_ts_nosa setspecs_fp parm_declarator maybe_attribute { $$ = build_tree_list (build_tree_list (current_declspecs, $3), - build_tree_list (prefix_attributes, - $4)); + chainon ($4, prefix_attributes)); current_declspecs = TREE_VALUE (declspec_stack); prefix_attributes = TREE_PURPOSE (declspec_stack); declspec_stack = TREE_CHAIN (declspec_stack); } | declspecs_ts_nosa setspecs_fp notype_declarator maybe_attribute { $$ = build_tree_list (build_tree_list (current_declspecs, $3), - build_tree_list (prefix_attributes, - $4)); + chainon ($4, prefix_attributes)); current_declspecs = TREE_VALUE (declspec_stack); prefix_attributes = TREE_PURPOSE (declspec_stack); declspec_stack = TREE_CHAIN (declspec_stack); } @@ -2628,8 +2620,7 @@ firstparm: | declspecs_nots_nosa setspecs_fp notype_declarator maybe_attribute { $$ = build_tree_list (build_tree_list (current_declspecs, $3), - build_tree_list (prefix_attributes, - $4)); + chainon ($4, prefix_attributes)); current_declspecs = TREE_VALUE (declspec_stack); prefix_attributes = TREE_PURPOSE (declspec_stack); declspec_stack = TREE_CHAIN (declspec_stack); } @@ -3113,13 +3104,11 @@ myparm: parm_declarator maybe_attribute { $$ = build_tree_list (build_tree_list (current_declspecs, $1), - build_tree_list (prefix_attributes, - $2)); } + chainon ($2, prefix_attributes)); } | notype_declarator maybe_attribute { $$ = build_tree_list (build_tree_list (current_declspecs, $1), - build_tree_list (prefix_attributes, - $2)); } + chainon ($2, prefix_attributes)); } | absdcl_maybe_attribute { $$ = $1; } ; diff --git a/gcc/c-tree.h b/gcc/c-tree.h index 1ea096f88b2..6c466e76086 100644 --- a/gcc/c-tree.h +++ b/gcc/c-tree.h @@ -207,10 +207,9 @@ extern void shadow_record_fields PARAMS ((tree)); extern void shadow_tag PARAMS ((tree)); extern void shadow_tag_warned PARAMS ((tree, int)); extern tree start_enum PARAMS ((tree)); -extern int start_function PARAMS ((tree, tree, tree, - tree)); +extern int start_function PARAMS ((tree, tree, tree)); extern tree start_decl PARAMS ((tree, tree, int, - tree, tree)); + tree)); extern tree start_struct PARAMS ((enum tree_code, tree)); extern void store_parm_decls PARAMS ((void)); extern tree xref_tag PARAMS ((enum tree_code, tree)); diff --git a/gcc/config/sh/sh-protos.h b/gcc/config/sh/sh-protos.h index 5cfec06a911..4125e327a83 100644 --- a/gcc/config/sh/sh-protos.h +++ b/gcc/config/sh/sh-protos.h @@ -105,7 +105,7 @@ extern rtx sh_va_arg PARAMS ((tree, tree)); #endif /* RTX_CODE */ #ifdef TREE_CODE -extern void sh_pragma_insert_attributes PARAMS ((tree, tree *, tree *)); +extern void sh_pragma_insert_attributes PARAMS ((tree, tree *)); extern tree sh_build_va_list PARAMS ((void)); #endif /* TREE_CODE */ diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c index db8de6574cc..d66984080df 100644 --- a/gcc/config/sh/sh.c +++ b/gcc/config/sh/sh.c @@ -4604,10 +4604,9 @@ sh_pr_nosave_low_regs (pfile) /* Generate 'handle_interrupt' attribute for decls */ void -sh_pragma_insert_attributes (node, attributes, prefix) +sh_pragma_insert_attributes (node, attributes) tree node; tree * attributes; - tree * prefix ATTRIBUTE_UNUSED; { if (! pragma_interrupt || TREE_CODE (node) != FUNCTION_DECL) diff --git a/gcc/config/sh/sh.h b/gcc/config/sh/sh.h index 8c34084e1fd..29393fd2d93 100644 --- a/gcc/config/sh/sh.h +++ b/gcc/config/sh/sh.h @@ -2293,8 +2293,8 @@ extern int current_function_interrupt; for interrupt functions. */ extern struct rtx_def *sp_switch; -#define PRAGMA_INSERT_ATTRIBUTES(node, pattr, prefix_attr) \ - sh_pragma_insert_attributes (node, pattr, prefix_attr) +#define PRAGMA_INSERT_ATTRIBUTES(node, pattr) \ + sh_pragma_insert_attributes (node, pattr) extern int rtx_equal_function_value_matters; extern struct rtx_def *fpscr_rtx; diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 54748c10dee..efdbccd4b98 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2001-07-08 Joseph S. Myers + + * decl.c (grokdeclarator), decl2.c (cplus_decl_attributes): Update + calls to decl_attributes. + 2001-07-06 Ira Ruben * cp-tree.def (TEMPLATE_DECL): Update comment. DECL_RESULT should diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index f6edc2cf3c9..c0f90b87e4c 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10468,7 +10468,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) ignore_attrs = 0; else if (inner_attrs) { - decl_attributes (type, inner_attrs, NULL_TREE); + decl_attributes (type, inner_attrs); inner_attrs = NULL_TREE; } @@ -10987,7 +10987,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) if (inner_attrs) { if (! ignore_attrs) - decl_attributes (type, inner_attrs, NULL_TREE); + decl_attributes (type, inner_attrs); else if (attrlist) TREE_VALUE (attrlist) = chainon (inner_attrs, TREE_VALUE (attrlist)); else diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 5b0abfcd738..e6d4274ebb2 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1884,7 +1884,7 @@ cplus_decl_attributes (decl, attributes, prefix_attributes) if (TREE_CODE (decl) == TEMPLATE_DECL) decl = DECL_TEMPLATE_RESULT (decl); - decl_attributes (decl, attributes, prefix_attributes); + decl_attributes (decl, chainon (attributes, prefix_attributes)); if (TREE_CODE (decl) == TYPE_DECL) SET_IDENTIFIER_TYPE_VALUE (DECL_NAME (decl), TREE_TYPE (decl)); diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 17f6c6b8697..4cddb831314 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -8415,15 +8415,17 @@ in @file{i386/cygwin.h} and @file{i386/i386.c}, for example. @table @code @findex INSERT_ATTRIBUTES -@item INSERT_ATTRIBUTES (@var{node}, @var{attr_ptr}, @var{prefix_ptr}) +@item INSERT_ATTRIBUTES (@var{node}, @var{attr_ptr}) Define this macro if you want to be able to add attributes to a decl when it is being created. This is normally useful for back ends which wish to implement a pragma by using the attributes which correspond to the pragma's effect. The @var{node} argument is the decl which is being created. The @var{attr_ptr} argument is a pointer to the attribute list -for this decl. The @var{prefix_ptr} is a pointer to the list of -attributes that have appeared after the specifiers and modifiers of the -declaration, but before the declaration proper. +for this decl. The list itself should not be modified, since it may be +shared with other decls, but attributes may be chained on the head of +the list and @code{*@var{attr_ptr}} modified to point to the new +attributes, or a copy of the list may be made if further changes are +needed. @findex SET_DEFAULT_DECL_ATTRIBUTES @item SET_DEFAULT_DECL_ATTRIBUTES (@var{decl}, @var{attributes}) diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index f059472112a..3a19d286a42 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -852,7 +852,7 @@ define_decl (declarator, declspecs) tree declarator; tree declspecs; { - tree decl = start_decl (declarator, declspecs, 0, NULL_TREE, NULL_TREE); + tree decl = start_decl (declarator, declspecs, 0, NULL_TREE); finish_decl (decl, NULL_TREE, NULL_TREE); return decl; } @@ -1753,7 +1753,7 @@ generate_objc_symtab_decl () tree_cons (NULL_TREE, objc_symtab_template, sc_spec), 1, - NULL_TREE, NULL_TREE); + NULL_TREE); TREE_USED (UOBJC_SYMBOLS_decl) = 1; DECL_IGNORED_P (UOBJC_SYMBOLS_decl) = 1; @@ -1853,7 +1853,7 @@ build_module_descriptor () ridpointers[(int) RID_STATIC])); UOBJC_MODULES_decl = start_decl (get_identifier ("_OBJC_MODULES"), - decl_specs, 1, NULL_TREE, NULL_TREE); + decl_specs, 1, NULL_TREE); DECL_ARTIFICIAL (UOBJC_MODULES_decl) = 1; DECL_IGNORED_P (UOBJC_MODULES_decl) = 1; @@ -1910,7 +1910,7 @@ build_module_descriptor () tree_cons (NULL_TREE, NULL_TREE, void_list_node_1), NULL_TREE), - NULL_TREE, NULL_TREE); + NULL_TREE); #if 0 /* This should be turned back on later for the systems where collect is not needed. */ /* Make these functions nonglobal @@ -2003,7 +2003,7 @@ generate_static_references () decl_spec = tree_cons (NULL_TREE, build_pointer_type (void_type_node), build_tree_list (NULL_TREE, ridpointers[(int) RID_STATIC])); - decl = start_decl (expr_decl, decl_spec, 1, NULL_TREE, NULL_TREE); + decl = start_decl (expr_decl, decl_spec, 1, NULL_TREE); DECL_CONTEXT (decl) = 0; DECL_ARTIFICIAL (decl) = 1; @@ -2043,7 +2043,7 @@ generate_static_references () build_tree_list (NULL_TREE, ridpointers[(int) RID_STATIC])); static_instances_decl - = start_decl (expr_decl, decl_spec, 1, NULL_TREE, NULL_TREE); + = start_decl (expr_decl, decl_spec, 1, NULL_TREE); TREE_USED (static_instances_decl) = 1; DECL_CONTEXT (static_instances_decl) = 0; DECL_ARTIFICIAL (static_instances_decl) = 1; @@ -2069,7 +2069,7 @@ generate_strings () = tree_cons (NULL_TREE, ridpointers[(int) RID_STATIC], NULL_TREE); decl_specs = tree_cons (NULL_TREE, ridpointers[(int) RID_CHAR], sc_spec); expr_decl = build_nt (ARRAY_REF, DECL_NAME (decl), NULL_TREE); - decl = start_decl (expr_decl, decl_specs, 1, NULL_TREE, NULL_TREE); + decl = start_decl (expr_decl, decl_specs, 1, NULL_TREE); DECL_CONTEXT (decl) = NULL_TREE; string_expr = my_build_string (IDENTIFIER_LENGTH (string) + 1, IDENTIFIER_POINTER (string)); @@ -2084,7 +2084,7 @@ generate_strings () = tree_cons (NULL_TREE, ridpointers[(int) RID_STATIC], NULL_TREE); decl_specs = tree_cons (NULL_TREE, ridpointers[(int) RID_CHAR], sc_spec); expr_decl = build_nt (ARRAY_REF, DECL_NAME (decl), NULL_TREE); - decl = start_decl (expr_decl, decl_specs, 1, NULL_TREE, NULL_TREE); + decl = start_decl (expr_decl, decl_specs, 1, NULL_TREE); DECL_CONTEXT (decl) = NULL_TREE; string_expr = my_build_string (IDENTIFIER_LENGTH (string) + 1, IDENTIFIER_POINTER (string)); @@ -2099,7 +2099,7 @@ generate_strings () = tree_cons (NULL_TREE, ridpointers[(int) RID_STATIC], NULL_TREE); decl_specs = tree_cons (NULL_TREE, ridpointers[(int) RID_CHAR], sc_spec); expr_decl = build_nt (ARRAY_REF, DECL_NAME (decl), NULL_TREE); - decl = start_decl (expr_decl, decl_specs, 1, NULL_TREE, NULL_TREE); + decl = start_decl (expr_decl, decl_specs, 1, NULL_TREE); DECL_CONTEXT (decl) = NULL_TREE; string_expr = my_build_string (IDENTIFIER_LENGTH (string) + 1, IDENTIFIER_POINTER (string)); @@ -2172,7 +2172,7 @@ build_selector_translation_table () /* The `decl' that is returned from start_decl is the one that we forward declared in `build_selector_reference' */ - decl = start_decl (var_decl, decl_specs, 1, NULL_TREE, NULL_TREE); + decl = start_decl (var_decl, decl_specs, 1, NULL_TREE ); } /* add one for the '\0' character */ @@ -2967,7 +2967,7 @@ generate_descriptor_table (type, name, size, list, proto) decl_specs = tree_cons (NULL_TREE, type, sc_spec); decl = start_decl (synth_id_with_class_suffix (name, proto), - decl_specs, 1, NULL_TREE, NULL_TREE); + decl_specs, 1, NULL_TREE); DECL_CONTEXT (decl) = NULL_TREE; initlist = build_tree_list (NULL_TREE, build_int_2 (size, 0)); @@ -3060,14 +3060,14 @@ build_tmp_function_decl () (build_tree_list (decl_specs, build1 (INDIRECT_REF, NULL_TREE, NULL_TREE)), - build_tree_list (NULL_TREE, NULL_TREE))); + NULL_TREE)); decl_specs = build_tree_list (NULL_TREE, xref_tag (RECORD_TYPE, get_identifier (TAG_SELECTOR))); expr_decl = build1 (INDIRECT_REF, NULL_TREE, NULL_TREE); push_parm_decl (build_tree_list (build_tree_list (decl_specs, expr_decl), - build_tree_list (NULL_TREE, NULL_TREE))); + NULL_TREE)); parms = get_parm_info (0); poplevel (0, 0, 0); @@ -3223,7 +3223,7 @@ generate_protocols () decl_specs = tree_cons (NULL_TREE, objc_protocol_template, sc_spec); decl = start_decl (synth_id_with_class_suffix ("_OBJC_PROTOCOL", p), - decl_specs, 1, NULL_TREE, NULL_TREE); + decl_specs, 1, NULL_TREE); DECL_CONTEXT (decl) = NULL_TREE; @@ -3929,7 +3929,7 @@ generate_ivars_list (type, name, size, list) decl_specs = tree_cons (NULL_TREE, type, sc_spec); decl = start_decl (synth_id_with_class_suffix (name, implementation_context), - decl_specs, 1, NULL_TREE, NULL_TREE); + decl_specs, 1, NULL_TREE); initlist = build_tree_list (NULL_TREE, build_int_2 (size, 0)); initlist = tree_cons (NULL_TREE, list, initlist); @@ -4094,7 +4094,7 @@ generate_dispatch_table (type, name, size, list) decl_specs = tree_cons (NULL_TREE, type, sc_spec); decl = start_decl (synth_id_with_class_suffix (name, implementation_context), - decl_specs, 1, NULL_TREE, NULL_TREE); + decl_specs, 1, NULL_TREE); initlist = build_tree_list (NULL_TREE, build_int_2 (0, 0)); initlist = tree_cons (NULL_TREE, build_int_2 (size, 0), initlist); @@ -4252,7 +4252,7 @@ generate_protocol_list (i_or_p) expr_decl = build1 (INDIRECT_REF, NULL_TREE, expr_decl); - refs_decl = start_decl (expr_decl, decl_specs, 1, NULL_TREE, NULL_TREE); + refs_decl = start_decl (expr_decl, decl_specs, 1, NULL_TREE); DECL_CONTEXT (refs_decl) = NULL_TREE; finish_decl (refs_decl, build_constructor (TREE_TYPE (refs_decl), @@ -4462,7 +4462,7 @@ generate_category (cat) decl = start_decl (synth_id_with_class_suffix ("_OBJC_CATEGORY", implementation_context), - decl_specs, 1, NULL_TREE, NULL_TREE); + decl_specs, 1, NULL_TREE); initlist = build_category_initializer (TREE_TYPE (decl), cat_name_expr, class_name_expr, @@ -4545,7 +4545,7 @@ generate_shared_structures () decl_specs = tree_cons (NULL_TREE, objc_class_template, sc_spec); decl = start_decl (DECL_NAME (UOBJC_METACLASS_decl), decl_specs, 1, - NULL_TREE, NULL_TREE); + NULL_TREE); initlist = build_shared_structure_initializer @@ -4562,7 +4562,7 @@ generate_shared_structures () /* static struct objc_class _OBJC_CLASS_Foo={ ... }; */ decl = start_decl (DECL_NAME (UOBJC_CLASS_decl), decl_specs, 1, - NULL_TREE, NULL_TREE); + NULL_TREE); initlist = build_shared_structure_initializer @@ -6953,7 +6953,7 @@ start_method_def (method) push_parm_decl (build_tree_list (build_tree_list (decl_specs, build1 (INDIRECT_REF, NULL_TREE, self_id)), - build_tree_list (unused_list, NULL_TREE))); + unused_list)); decl_specs = build_tree_list (NULL_TREE, xref_tag (RECORD_TYPE, @@ -6961,7 +6961,7 @@ start_method_def (method) push_parm_decl (build_tree_list (build_tree_list (decl_specs, build1 (INDIRECT_REF, NULL_TREE, ucmd_id)), - build_tree_list (unused_list, NULL_TREE))); + unused_list)); /* Generate argument declarations if a keyword_decl. */ if (METHOD_SEL_ARGS (method)) @@ -6980,7 +6980,7 @@ start_method_def (method) TREE_OPERAND (last_expr, 0) = KEYWORD_ARG_NAME (arglist); push_parm_decl (build_tree_list (build_tree_list (arg_spec, arg_decl), - build_tree_list (NULL_TREE, NULL_TREE))); + NULL_TREE)); /* Unhook: restore the abstract declarator. */ TREE_OPERAND (last_expr, 0) = NULL_TREE; @@ -6990,7 +6990,7 @@ start_method_def (method) push_parm_decl (build_tree_list (build_tree_list (arg_spec, KEYWORD_ARG_NAME (arglist)), - build_tree_list (NULL_TREE, NULL_TREE))); + NULL_TREE)); arglist = TREE_CHAIN (arglist); } @@ -7133,7 +7133,7 @@ really_start_method (method, parmlist) method_decl = ret_decl; /* Fool the parser into thinking it is starting a function. */ - start_function (decl_specs, method_decl, NULL_TREE, NULL_TREE); + start_function (decl_specs, method_decl, NULL_TREE); /* Unhook: this has the effect of restoring the abstract declarator. */ TREE_OPERAND (save_expr, 0) = NULL_TREE; @@ -7144,7 +7144,7 @@ really_start_method (method, parmlist) TREE_VALUE (TREE_TYPE (method)) = method_decl; /* Fool the parser into thinking it is starting a function. */ - start_function (decl_specs, method_decl, NULL_TREE, NULL_TREE); + start_function (decl_specs, method_decl, NULL_TREE); /* Unhook: this has the effect of restoring the abstract declarator. */ TREE_VALUE (TREE_TYPE (method)) = NULL_TREE; @@ -7210,7 +7210,7 @@ add_objc_decls () UOBJC_SUPER_decl = start_decl (get_identifier (UTAG_SUPER), build_tree_list (NULL_TREE, objc_super_template), - 0, NULL_TREE, NULL_TREE); + 0, NULL_TREE); finish_decl (UOBJC_SUPER_decl, NULL_TREE, NULL_TREE); @@ -8342,7 +8342,7 @@ generate_classref_translation_entry (chain) /* The decl that is returned from start_decl is the one that we forward declared in build_class_reference. */ - decl = start_decl (name, decl_specs, 1, NULL_TREE, NULL_TREE); + decl = start_decl (name, decl_specs, 1, NULL_TREE); DECL_CONTEXT (decl) = NULL_TREE; finish_decl (decl, expr, NULL_TREE); return; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5e37d0f31d7..c9fb89f4bb0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2001-07-08 Joseph S. Myers + + * gcc.c-torture/compile/20010701-1.c, + g++.old-deja/g++.ext/attrib6.C: New tests. + Fri Jul 6 09:31:43 2001 Jeffrey A Law (law@cygnus.com) * gcc.c-torture/compile/20010706-1.c: New test. diff --git a/gcc/testsuite/g++.old-deja/g++.ext/attrib6.C b/gcc/testsuite/g++.old-deja/g++.ext/attrib6.C new file mode 100644 index 00000000000..6b2184ffb7a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/attrib6.C @@ -0,0 +1,6 @@ +// Test that postfix attributes only apply to a single declared object. +// (decl_attributes used to chain them onto the end of the prefix attributes, +// which caused them to apply to other declarations as well.) +// Origin: Joseph Myers . +// Build don't link: +void __attribute__((__noreturn__)) foo (const char *, ...) __attribute__((__format__(__printf__, 1, 2))), bar (void); diff --git a/gcc/testsuite/gcc.c-torture/compile/20010701-1.c b/gcc/testsuite/gcc.c-torture/compile/20010701-1.c new file mode 100644 index 00000000000..7fb7ab5b150 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20010701-1.c @@ -0,0 +1,5 @@ +/* Test that postfix attributes only apply to a single declared object. + (decl_attributes used to chain them onto the end of the prefix attributes, + which caused them to apply to other declarations as well.) */ +/* Origin: Joseph Myers . */ +void __attribute__((__noreturn__)) foo (const char *, ...) __attribute__((__format__(__printf__, 1, 2))), bar (void); -- 2.30.2