#undef DEFINE_DIAGNOSTIC_KIND
NULL
};
+ gcc_assert (diagnostic->kind < DK_LAST_DIAGNOSTIC_KIND);
+
const char *text = _(diagnostic_kind_text[diagnostic->kind]);
const char *text_cs = "", *text_ce = "";
const char *locus_cs, *locus_ce;
locus_cs = colorize_start (pp_show_color (pp), "locus");
locus_ce = colorize_stop (pp_show_color (pp));
- 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);
-
+ expanded_location s = diagnostic_expand_location (diagnostic);
return
(s.file == NULL
? build_message_string ("%s%s:%s %s%s%s", locus_cs, progname, locus_ce,
: context->show_column
? build_message_string ("%s%s:%d:%d:%s %s%s%s", locus_cs, s.file, s.line,
s.column, locus_ce, text_cs, text, text_ce)
- : build_message_string ("%s%s:%d:%s %s%s%s", locus_cs, s.file, s.line, locus_ce,
- text_cs, text, text_ce));
+ : build_message_string ("%s%s:%d:%s %s%s%s", locus_cs, s.file, s.line,
+ locus_ce, text_cs, text, text_ce));
}
/* If LINE is longer than MAX_WIDTH, and COLUMN is not smaller than
return;
context->last_location = diagnostic->location;
- s = expand_location_to_spelling_point (diagnostic->location);
- if (diagnostic->override_column)
- s.column = diagnostic->override_column;
+ s = diagnostic_expand_location (diagnostic);
line = location_get_source_line (s, &line_width);
if (line == NULL || s.column > line_width)
return;
void diagnostic_file_cache_fini (void);
+/* Expand the location of this diagnostic. Use this function for consistency. */
+
+static inline expanded_location
+diagnostic_expand_location (const diagnostic_info * diagnostic)
+{
+ expanded_location s
+ = expand_location_to_spelling_point (diagnostic->location);
+ if (diagnostic->override_column)
+ s.column = diagnostic->override_column;
+ return s;
+}
+
/* Pure text formatting support functions. */
extern char *file_name_as_prefix (diagnostic_context *, const char *);
pretty_printer *pp = context->printer;
const char *locus_cs = colorize_start (pp_show_color (pp), "locus");
const char *locus_ce = colorize_stop (pp_show_color (pp));
- expanded_location s = expand_location_to_spelling_point (diagnostic->location);
- if (diagnostic->override_column)
- s.column = diagnostic->override_column;
-
+ expanded_location s = diagnostic_expand_location (diagnostic);
return (s.file == NULL
? build_message_string ("%s%s:%s", locus_cs, progname, locus_ce )
: !strcmp (s.file, N_("<built-in>"))