aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2018-10-31 15:26:28 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2018-10-31 15:26:28 +0000
commitf3f6029db2e5f960c10062d8c8c74d766fcad6d2 (patch)
tree65fe76f5ca430fb5055b03a24045e1d61e3668be
parent82a14443dbad05cdf1bd09c7ebc98c406c81e384 (diff)
downloadgcc-f3f6029db2e5f960c10062d8c8c74d766fcad6d2.zip
gcc-f3f6029db2e5f960c10062d8c8c74d766fcad6d2.tar.gz
gcc-f3f6029db2e5f960c10062d8c8c74d766fcad6d2.tar.bz2
[6/6] Preprocessor forced macro location
https://gcc.gnu.org/ml/gcc-patches/2018-10/msg02044.html libcpp/ * internal.h (struct cpp_reader): Rename forced_token_location_p to forced_token_location and drop its pointerness. * include/cpplib.h (cpp_force_token_locations): Take location, not pointer to one. * init.c (cpp_create_reader): Adjust. * lex.c (cpp_read_main_file): gcc/c-family/ * c-opts.c (c_finish_options): Adjust cpp_force_token_locations call. gcc/fortran/ * cpp.c (gfc_cpp_init): Adjust cpp_force_token_locations call. From-SVN: r265692
-rw-r--r--gcc/c-family/ChangeLog4
-rw-r--r--gcc/c-family/c-opts.c3
-rw-r--r--gcc/fortran/ChangeLog4
-rw-r--r--gcc/fortran/cpp.c3
-rw-r--r--libcpp/ChangeLog7
-rw-r--r--libcpp/include/cpplib.h2
-rw-r--r--libcpp/init.c2
-rw-r--r--libcpp/internal.h4
-rw-r--r--libcpp/lex.c14
9 files changed, 28 insertions, 15 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 5b96582..290e3fa 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,7 @@
+2018-10-31 Nathan Sidwell <nathan@acm.org>
+
+ * c-opts.c (c_finish_options): Adjust cpp_force_token_locations call.
+
2018-10-30 Martin Sebor <msebor@redhat.com>
PR middle-end/87041
diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
index 9cf1900..4592682 100644
--- a/gcc/c-family/c-opts.c
+++ b/gcc/c-family/c-opts.c
@@ -1396,8 +1396,7 @@ c_finish_options (void)
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_force_token_locations (parse_in, BUILTINS_LOCATION);
cpp_init_builtins (parse_in, flag_hosted);
c_cpp_builtins (parse_in);
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index e6e350d..a773bbd 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,7 @@
+2018-10-31 Nathan Sidwell <nathan@acm.org>
+
+ * cpp.c (gfc_cpp_init): Adjust cpp_force_token_locations call.
+
2018-10-31 Martin Liska <mliska@suse.cz>
* trans-decl.c (struct module_hasher): Call htab_hash_string
diff --git a/gcc/fortran/cpp.c b/gcc/fortran/cpp.c
index 3091eeb..a28421f 100644
--- a/gcc/fortran/cpp.c
+++ b/gcc/fortran/cpp.c
@@ -579,8 +579,7 @@ gfc_cpp_init (void)
{
/* 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_force_token_locations (cpp_in, BUILTINS_LOCATION);
cpp_define_builtins (cpp_in);
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index c5a0285..3e98732 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,5 +1,12 @@
2018-10-31 Nathan Sidwell <nathan@acm.org>
+ * internal.h (struct cpp_reader): Rename forced_token_location_p
+ to forced_token_location and drop its pointerness.
+ * include/cpplib.h (cpp_force_token_locations): Take location, not
+ pointer to one.
+ * init.c (cpp_create_reader): Adjust.
+ * lex.c (cpp_read_main_file):
+
* directives.c (do_include_common): Commonize cleanup path.
(_cpp_pop_buffer): Fix leak.
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
index a2dab52..aad836d 100644
--- a/libcpp/include/cpplib.h
+++ b/libcpp/include/cpplib.h
@@ -1281,7 +1281,7 @@ extern int cpp_read_state (cpp_reader *, const char *, FILE *,
struct save_macro_data *);
/* In lex.c */
-extern void cpp_force_token_locations (cpp_reader *, source_location *);
+extern void cpp_force_token_locations (cpp_reader *, source_location);
extern void cpp_stop_forcing_token_locations (cpp_reader *);
/* In expr.c */
diff --git a/libcpp/init.c b/libcpp/init.c
index 9b7490b..43c07fc 100644
--- a/libcpp/init.c
+++ b/libcpp/init.c
@@ -264,7 +264,7 @@ cpp_create_reader (enum c_lang lang, cpp_hash_table *table,
pfile->pushed_macros = 0;
/* Do not force token locations by default. */
- pfile->forced_token_location_p = NULL;
+ pfile->forced_token_location = 0;
/* Initialize source_date_epoch to -2 (not yet set). */
pfile->source_date_epoch = (time_t) -2;
diff --git a/libcpp/internal.h b/libcpp/internal.h
index 59f830c..98fefeb 100644
--- a/libcpp/internal.h
+++ b/libcpp/internal.h
@@ -570,9 +570,9 @@ struct cpp_reader
/* List of saved macros by push_macro. */
struct def_pragma_macro *pushed_macros;
- /* If non-null, the lexer will use this location for the next token
+ /* If non-zero, the lexer will use this location for the next token
instead of getting a location from the linemap. */
- source_location *forced_token_location_p;
+ source_location forced_token_location;
};
/* Character classes. Based on the more primitive macros in safe-ctype.h.
diff --git a/libcpp/lex.c b/libcpp/lex.c
index 892cfc4..c6e34b3 100644
--- a/libcpp/lex.c
+++ b/libcpp/lex.c
@@ -2757,8 +2757,8 @@ _cpp_lex_direct (cpp_reader *pfile)
}
c = *buffer->cur++;
- if (pfile->forced_token_location_p)
- result->src_loc = *pfile->forced_token_location_p;
+ if (pfile->forced_token_location)
+ result->src_loc = pfile->forced_token_location;
else
result->src_loc = linemap_position_for_column (pfile->line_table,
CPP_BUF_COLUMN (buffer, buffer->cur));
@@ -3773,14 +3773,14 @@ cpp_token_val_index (const cpp_token *tok)
}
}
-/* All tokens lexed in R after calling this function will be forced to have
- their source_location the same as the location referenced by P, until
+/* All tokens lexed in R after calling this function will be forced to
+ have their source_location to be P, until
cpp_stop_forcing_token_locations is called for R. */
void
-cpp_force_token_locations (cpp_reader *r, source_location *p)
+cpp_force_token_locations (cpp_reader *r, source_location loc)
{
- r->forced_token_location_p = p;
+ r->forced_token_location = loc;
}
/* Go back to assigning locations naturally for lexed tokens. */
@@ -3788,5 +3788,5 @@ cpp_force_token_locations (cpp_reader *r, source_location *p)
void
cpp_stop_forcing_token_locations (cpp_reader *r)
{
- r->forced_token_location_p = NULL;
+ r->forced_token_location = 0;
}