This is the mail archive of the gcc-bugs@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]

Re: -include -g broken with current CVS (testcase for PR 771)


Zack,

Is there a reason we cannot just move 

  if (! cpp_start_read (&parse_in, filename))
    exit (FATAL_EXIT_CODE);	/* cpplib has emitted an error.  */

from init_c_lex to a new function called init_c_lex_delayed or
init_parse_delayed that goes something like

void
init_c_lex_delayed ()
{
#if USE_CPPLIB
  /* We need to delay this call until after setting up debug
     output, because -included files are processed immediately.  */
  if (! cpp_start_read (&parse_in, filename))
    exit (FATAL_EXIT_CODE);	/* cpplib has emitted an error.  */
#endif
}

and unconditionally call this before yyparse?  This would avoid
callbacks.  I hope nothing wants to use parse_in before yyparse.

Neil.

Zack Weinberg wrote:-

> This is a tough one.  I'm pretty sure the debug output init routines
> depend on being called as late as they are.  Really, we ought to call
> cpp_start_read from yyparse, before entering the scanner loop.
> Unfortunately, there is no way to get control at the beginning of
> yyparse.  We could have yylex test whether cpp_start_read had been
> called, but then we'd be making that test in the fast path for every
> call to yylex.
> 
> The best idea I have is to add a callback hook: in toplev.c 
> 
> + void (*delayed_init_parse_hook) PARAMS ((void));
> 
> ...
> 
>   /* Call the parser, which parses the entire file
>      (calling rest_of_compilation for each function).  */
> 
> + if (delayed_init_parse_hook)
> +   (*delayed_init_parse_hook) ()
> 
>   if (yyparse () != 0)
> 
> and then set that in c/c++ init_parse to a small routine that just
> calls cpp_start_read.
> 
> Then we could remove the silly special case in cb_enter_file.  Are
> you sure we ever call debug_start_source_file for the main file right
> now?  I don't see how we get there except via cb_enter_file...
> 
> zw

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