RFA: Merge C frontend calls to decl_attributes

Richard Sandiford richard@codesourcery.com
Thu Sep 13 13:15:00 GMT 2007

Richard Sandiford <richard@codesourcery.com> writes:
> gcc/
> 	* c-tree.h (grokfield): Add a "tree *" argument.
> 	* c-decl.c (grokdeclarator): Take a pointer to the decl's attributes.
> 	Chain nested decl attributes to it.  Don't call decl_attributes here.
> 	(groktypename): Pass grokdeclarator a pointer to the attribute list.
> 	(start_decl, grokparm, push_parm_decl, start_function): Likewise.
> 	(grokfield): Take a pointer to the decl's attributes and pass
> 	it to grokdeclarator.
> 	* c-parser.c (c_parser_struct_declaration): Update the calls to
> 	grokfield.  Call decl_attributes for anonymous struct and union
> 	fields.

Sorry, I inadvertently did the mipsisa32r2-sde-elf testing with an older
patch that called decl_attributes in grokfield, instead of pushing the
call into its two callers.  (The x86_64-linux-gnu bootstrap was done
with the final patch.)  Retesting on mipsisa32r2-sde-elf showed that
I'd forgotten to handle null returns from grokfield, which was causing
some tests to segfault after reporting an erroneous field.

Bootstrapped & regression-tested on x86_64-linux-gnu.  Applied as obvious.
Sorry for screw-up.


	* c-parser.c (c_parser_struct_declaration): Check for a null return.

Index: gcc/c-parser.c
--- gcc/c-parser.c	(revision 128437)
+++ gcc/c-parser.c	(working copy)
@@ -2033,7 +2033,8 @@ c_parser_struct_declaration (c_parser *p
 	  tree attrs = NULL;
 	  ret = grokfield (build_id_declarator (NULL_TREE), specs,
 			   NULL_TREE, &attrs);
-	  decl_attributes (&ret, attrs, 0);
+	  if (ret)
+	    decl_attributes (&ret, attrs, 0);
       return ret;

More information about the Gcc-patches mailing list