aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2020-11-23 07:34:17 -0800
committerNathan Sidwell <nathan@acm.org>2020-11-23 07:37:42 -0800
commit204b61b906f2f806eec2f7bb72d4dd79c88d688a (patch)
tree9cb01aa480ffc7396b5095b14e4919461ded0ac9
parentff1c10c1c5a617f99ea737185aed2c52277c0cab (diff)
downloadgcc-204b61b906f2f806eec2f7bb72d4dd79c88d688a.zip
gcc-204b61b906f2f806eec2f7bb72d4dd79c88d688a.tar.gz
gcc-204b61b906f2f806eec2f7bb72d4dd79c88d688a.tar.bz2
Diagnostic for module importation
This tweaks the 'included from ...' printing to deal with imports in the 'include' path. One new thing is that there can now be two 'include' names on a single line. For example 'in module X, included at Y'. This reads better than placing them on different lines. gcc/ * diagnostic.c (diagnostic_report_current_module): Adjust for C++ module importation.
-rw-r--r--gcc/diagnostic.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c
index 1b6c984..fe509d8 100644
--- a/gcc/diagnostic.c
+++ b/gcc/diagnostic.c
@@ -689,12 +689,13 @@ diagnostic_report_current_module (diagnostic_context *context, location_t where)
set_last_module (context, map);
if (! MAIN_FILE_P (map))
{
- bool first = true;
+ bool first = true, need_inc = true, was_module = MAP_MODULE_P (map);
expanded_location s = {};
do
{
where = linemap_included_from (map);
map = linemap_included_from_linemap (line_table, map);
+ bool is_module = MAP_MODULE_P (map);
s.file = LINEMAP_FILE (map);
s.line = SOURCE_LINE (map, where);
int col = -1;
@@ -706,14 +707,24 @@ diagnostic_report_current_module (diagnostic_context *context, location_t where)
const char *line_col = maybe_line_and_column (s.line, col);
static const char *const msgs[] =
{
- N_("In file included from"),
+ NULL,
N_(" from"),
+ N_("In file included from"), /* 2 */
+ N_(" included from"),
+ N_("In module"), /* 4 */
+ N_("of module"),
+ N_("In module imported at"), /* 6 */
+ N_("imported at"),
};
- unsigned index = !first;
+
+ unsigned index = (was_module ? 6 : is_module ? 4
+ : need_inc ? 2 : 0) + !first;
+
pp_verbatim (context->printer, "%s%s %r%s%s%R",
- first ? "" : ",\n", _(msgs[index]),
+ first ? "" : was_module ? ", " : ",\n",
+ _(msgs[index]),
"locus", s.file, line_col);
- first = false;
+ first = false, need_inc = was_module, was_module = is_module;
}
while (! MAIN_FILE_P (map));
pp_verbatim (context->printer, ":");