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]
Other format: [Raw text]

Re: New C parser [patch]


On Sat, 23 Oct 2004, Steven Bosscher wrote:

> > +      /* Parse old-style parameter declarations.  */
> > +      while (c_lexer_next_token_is_not (parser->lexer, CPP_EOF)
> > +            && c_lexer_next_token_is_not (parser->lexer, CPP_OPEN_BRACE))
> > +       c_parser_declaration_or_fndef (parser, false, false, true, false);
> > +      DECL_SOURCE_LOCATION (current_function_decl) = input_location;
> 
> Don't you want to make the location of current_function_decl the first
> line where the function definition starts (or the location of the first
> token even)?

This does make it the location of the open brace.  This is a direct 
translation of

          old_style_parm_decls save_location
                { DECL_SOURCE_LOCATION (current_function_decl) = $6;

from the old grammar - and unlike on some places, both the old and new 
parsers have done the one token lookahead at this point so there isn't a 
difference arising and I didn't need to fix this place up to get 
diagnostic locations to agree between the parsers.

Yes, referring to the location of a token explicitly is better than using 
input_location to get it implicitly when location handling is cleaned up 
generally later; just not needed to replace one parser with another.

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
    jsm@polyomino.org.uk (personal mail)
    joseph@codesourcery.com (CodeSourcery mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)


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