]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR ada/23717 ([Ada] Wrong ICE diagnostic formatting)
authorRichard Guenther <rguenther@suse.de>
Sat, 19 Nov 2005 17:24:33 +0000 (17:24 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Sat, 19 Nov 2005 17:24:33 +0000 (17:24 +0000)
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

gcc/ada/ChangeLog
gcc/ada/misc.c

index 99ec072897071657ab4f82684a24bd55006851d4..60ed170784f1de2b11a92a079eef439011ba1ada 100644 (file)
@@ -1,3 +1,11 @@
+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.
+
 2005-11-18  Laurent GUERBY  <laurent@guerby.net>
 
         PR ada/24857
index 819e27572a9d63b15ae3038dcc43bf51ea7ddd8e..0971808712c887428928c47f538688ef2444362d 100644 (file)
@@ -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);