aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/misc.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2005-11-19 17:24:33 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2005-11-19 17:24:33 +0000
commit452b5b1e53bb7d0fafaab7c09685981041f2fa16 (patch)
tree1df2987ac2d6ce55215925a440abb6e64d6806f4 /gcc/ada/misc.c
parent756191b7c51263603b91b45f60d5d6acf7250711 (diff)
downloadgcc-452b5b1e53bb7d0fafaab7c09685981041f2fa16.zip
gcc-452b5b1e53bb7d0fafaab7c09685981041f2fa16.tar.gz
gcc-452b5b1e53bb7d0fafaab7c09685981041f2fa16.tar.bz2
re PR ada/23717 ([Ada] Wrong ICE diagnostic formatting)
2005-11-19 Richard Guenther <rguenther@suse.de> Roger Sayle <roger@eyesopen.com> PR ada/23717 * misc.c (internal_error_function): Don't use vsprintf to format the error message text, instead use pp_format_text and the new pretty printer APIs. This allows handling of %qs, %w, etc. Co-Authored-By: Roger Sayle <roger@eyesopen.com> From-SVN: r107223
Diffstat (limited to 'gcc/ada/misc.c')
-rw-r--r--gcc/ada/misc.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/gcc/ada/misc.c b/gcc/ada/misc.c
index 819e275..0971808 100644
--- a/gcc/ada/misc.c
+++ b/gcc/ada/misc.c
@@ -364,12 +364,23 @@ gnat_post_options (const char **pfilename ATTRIBUTE_UNUSED)
static void
internal_error_function (const char *msgid, va_list *ap)
{
- char buffer[1000]; /* Assume this is big enough. */
+ text_info tinfo;
+ char *buffer;
char *p;
String_Template temp;
Fat_Pointer fp;
- vsprintf (buffer, msgid, *ap);
+ /* Reset the pretty-printer. */
+ pp_clear_output_area (global_dc->printer);
+
+ /* Format the message into the pretty-printer. */
+ tinfo.format_spec = msgid;
+ tinfo.args_ptr = ap;
+ tinfo.err_no = errno;
+ pp_format_verbatim (global_dc->printer, &tinfo);
+
+ /* Extract a (writable) pointer to the formatted text. */
+ buffer = (char*) pp_formatted_text (global_dc->printer);
/* Go up to the first newline. */
for (p = buffer; *p; p++)
@@ -379,8 +390,10 @@ internal_error_function (const char *msgid, va_list *ap)
break;
}
- temp.Low_Bound = 1, temp.High_Bound = strlen (buffer);
- fp.Array = buffer, fp.Bounds = &temp;
+ temp.Low_Bound = 1;
+ temp.High_Bound = p - buffer;
+ fp.Bounds = &temp;
+ fp.Array = buffer;
Current_Error_Node = error_gnat_node;
Compiler_Abort (fp, -1);