error.c (gfc_diagnostic_build_locus_prefix): Use diagnostic_expand_location.

gcc/fortran/ChangeLog:

2014-12-05  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	* error.c (gfc_diagnostic_build_locus_prefix): Use
	diagnostic_expand_location.

gcc/ChangeLog:

2014-12-05  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	* diagnostic.h (diagnostic_expand_location): New inline function.
	* diagnostic.c (diagnostic_build_prefix): Use it.
	(diagnostic_show_locus): Likewise.

From-SVN: r218409
parent 1be71446
2014-12-05 Manuel López-Ibáñez <manu@gcc.gnu.org>
* diagnostic.h (diagnostic_expand_location): New inline function.
* diagnostic.c (diagnostic_build_prefix): Use it.
(diagnostic_show_locus): Likewise.
2014-12-04 H.J. Lu <hongjiu.lu@intel.com> 2014-12-04 H.J. Lu <hongjiu.lu@intel.com>
PR bootstrap/64189 PR bootstrap/64189
...@@ -260,6 +260,8 @@ diagnostic_build_prefix (diagnostic_context *context, ...@@ -260,6 +260,8 @@ diagnostic_build_prefix (diagnostic_context *context,
#undef DEFINE_DIAGNOSTIC_KIND #undef DEFINE_DIAGNOSTIC_KIND
NULL NULL
}; };
gcc_assert (diagnostic->kind < DK_LAST_DIAGNOSTIC_KIND);
const char *text = _(diagnostic_kind_text[diagnostic->kind]); const char *text = _(diagnostic_kind_text[diagnostic->kind]);
const char *text_cs = "", *text_ce = ""; const char *text_cs = "", *text_ce = "";
const char *locus_cs, *locus_ce; const char *locus_cs, *locus_ce;
...@@ -274,11 +276,7 @@ diagnostic_build_prefix (diagnostic_context *context, ...@@ -274,11 +276,7 @@ diagnostic_build_prefix (diagnostic_context *context,
locus_cs = colorize_start (pp_show_color (pp), "locus"); locus_cs = colorize_start (pp_show_color (pp), "locus");
locus_ce = colorize_stop (pp_show_color (pp)); locus_ce = colorize_stop (pp_show_color (pp));
expanded_location s = expand_location_to_spelling_point (diagnostic->location); expanded_location s = diagnostic_expand_location (diagnostic);
if (diagnostic->override_column)
s.column = diagnostic->override_column;
gcc_assert (diagnostic->kind < DK_LAST_DIAGNOSTIC_KIND);
return return
(s.file == NULL (s.file == NULL
? build_message_string ("%s%s:%s %s%s%s", locus_cs, progname, locus_ce, ? build_message_string ("%s%s:%s %s%s%s", locus_cs, progname, locus_ce,
...@@ -289,8 +287,8 @@ diagnostic_build_prefix (diagnostic_context *context, ...@@ -289,8 +287,8 @@ diagnostic_build_prefix (diagnostic_context *context,
: context->show_column : context->show_column
? build_message_string ("%s%s:%d:%d:%s %s%s%s", locus_cs, s.file, s.line, ? 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) 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, : build_message_string ("%s%s:%d:%s %s%s%s", locus_cs, s.file, s.line,
text_cs, text, text_ce)); locus_ce, text_cs, text, text_ce));
} }
/* If LINE is longer than MAX_WIDTH, and COLUMN is not smaller than /* If LINE is longer than MAX_WIDTH, and COLUMN is not smaller than
...@@ -337,9 +335,7 @@ diagnostic_show_locus (diagnostic_context * context, ...@@ -337,9 +335,7 @@ diagnostic_show_locus (diagnostic_context * context,
return; return;
context->last_location = diagnostic->location; context->last_location = diagnostic->location;
s = expand_location_to_spelling_point (diagnostic->location); s = diagnostic_expand_location (diagnostic);
if (diagnostic->override_column)
s.column = diagnostic->override_column;
line = location_get_source_line (s, &line_width); line = location_get_source_line (s, &line_width);
if (line == NULL || s.column > line_width) if (line == NULL || s.column > line_width)
return; return;
......
...@@ -297,6 +297,18 @@ void diagnostic_set_caret_max_width (diagnostic_context *context, int value); ...@@ -297,6 +297,18 @@ void diagnostic_set_caret_max_width (diagnostic_context *context, int value);
void diagnostic_file_cache_fini (void); 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. */ /* Pure text formatting support functions. */
extern char *file_name_as_prefix (diagnostic_context *, const char *); extern char *file_name_as_prefix (diagnostic_context *, const char *);
......
2014-12-05 Manuel López-Ibáñez <manu@gcc.gnu.org> 2014-12-05 Manuel López-Ibáñez <manu@gcc.gnu.org>
* error.c (gfc_diagnostic_build_locus_prefix): Use
diagnostic_expand_location.
2014-12-05 Manuel López-Ibáñez <manu@gcc.gnu.org>
* scanner.c (gfc_next_char_literal): Use gfc_warning_now. * scanner.c (gfc_next_char_literal): Use gfc_warning_now.
(load_file): Use the line length as the column hint for (load_file): Use the line length as the column hint for
linemap_line_start. Reserve a location for the highest column of linemap_line_start. Reserve a location for the highest column of
......
...@@ -1143,10 +1143,7 @@ gfc_diagnostic_build_locus_prefix (diagnostic_context *context, ...@@ -1143,10 +1143,7 @@ gfc_diagnostic_build_locus_prefix (diagnostic_context *context,
pretty_printer *pp = context->printer; pretty_printer *pp = context->printer;
const char *locus_cs = colorize_start (pp_show_color (pp), "locus"); const char *locus_cs = colorize_start (pp_show_color (pp), "locus");
const char *locus_ce = colorize_stop (pp_show_color (pp)); const char *locus_ce = colorize_stop (pp_show_color (pp));
expanded_location s = expand_location_to_spelling_point (diagnostic->location); expanded_location s = diagnostic_expand_location (diagnostic);
if (diagnostic->override_column)
s.column = diagnostic->override_column;
return (s.file == NULL return (s.file == NULL
? build_message_string ("%s%s:%s", locus_cs, progname, locus_ce ) ? build_message_string ("%s%s:%s", locus_cs, progname, locus_ce )
: !strcmp (s.file, N_("<built-in>")) : !strcmp (s.file, N_("<built-in>"))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment