This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch to unify prefix/postfix attributes processing


This patch makes the adjustments to c-common code and the C and
Objective-C compilers to pass a single list of attributes to
declarations rather than distinguishing prefix and postfix attributes.
It doesn't make the corresponding changes through the C++ compiler,
beyond those needed to handle the interface changes on common code,
since I think Mark is doing this as part of the new parser work.
Testcases (C and C++) are included for a bug this incidentally fixes.

Bootstrapped with no regressions on i686-pc-linux-gnu.  OK to commit?

2001-07-02  Joseph S. Myers  <jsm28@cam.ac.uk>

	* 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:
2001-07-02  Joseph S. Myers  <jsm28@cam.ac.uk>

	* decl.c (grokdeclarator), decl2.c (cplus_decl_attributes): Update
	calls to decl_attributes.

testsuite:
2001-07-02  Joseph S. Myers  <jsm28@cam.ac.uk>

	* gcc.c-torture/compile/20010701-1.c,
	g++.old-deja/g++.ext/attrib6.C: New tests.

diff -rupN gcc.orig/c-common.c gcc/c-common.c
--- gcc.orig/c-common.c	Fri Jun 22 19:13:21 2001
+++ gcc/c-common.c	Fri Jun 29 23:36:02 2001
@@ -722,14 +722,12 @@ default_valid_lang_attribute (attr_name,
 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,14 +750,12 @@ decl_attributes (node, attributes, prefi
      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))
     {
diff -rupN gcc.orig/c-common.h gcc/c-common.h
--- gcc.orig/c-common.h	Tue Jun 19 11:16:20 2001
+++ gcc/c-common.h	Fri Jun 29 23:36:14 2001
@@ -485,7 +485,7 @@ extern void finish_fname_decls			PARAMS 
 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 -rupN gcc.orig/c-decl.c gcc/c-decl.c
--- gcc.orig/c-decl.c	Tue Jun 26 19:14:53 2001
+++ gcc/c-decl.c	Mon Jul  2 13:00:03 2001
@@ -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, initi
 #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, attribute
   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, p
       return 0;
     }
 
-  decl_attributes (decl1, prefix_attributes, attributes);
+  decl_attributes (decl1, attributes);
 
   announce_function (decl1);
 
diff -rupN gcc.orig/c-parse.in gcc/c-parse.in
--- gcc.orig/c-parse.in	Sun Jun 10 14:00:56 2001
+++ gcc/c-parse.in	Mon Jul  2 12:58:52 2001
@@ -383,7 +383,7 @@ datadef:
 fndef:
 	  declspecs_ts setspecs declarator
 		{ if (! start_function (current_declspecs, $3,
-					prefix_attributes, NULL_TREE))
+					prefix_attributes))
 		    YYERROR1;
 		}
 	  old_style_parm_decls
@@ -401,7 +401,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
@@ -419,7 +419,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
@@ -1440,7 +1440,7 @@ maybeasm:
 initdcl:
 	  declarator maybeasm maybe_attribute '='
 		{ $<ttype>$ = start_decl ($1, current_declspecs, 1,
-					  $3, prefix_attributes);
+					  chainon ($3, prefix_attributes));
 		  start_init ($<ttype>$, $2, global_bindings_p ()); }
 	  init
 /* Note how the declaration of the variable is in effect while its init is parsed! */
@@ -1448,7 +1448,7 @@ initdcl:
 		  finish_decl ($<ttype>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); 
                 }
 	;
@@ -1456,7 +1456,7 @@ initdcl:
 notype_initdcl:
 	  notype_declarator maybeasm maybe_attribute '='
 		{ $<ttype>$ = start_decl ($1, current_declspecs, 1,
-					  $3, prefix_attributes);
+					  chainon ($3, prefix_attributes));
 		  start_init ($<ttype>$, $2, global_bindings_p ()); }
 	  init
 /* Note how the declaration of the variable is in effect while its init is parsed! */
@@ -1464,7 +1464,7 @@ notype_initdcl:
 		  finish_decl ($<ttype>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
@@ -1598,7 +1598,7 @@ nested_function:
 
 		  push_function_context ();
 		  if (! start_function (current_declspecs, $1,
-					prefix_attributes, NULL_TREE))
+					prefix_attributes))
 		    {
 		      pop_function_context ();
 		      YYERROR1;
@@ -1628,7 +1628,7 @@ notype_nested_function:
 
 		  push_function_context ();
 		  if (! start_function (current_declspecs, $1,
-					prefix_attributes, NULL_TREE))
+					prefix_attributes))
 		    {
 		      pop_function_context ();
 		      YYERROR1;
@@ -1900,27 +1900,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.
@@ -1970,18 +1970,15 @@ absdcl_maybe_attribute:   /* absdcl mayb
 	/* 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 */
@@ -2454,7 +2451,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
@@ -2571,16 +2568,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); }
@@ -2592,8 +2587,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); }
@@ -2611,16 +2605,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); }
@@ -2632,8 +2624,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); }
@@ -3117,13 +3108,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 -rupN gcc.orig/c-tree.h gcc/c-tree.h
--- gcc.orig/c-tree.h	Tue Jun  5 07:05:17 2001
+++ gcc/c-tree.h	Fri Jun 29 23:46:09 2001
@@ -207,10 +207,9 @@ extern void shadow_record_fields        
 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 -rupN gcc.orig/config/sh/sh-protos.h gcc/config/sh/sh-protos.h
--- gcc.orig/config/sh/sh-protos.h	Tue Jun 26 19:14:59 2001
+++ gcc/config/sh/sh-protos.h	Sat Jun 30 00:14:55 2001
@@ -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 -rupN gcc.orig/config/sh/sh.c gcc/config/sh/sh.c
--- gcc.orig/config/sh/sh.c	Tue Jun 26 19:14:59 2001
+++ gcc/config/sh/sh.c	Sat Jun 30 00:15:09 2001
@@ -4602,10 +4602,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 -rupN gcc.orig/config/sh/sh.h gcc/config/sh/sh.h
--- gcc.orig/config/sh/sh.h	Tue Jun 26 19:14:59 2001
+++ gcc/config/sh/sh.h	Sat Jun 30 00:14:47 2001
@@ -2298,8 +2298,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 -rupN gcc.orig/cp/decl.c gcc/cp/decl.c
--- gcc.orig/cp/decl.c	Tue Jun 26 19:15:01 2001
+++ gcc/cp/decl.c	Sat Jun 30 00:08:59 2001
@@ -10468,7 +10468,7 @@ grokdeclarator (declarator, declspecs, d
 	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, d
   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 -rupN gcc.orig/cp/decl2.c gcc/cp/decl2.c
--- gcc.orig/cp/decl2.c	Wed Jun 27 07:19:06 2001
+++ gcc/cp/decl2.c	Sat Jun 30 00:13:15 2001
@@ -1884,7 +1884,7 @@ cplus_decl_attributes (decl, 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 -rupN gcc.orig/doc/tm.texi gcc/doc/tm.texi
--- gcc.orig/doc/tm.texi	Fri Jun 29 16:53:21 2001
+++ gcc/doc/tm.texi	Sat Jun 30 07:08:39 2001
@@ -8341,15 +8341,17 @@ in @file{i386/cygwin.h} and @file{i386/i
 
 @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 -rupN gcc.orig/objc/objc-act.c gcc/objc/objc-act.c
--- gcc.orig/objc/objc-act.c	Thu Jun 28 07:20:27 2001
+++ gcc/objc/objc-act.c	Mon Jul  2 13:02:57 2001
@@ -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, s
   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, l
   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, siz
   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 (cha
 
   /* 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 -rupN gcc.orig/testsuite/g++.old-deja/g++.ext/attrib6.C gcc/testsuite/g++.old-deja/g++.ext/attrib6.C
--- gcc.orig/testsuite/g++.old-deja/g++.ext/attrib6.C	Thu Jan  1 00:00:00 1970
+++ gcc/testsuite/g++.old-deja/g++.ext/attrib6.C	Sun Jul  1 15:19:44 2001
@@ -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 <jsm28@cam.ac.uk>.
+// Build don't link:
+void __attribute__((__noreturn__)) foo (const char *, ...) __attribute__((__format__(__printf__, 1, 2))), bar (void);
diff -rupN gcc.orig/testsuite/gcc.c-torture/compile/20010701-1.c gcc/testsuite/gcc.c-torture/compile/20010701-1.c
--- gcc.orig/testsuite/gcc.c-torture/compile/20010701-1.c	Thu Jan  1 00:00:00 1970
+++ gcc/testsuite/gcc.c-torture/compile/20010701-1.c	Sun Jul  1 15:16:28 2001
@@ -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 <jsm28@cam.ac.uk>.  */
+void __attribute__((__noreturn__)) foo (const char *, ...) __attribute__((__format__(__printf__, 1, 2))), bar (void);

-- 
Joseph S. Myers
jsm28@cam.ac.uk


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]