From e3dfef44ef6b735ac7eea4202152d672ea0a91ef Mon Sep 17 00:00:00 2001 From: Gabriel Charette Date: Mon, 22 Aug 2011 20:41:07 +0000 Subject: Add ability to force lexed tokens' source_locations. Use it to force BUILTINS_LOCATION when declaring builtins instead of creating a entry in the line_table which is wrong. * 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. From-SVN: r177973 --- gcc/fortran/ChangeLog | 5 +++++ gcc/fortran/cpp.c | 12 ++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 69d901e..075c366 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2011-08-22 Gabriel Charette + + * cpp.c (gfc_cpp_init): Force BUILTINS_LOCATION for tokens + defined in cpp_define_builtins. + 2011-08-22 Mikael Morin PR fortran/50050 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, _("")); 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, _("")); -- cgit v1.1