On 08/18/2011 06:47 PM, Gabriel Charette wrote: > Tom: ok for trunk? > > fortran@: The fortran change just reflects the fix from libcpp, > fortran bootstrap and tests passed.
The Fortran change is OK. Thanks for the patch! Tobias On 08/16/2011 02:37 AM, Gabriel Charette wrote:
Here is the updated patch. It nows exposes two libcpp functions to force the source_location for tokens when desired. The lexer then checks for a value set by these functions in cpp_reader and acts accordingly when needing a location for a new token (either using the forced_location or calling the linemap as it used to). It turns out the fortran library made the same mistake of creating a line_table entry for builtins, I fixed it as well in this patch. Tested on x64 for c++,fortran. Ok for trunk? Gabriel 2011-08-15 Gabriel Charette<gch...@google.com> gcc/c-family/ChangeLog * c-opts.c (c_finish_options): Force BUILTINS_LOCATION for tokens defined in cpp_init_builtins and c_cpp_builtins. gcc/fortran/ChangeLog * cpp.c (gfc_cpp_init): Force BUILTINS_LOCATION for tokens defined in cpp_define_builtins. libcpp/ChangeLog * init.c (cpp_create_reader): Inititalize forced_token_location_p. * internal.h (struct cpp_reader): Add field forced_token_location_p. * lex.c (_cpp_lex_direct): Use forced_token_location_p. (cpp_force_token_locations): New. (cpp_stop_forcing_token_locations): New. diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index 3227f7b..49ff80d 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -1306,12 +1306,17 @@ c_finish_options (void) { size_t i; - cb_file_change (parse_in, - linemap_add (line_table, LC_RENAME, 0, - _("<built-in>"), 0)); + { + /* Make sure all of the builtins about to be declared have + BUILTINS_LOCATION has their source_location. */ + source_location builtins_loc = BUILTINS_LOCATION; + cpp_force_token_locations (parse_in,&builtins_loc); - cpp_init_builtins (parse_in, flag_hosted); - c_cpp_builtins (parse_in); + cpp_init_builtins (parse_in, flag_hosted); + c_cpp_builtins (parse_in); + + cpp_stop_forcing_token_locations (parse_in); + } /* We're about to send user input to cpplib, so make it warn for things that we previously (when we sent it internal definitions) diff --git a/gcc/fortran/cpp.c b/gcc/fortran/cpp.c index a40442e..9368d89 100644 --- a/gcc/fortran/cpp.c +++ b/gcc/fortran/cpp.c @@ -565,9 +565,17 @@ gfc_cpp_init (void) if (gfc_option.flag_preprocessed) return; - cpp_change_file (cpp_in, LC_RENAME, _("<built-in>")); if (!gfc_cpp_option.no_predefined) - cpp_define_builtins (cpp_in); + { + /* Make sure all of the builtins about to be declared have + BUILTINS_LOCATION has their source_location. */ + source_location builtins_loc = BUILTINS_LOCATION; + cpp_force_token_locations (cpp_in,&builtins_loc); + + cpp_define_builtins (cpp_in); + + cpp_stop_forcing_token_locations (cpp_in); + } /* Handle deferred options from command-line. */ cpp_change_file (cpp_in, LC_RENAME, _("<command-line>"));
[...]