Commit c92bcccb by Gabriel Dos Reis Committed by Gabriel Dos Reis

diagnostic.c (output_format): Recognize "%H" as a format specifier for a location_t.

	* diagnostic.c (output_format): Recognize "%H" as a format
	specifier for a location_t.
	(text_specifies_location): New function.
	(diagnostic_set_info): Use it.

From-SVN: r54584
parent 110b3faa
2002-06-13 Gabriel Dos Reis <gdr@codesourcery.com>
* diagnostic.c (output_format): Recognize "%H" as a format
specifier for a location_t.
(text_specifies_location): New function.
(diagnostic_set_info): Use it.
2002-06-13 Jeffrey Law <law@redhat.com> 2002-06-13 Jeffrey Law <law@redhat.com>
* i386.md (extenddfxf2, extenddftf2): Fix typo/thinko. * i386.md (extenddfxf2, extenddftf2): Fix typo/thinko.
......
...@@ -89,6 +89,7 @@ static void default_diagnostic_finalizer PARAMS ((diagnostic_context *, ...@@ -89,6 +89,7 @@ static void default_diagnostic_finalizer PARAMS ((diagnostic_context *,
diagnostic_info *)); diagnostic_info *));
static void error_recursion PARAMS ((diagnostic_context *)) ATTRIBUTE_NORETURN; static void error_recursion PARAMS ((diagnostic_context *)) ATTRIBUTE_NORETURN;
static bool text_specifies_location PARAMS ((text_info *, location_t *));
extern int rtl_dump_and_exit; extern int rtl_dump_and_exit;
extern int warnings_are_errors; extern int warnings_are_errors;
...@@ -495,7 +496,8 @@ output_buffer_to_stream (buffer) ...@@ -495,7 +496,8 @@ output_buffer_to_stream (buffer)
%c: character. %c: character.
%s: string. %s: string.
%%: `%'. %%: `%'.
%*.s: a substring the length of which is specified by an integer. */ %*.s: a substring the length of which is specified by an integer.
%H: location_t. */
static void static void
output_format (buffer, text) output_format (buffer, text)
output_buffer *buffer; output_buffer *buffer;
...@@ -576,6 +578,16 @@ output_format (buffer, text) ...@@ -576,6 +578,16 @@ output_format (buffer, text)
output_add_character (buffer, '%'); output_add_character (buffer, '%');
break; break;
case 'H':
{
const location_t *locus = va_arg (*text->args_ptr, location_t *);
output_add_string (buffer, "file '");
output_add_string (buffer, locus->file);
output_add_string (buffer, "', line ");
output_decimal (buffer, locus->file);
}
break;
case '.': case '.':
{ {
int n; int n;
...@@ -769,6 +781,30 @@ diagnostic_initialize (context) ...@@ -769,6 +781,30 @@ diagnostic_initialize (context)
context->warnings_are_errors_message = warnings_are_errors; context->warnings_are_errors_message = warnings_are_errors;
} }
/* Returns true if the next format specifier in TEXT is a format specifier
for a location_t. If so, update the object pointed by LOCUS to reflect
the specified location in *TEXT->args_ptr. */
static bool
text_specifies_location (text, locus)
text_info *text;
location_t *locus;
{
const char *p;
/* Skip any leading text. */
for (p = text->format_spec; *p && *p != '%'; ++p)
;
/* Extract the location information if any. */
if (*p == '%' && *++p == 'H')
{
*locus = *va_arg (*text->args_ptr, location_t *);
text->format_spec = p + 1;
return true;
}
return false;
}
void void
diagnostic_set_info (diagnostic, msgid, args, file, line, kind) diagnostic_set_info (diagnostic, msgid, args, file, line, kind)
diagnostic_info *diagnostic; diagnostic_info *diagnostic;
...@@ -780,8 +816,13 @@ diagnostic_set_info (diagnostic, msgid, args, file, line, kind) ...@@ -780,8 +816,13 @@ diagnostic_set_info (diagnostic, msgid, args, file, line, kind)
{ {
diagnostic->message.format_spec = msgid; diagnostic->message.format_spec = msgid;
diagnostic->message.args_ptr = args; diagnostic->message.args_ptr = args;
diagnostic->location.file = file; /* If the diagnostic message doesn't specify a loccation,
diagnostic->location.line = line; use FILE and LINE. */
if (!text_specifies_location (&diagnostic->message, &diagnostic->location))
{
diagnostic->location.file = file;
diagnostic->location.line = line;
}
diagnostic->kind = kind; diagnostic->kind = kind;
} }
......
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