Skip to content

Commit 048062e

Browse files
author
nathan
committed
[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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@265692 138bc75d-0d04-0410-961f-82ee72b054a4
1 parent b544100 commit 048062e

File tree

9 files changed

+28
-15
lines changed

9 files changed

+28
-15
lines changed

gcc/c-family/ChangeLog

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2018-10-31 Nathan Sidwell <[email protected]>
2+
3+
* c-opts.c (c_finish_options): Adjust cpp_force_token_locations call.
4+
15
2018-10-30 Martin Sebor <[email protected]>
26

37
PR middle-end/87041

gcc/c-family/c-opts.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -1396,8 +1396,7 @@ c_finish_options (void)
13961396
0)));
13971397
/* Make sure all of the builtins about to be declared have
13981398
BUILTINS_LOCATION has their source_location. */
1399-
source_location builtins_loc = BUILTINS_LOCATION;
1400-
cpp_force_token_locations (parse_in, &builtins_loc);
1399+
cpp_force_token_locations (parse_in, BUILTINS_LOCATION);
14011400

14021401
cpp_init_builtins (parse_in, flag_hosted);
14031402
c_cpp_builtins (parse_in);

gcc/fortran/ChangeLog

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2018-10-31 Nathan Sidwell <[email protected]>
2+
3+
* cpp.c (gfc_cpp_init): Adjust cpp_force_token_locations call.
4+
15
2018-10-31 Martin Liska <[email protected]>
26

37
* trans-decl.c (struct module_hasher): Call htab_hash_string

gcc/fortran/cpp.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,7 @@ gfc_cpp_init (void)
579579
{
580580
/* Make sure all of the builtins about to be declared have
581581
BUILTINS_LOCATION has their source_location. */
582-
source_location builtins_loc = BUILTINS_LOCATION;
583-
cpp_force_token_locations (cpp_in, &builtins_loc);
582+
cpp_force_token_locations (cpp_in, BUILTINS_LOCATION);
584583

585584
cpp_define_builtins (cpp_in);
586585

libcpp/ChangeLog

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
2018-10-31 Nathan Sidwell <[email protected]>
22

3+
* internal.h (struct cpp_reader): Rename forced_token_location_p
4+
to forced_token_location and drop its pointerness.
5+
* include/cpplib.h (cpp_force_token_locations): Take location, not
6+
pointer to one.
7+
* init.c (cpp_create_reader): Adjust.
8+
* lex.c (cpp_read_main_file):
9+
310
* directives.c (do_include_common): Commonize cleanup path.
411
(_cpp_pop_buffer): Fix leak.
512

libcpp/include/cpplib.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,7 @@ extern int cpp_read_state (cpp_reader *, const char *, FILE *,
12811281
struct save_macro_data *);
12821282

12831283
/* In lex.c */
1284-
extern void cpp_force_token_locations (cpp_reader *, source_location *);
1284+
extern void cpp_force_token_locations (cpp_reader *, source_location);
12851285
extern void cpp_stop_forcing_token_locations (cpp_reader *);
12861286

12871287
/* In expr.c */

libcpp/init.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ cpp_create_reader (enum c_lang lang, cpp_hash_table *table,
264264
pfile->pushed_macros = 0;
265265

266266
/* Do not force token locations by default. */
267-
pfile->forced_token_location_p = NULL;
267+
pfile->forced_token_location = 0;
268268

269269
/* Initialize source_date_epoch to -2 (not yet set). */
270270
pfile->source_date_epoch = (time_t) -2;

libcpp/internal.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -570,9 +570,9 @@ struct cpp_reader
570570
/* List of saved macros by push_macro. */
571571
struct def_pragma_macro *pushed_macros;
572572

573-
/* If non-null, the lexer will use this location for the next token
573+
/* If non-zero, the lexer will use this location for the next token
574574
instead of getting a location from the linemap. */
575-
source_location *forced_token_location_p;
575+
source_location forced_token_location;
576576
};
577577

578578
/* Character classes. Based on the more primitive macros in safe-ctype.h.

libcpp/lex.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -2757,8 +2757,8 @@ _cpp_lex_direct (cpp_reader *pfile)
27572757
}
27582758
c = *buffer->cur++;
27592759

2760-
if (pfile->forced_token_location_p)
2761-
result->src_loc = *pfile->forced_token_location_p;
2760+
if (pfile->forced_token_location)
2761+
result->src_loc = pfile->forced_token_location;
27622762
else
27632763
result->src_loc = linemap_position_for_column (pfile->line_table,
27642764
CPP_BUF_COLUMN (buffer, buffer->cur));
@@ -3773,20 +3773,20 @@ cpp_token_val_index (const cpp_token *tok)
37733773
}
37743774
}
37753775

3776-
/* All tokens lexed in R after calling this function will be forced to have
3777-
their source_location the same as the location referenced by P, until
3776+
/* All tokens lexed in R after calling this function will be forced to
3777+
have their source_location to be P, until
37783778
cpp_stop_forcing_token_locations is called for R. */
37793779

37803780
void
3781-
cpp_force_token_locations (cpp_reader *r, source_location *p)
3781+
cpp_force_token_locations (cpp_reader *r, source_location loc)
37823782
{
3783-
r->forced_token_location_p = p;
3783+
r->forced_token_location = loc;
37843784
}
37853785

37863786
/* Go back to assigning locations naturally for lexed tokens. */
37873787

37883788
void
37893789
cpp_stop_forcing_token_locations (cpp_reader *r)
37903790
{
3791-
r->forced_token_location_p = NULL;
3791+
r->forced_token_location = 0;
37923792
}

0 commit comments

Comments
 (0)