diff options
author | Nathan Sidwell <nathan@acm.org> | 2018-08-08 18:13:00 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2018-08-08 18:13:00 +0000 |
commit | f10a91352f83232394646df5a67bdb8f4366a067 (patch) | |
tree | a4ec7ecbde7bfc84329e5a2bb1dc8dea689d7d31 /gcc | |
parent | a801991954f70fb9470502d305065719849c5660 (diff) | |
download | gcc-f10a91352f83232394646df5a67bdb8f4366a067.zip gcc-f10a91352f83232394646df5a67bdb8f4366a067.tar.gz gcc-f10a91352f83232394646df5a67bdb8f4366a067.tar.bz2 |
[PATCH] line-map include-from representation
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg00554.html
Make linemap::included_from a location
libcpp/
* include/line-map.h (struct line_map_ordinary): Replace
included_from map index with included_at source_location.
(ORDINARY_MAP_INCLUDER_FILE_INDEX): Delete.
(LAST_SOURCE_LINE_LOCATION): Delete.
(LAST_SOURCE_LINE, LAST_SOURCE_COLUMN): Delete.
(linemap_included_from): New.
(linemap_included_from_linemap): Declare.
(MAIN_FILE_P): Adjust.
* line-map.c (linemap_included_from_linemap): New.
(lonemap_check_files_exited): Use linemap_included_at.
(linemap_add): Adjust inclusion setting.
(linemap_dump, linemap_dump_location): Adjust.
* directives.c (do_linemarker): Use linemap_included_at.
gcc/
* diagnostic.c (diagnostic_report_current_module): Use
linemap_included_from & linemap_included_from_linemap.
gcc/c-family/
* c-common.c (try_to_locate_new_include_inertion_point): Use
linemap_included_from_linemap.
* c-lex.c (fe_file_change): Use linemap_included_from.
* c-ppoutput.c (pp_file_change): Likewise.
gcc/fortran/
* cpp.c (cb_file_change): Use linemap_included_from.
gcc/testsuite/
* c-c++-common/inc-from-1a.h, c-c++-common/inc-from-1b.h,
c-c++-common/inc-from-1.c: New
From-SVN: r263429
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c-family/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/c-family/c-common.c | 4 | ||||
-rw-r--r-- | gcc/c-family/c-lex.c | 2 | ||||
-rw-r--r-- | gcc/c-family/c-ppoutput.c | 6 | ||||
-rw-r--r-- | gcc/diagnostic.c | 5 | ||||
-rw-r--r-- | gcc/fortran/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/fortran/cpp.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/inc-from-1.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/inc-from-1a.h | 1 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/inc-from-1b.h | 1 |
12 files changed, 37 insertions, 13 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3c9aea6..64704bc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-08-08 Nathan Sidwell <nathan@acm.org> + + * diagnostic.c (diagnostic_report_current_module): Use + linemap_included_from & linemap_included_from_linemap. + 2018-08-08 Hongbo Zhang <hongbo.zhang@linaro.org> * config/aarch64/aarch64-cores.def: Add phecda core. diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index d5e5fff..aa7aada 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,10 @@ +2018-08-08 Nathan Sidwell <nathan@acm.org> + + * c-common.c (try_to_locate_new_include_inertion_point): Use + linemap_included_from_linemap. + * c-lex.c (fe_file_change): Use linemap_included_from. + * c-ppoutput.c (pp_file_change): Likewise. + 2018-08-01 Martin Sebor <msebor@redhat.com> PR tree-optimization/86650 diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index d919605..91e60f3 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -8413,8 +8413,8 @@ try_to_locate_new_include_insertion_point (const char *file, location_t loc) const line_map_ordinary *ord_map = LINEMAPS_ORDINARY_MAP_AT (line_table, i); - const line_map_ordinary *from = INCLUDED_FROM (line_table, ord_map); - if (from) + if (const line_map_ordinary *from + = linemap_included_from_linemap (line_table, ord_map)) if (from->to_file == file) { last_include_ord_map = from; diff --git a/gcc/c-family/c-lex.c b/gcc/c-family/c-lex.c index 074c2d2..ac58335c 100644 --- a/gcc/c-family/c-lex.c +++ b/gcc/c-family/c-lex.c @@ -199,7 +199,7 @@ fe_file_change (const line_map_ordinary *new_map) we already did in compile_file. */ if (!MAIN_FILE_P (new_map)) { - unsigned int included_at = LAST_SOURCE_LINE_LOCATION (new_map - 1); + location_t included_at = linemap_included_from (new_map); int line = 0; if (included_at > BUILTINS_LOCATION) line = SOURCE_LINE (new_map - 1, included_at); diff --git a/gcc/c-family/c-ppoutput.c b/gcc/c-family/c-ppoutput.c index 8c525caf..b8fc1c6 100644 --- a/gcc/c-family/c-ppoutput.c +++ b/gcc/c-family/c-ppoutput.c @@ -663,11 +663,9 @@ pp_file_change (const line_map_ordinary *map) /* Bring current file to correct line when entering a new file. */ if (map->reason == LC_ENTER) { - const line_map_ordinary *from = INCLUDED_FROM (line_table, map); - maybe_print_line (LAST_SOURCE_LINE_LOCATION (from)); + maybe_print_line (linemap_included_from (map)); + flags = " 1"; } - if (map->reason == LC_ENTER) - flags = " 1"; else if (map->reason == LC_LEAVE) flags = " 2"; print_line (map->start_location, flags); diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index 5205944..3d7f164 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -590,9 +590,10 @@ diagnostic_report_current_module (diagnostic_context *context, location_t where) bool first = true; do { - map = INCLUDED_FROM (line_table, map); + where = linemap_included_from (map); + map = linemap_included_from_linemap (line_table, map); const char *line_col - = maybe_line_and_column (LAST_SOURCE_LINE (map), + = maybe_line_and_column (SOURCE_LINE (map, where), first && context->show_column ? SOURCE_COLUMN (map, where) : 0); static const char *const msgs[] = diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index db0fe9d..7051509 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,7 @@ +2018-08-08 Nathan Sidwell <nathan@acm.org> + + * cpp.c (cb_file_change): Use linemap_included_from. + 2018-08-07 Cesar Philippidis <cesar@codesourcery.com> * trans-stmt.h: Remove stale reference to trans-openacc.c. diff --git a/gcc/fortran/cpp.c b/gcc/fortran/cpp.c index 82e890f..4320461 100644 --- a/gcc/fortran/cpp.c +++ b/gcc/fortran/cpp.c @@ -881,10 +881,7 @@ cb_file_change (cpp_reader * ARG_UNUSED (pfile), const line_map_ordinary *map) { /* Bring current file to correct line when entering a new file. */ if (map->reason == LC_ENTER) - { - const line_map_ordinary *from = INCLUDED_FROM (line_table, map); - maybe_print_line (LAST_SOURCE_LINE_LOCATION (from)); - } + maybe_print_line (linemap_included_from (map)); if (map->reason == LC_ENTER) flags = " 1"; else if (map->reason == LC_LEAVE) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 472e6a9..12f8425 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-08-08 Nathan Sidwell <nathan@acm.org> + + * c-c++-common/inc-from-1a.h, c-c++-common/inc-from-1b.h, + c-c++-common/inc-from-1.c: New + 2018-08-08 Andreas Krebbel <krebbel@linux.ibm.com> PR target/85295 diff --git a/gcc/testsuite/c-c++-common/inc-from-1.c b/gcc/testsuite/c-c++-common/inc-from-1.c new file mode 100644 index 0000000..7e95c2a --- /dev/null +++ b/gcc/testsuite/c-c++-common/inc-from-1.c @@ -0,0 +1,5 @@ +#include "inc-from-1b.h" + +/* { dg-error "" "" { target *-*-* } 1 } */ + +/* { dg-regexp "In file included from \[^\n]*inc-from-1b.h:1,\n *from \[^\n]*inc-from-1.c:1:\n" } */ diff --git a/gcc/testsuite/c-c++-common/inc-from-1a.h b/gcc/testsuite/c-c++-common/inc-from-1a.h new file mode 100644 index 0000000..684e812 --- /dev/null +++ b/gcc/testsuite/c-c++-common/inc-from-1a.h @@ -0,0 +1 @@ +void bleah; diff --git a/gcc/testsuite/c-c++-common/inc-from-1b.h b/gcc/testsuite/c-c++-common/inc-from-1b.h new file mode 100644 index 0000000..40fae4a --- /dev/null +++ b/gcc/testsuite/c-c++-common/inc-from-1b.h @@ -0,0 +1 @@ +#include "inc-from-1a.h" |