[Patch] grokdeclarator cleanup (newb patch)

Zack Weinberg zack@codesourcery.com
Tue Apr 20 01:34:00 GMT 2004


> I've made a patch that forms part of my attempt to cleanup the
> function grokdeclarator in gcc/cp/decl.c. I've added a function
> (get_identifier_name_ptr) and moved some code from the 1st switch
> statement in grokdeclarator into it. I've tested it using make
> check-g++ and there are no unexpected fails. The idea behind the
> change was to figure out what the code in case IDENTIFIER_NODE: was
> trying to do and move that into a function that does one thing. In
> this case I decided that the code was really trying to find the name
> of the identifier, so I moved the code to do that into a new function
> called get_identifier_name_ptr.

This is an interesting patch, but I think it is the wrong
refactorization.  There are several variables named 'name' in this
function (one at top level, others in block scopes) and I suspect that
some of them are write-only.  You should disentangle that first.  It
may then become evident that some of this code is unnecessary.  You
should also investigate the use of the %E format specifier for
'error', 'warning', etc. - this allows you to write e.g.

   error ("invalid use of '%E'", id);

instead of 

   error ("invalid use of '%s'", IDENTIFIER_POINTER (id));

where id is an IDENTIFIER_NODE.  Note further that the %D in this 

       error ("declarator-id missing; using reserved word `%D'", dname);

is incorrect - %D takes a DECL node.  It should be %E.

Have you filed a copyright assignment with the FSF yet?  We can't take
substantial contributions without one.

zw



More information about the Gcc-patches mailing list