summaryrefslogtreecommitdiff
path: root/gcc/diagnostic.c
diff options
context:
space:
mode:
authordodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>2012-04-30 11:42:00 +0000
committerdodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>2012-04-30 11:42:00 +0000
commit391076554ccd40fa818825bff3afa4c62ce2d9a9 (patch)
tree738efb08fe80b3ccdec781fe89133fc0088d90e1 /gcc/diagnostic.c
parent00abfdc0d5e2c9c3c55c6ca182c2522a6c17be0e (diff)
downloadgcc-391076554ccd40fa818825bff3afa4c62ce2d9a9.tar.gz
Make expand_location resolve to locus in main source file
Apparently, quite some places in the compiler (like the C/C++ preprocessor, the debug info machinery) expect expand_location to resolve to locations that are in the main source file, even if the token at stake comes from a macro that was defined in a header somewhere. Turning on -ftrack-macro-expansion by default was triggering a lot of failures (not necessarily related to diagnostics) because expand_location resolves to spelling locations instead. So I have changed expand_location to honour the initial expectation. In addition, I came up with the new expand_location_to_spelling_point used in diagnostic_build_prefix because the diagnostic system, on the other hand, wants to point to the location of the token where it was spelled, and then display the error context involving all the macro whose expansion led to that spelling point - if we are in the context of a macro expansion there. This seems to me like a reasonable balance. Tested and bootstrapped on x86_64-unknown-linux-gnu against trunk and whitnessed that a lot more tests were PASSing. Note that the bootstrap with -ftrack-macro-expansion exhibits other separate issues that are addressed in subsequent patches. This patch just fixes one class of problems. The patch does pass bootstrap with -ftrack-macro-expansion turned off, though. gcc/ * input.c (expand_location_1): New. Takes a parameter to choose whether to resolve the location to spelling or expansion point. Was factorized from ... (expand_location): ... here. (expand_location_to_spelling_point): New. Implemented in terms of expand_location_1. * diagnostic.c (diagnostic_build_prefix): Use the new expand_location_to_spelling_point instead of expand_location. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@186969 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/diagnostic.c')
-rw-r--r--gcc/diagnostic.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c
index 4496803f2ff..729e8654298 100644
--- a/gcc/diagnostic.c
+++ b/gcc/diagnostic.c
@@ -214,7 +214,7 @@ diagnostic_build_prefix (diagnostic_context *context,
"must-not-happen"
};
const char *text = _(diagnostic_kind_text[diagnostic->kind]);
- expanded_location s = expand_location (diagnostic->location);
+ expanded_location s = expand_location_to_spelling_point (diagnostic->location);
if (diagnostic->override_column)
s.column = diagnostic->override_column;
gcc_assert (diagnostic->kind < DK_LAST_DIAGNOSTIC_KIND);
@@ -266,7 +266,7 @@ diagnostic_show_locus (diagnostic_context * context,
|| diagnostic->location <= BUILTINS_LOCATION)
return;
- s = expand_location(diagnostic->location);
+ s = expand_location_to_spelling_point (diagnostic->location);
line = location_get_source_line (s);
if (line == NULL)
return;