OSDN Git Service

* expr.c (init_expr_once): Don't use start/end_sequence.
[pf3gnuchains/gcc-fork.git] / gcc / diagnostic.c
index 700dd31..b4f0fad 100644 (file)
@@ -1,5 +1,5 @@
 /* Language-independent diagnostic subroutines for the GNU C compiler
-   Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
    Contributed by Gabriel Dos Reis <gdr@codesourcery.com>
 
 This file is part of GCC.
@@ -34,15 +34,19 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "toplev.h"
 #include "intl.h"
 #include "diagnostic.h"
+#include "langhooks.h"
+#include "langhooks-def.h"
 
 #define obstack_chunk_alloc xmalloc
 #define obstack_chunk_free  free
 
-#define output_formatted_integer(BUFFER, FORMAT, INTEGER) \
-  do {                                                    \
-    sprintf ((BUFFER)->digit_buffer, FORMAT, INTEGER);    \
-    output_add_string (BUFFER, (BUFFER)->digit_buffer);   \
-  } while (0)
+#define output_formatted_integer(BUFFER, FORMAT, INTEGER)      \
+  do                                                           \
+    {                                                          \
+      sprintf ((BUFFER)->digit_buffer, FORMAT, INTEGER);       \
+      output_add_string (BUFFER, (BUFFER)->digit_buffer);      \
+    }                                                          \
+  while (0)
 
 #define output_text_length(BUFFER) (BUFFER)->line_length
 #define is_starting_newline(BUFFER) (output_text_length (BUFFER) == 0)
@@ -57,7 +61,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 /* Prototypes.  */
 static void diagnostic_finish PARAMS ((output_buffer *));
 static void output_do_verbatim PARAMS ((output_buffer *,
-                                        const char *, va_list *));
+                                       const char *, va_list *));
 static void output_buffer_to_stream PARAMS ((output_buffer *));
 static void output_format PARAMS ((output_buffer *));
 static void output_indent PARAMS ((output_buffer *));
@@ -75,22 +79,22 @@ static void set_real_maximum_length PARAMS ((output_buffer *));
 static void output_unsigned_decimal PARAMS ((output_buffer *, unsigned int));
 static void output_long_decimal PARAMS ((output_buffer *, long int));
 static void output_long_unsigned_decimal PARAMS ((output_buffer *,
-                                                  long unsigned int));
+                                                 long unsigned int));
 static void output_octal PARAMS ((output_buffer *, unsigned int));
 static void output_long_octal PARAMS ((output_buffer *, unsigned long int));
 static void output_hexadecimal PARAMS ((output_buffer *, unsigned int));
 static void output_long_hexadecimal PARAMS ((output_buffer *,
-                                             unsigned long int));
+                                            unsigned long int));
 static void output_append_r PARAMS ((output_buffer *, const char *, int));
 static void wrap_text PARAMS ((output_buffer *, const char *, const char *));
 static void maybe_wrap_text PARAMS ((output_buffer *, const char *,
-                                     const char *));
+                                    const char *));
 static void clear_diagnostic_info PARAMS ((output_buffer *));
 
 static void default_diagnostic_starter PARAMS ((output_buffer *,
-                                                diagnostic_context *));
+                                               diagnostic_context *));
 static void default_diagnostic_finalizer PARAMS ((output_buffer *,
-                                                  diagnostic_context *));
+                                                 diagnostic_context *));
 
 static void error_recursion PARAMS ((void)) ATTRIBUTE_NORETURN;
 
@@ -101,9 +105,6 @@ extern int warnings_are_errors;
 static diagnostic_context global_diagnostic_context;
 diagnostic_context *global_dc = &global_diagnostic_context;
 
-/* This will be removed shortly.  */
-output_buffer *diagnostic_buffer = &global_diagnostic_context.buffer;
-
 /* Function of last error message;
    more generally, function such that if next error message is in it
    then we don't have to mention the function name.  */
@@ -112,12 +113,6 @@ static tree last_error_function = NULL;
 /* Used to detect when input_file_stack has changed since last described.  */
 static int last_error_tick;
 
-/* Called by report_error_function to print out function name.
-   Default may be overridden by language front-ends.  */
-
-void (*print_error_function) PARAMS ((diagnostic_context *, const char *))
-     = default_print_error_function;
-
 /* Prevent recursion into the error handler.  */
 static int diagnostic_lock;
 
@@ -175,13 +170,13 @@ diagnostic_initialize (context)
   diagnostic_finalizer (context) = default_diagnostic_finalizer;
 }
 
-/* Returns true if BUFFER is in line-wrappind mode.  */
+/* Returns true if BUFFER is in line-wrapping mode.  */
 
 int
 output_is_line_wrapping (buffer)
      output_buffer *buffer;
 {
-  return diagnostic_line_cutoff (buffer) > 0;
+  return output_line_cutoff (buffer) > 0;
 }
 
 /* Return BUFFER's prefix.  */
@@ -202,21 +197,21 @@ set_real_maximum_length (buffer)
 {
   /* If we're told not to wrap lines then do the obvious thing.  In case
    we'll emit prefix only once per diagnostic message, it is appropriate
-  not to increase unncessarily the line-length cut-off.  */
+  not to increase unnecessarily the line-length cut-off.  */
   if (! output_is_line_wrapping (buffer)
-      || diagnostic_prefixing_rule (buffer) == DIAGNOSTICS_SHOW_PREFIX_ONCE
-      || diagnostic_prefixing_rule (buffer) == DIAGNOSTICS_SHOW_PREFIX_NEVER)
-    line_wrap_cutoff (buffer) = diagnostic_line_cutoff (buffer);
+      || output_prefixing_rule (buffer) == DIAGNOSTICS_SHOW_PREFIX_ONCE
+      || output_prefixing_rule (buffer) == DIAGNOSTICS_SHOW_PREFIX_NEVER)
+    line_wrap_cutoff (buffer) = output_line_cutoff (buffer);
   else
     {
       int prefix_length =
-        output_prefix (buffer) ? strlen (output_prefix (buffer)) : 0;
+       output_prefix (buffer) ? strlen (output_prefix (buffer)) : 0;
       /* If the prefix is ridiculously too long, output at least
          32 characters.  */
-      if (diagnostic_line_cutoff (buffer) - prefix_length < 32)
-        line_wrap_cutoff (buffer) = diagnostic_line_cutoff (buffer) + 32;
+      if (output_line_cutoff (buffer) - prefix_length < 32)
+       line_wrap_cutoff (buffer) = output_line_cutoff (buffer) + 32;
       else
-        line_wrap_cutoff (buffer) = diagnostic_line_cutoff (buffer);
+       line_wrap_cutoff (buffer) = output_line_cutoff (buffer);
     }
 }
 
@@ -228,7 +223,7 @@ output_set_maximum_length (buffer, length)
      output_buffer *buffer;
      int length;
 {
-  diagnostic_line_cutoff (buffer) = length;
+  output_line_cutoff (buffer) = length;
   set_real_maximum_length (buffer);
 }
 
@@ -252,7 +247,7 @@ output_last_position (buffer)
      const output_buffer *buffer;
 {
   const char *p = NULL;
-  
+
   if (obstack_base (&buffer->obstack) != obstack_next_free (&buffer->obstack))
     p = ((const char *) obstack_next_free (&buffer->obstack)) - 1;
   return p;
@@ -305,11 +300,11 @@ init_output_buffer (buffer, prefix, maximum_length)
   memset (buffer, 0, sizeof (output_buffer));
   obstack_init (&buffer->obstack);
   output_buffer_attached_stream (buffer) = stderr;
-  diagnostic_line_cutoff (buffer) = maximum_length;
-  diagnostic_prefixing_rule (buffer) = diagnostic_prefixing_rule (global_dc);
+  output_line_cutoff (buffer) = maximum_length;
+  output_prefixing_rule (buffer) = diagnostic_prefixing_rule (global_dc);
   output_set_prefix (buffer, prefix);
   output_text_length (buffer) = 0;
-  clear_diagnostic_info (buffer);  
+  clear_diagnostic_info (buffer);
 }
 
 /* Reinitialize BUFFER.  */
@@ -358,29 +353,29 @@ output_emit_prefix (buffer)
 {
   if (output_prefix (buffer) != NULL)
     {
-      switch (diagnostic_prefixing_rule (buffer))
-        {
-        default:
-        case DIAGNOSTICS_SHOW_PREFIX_NEVER:
-          break;
-
-        case DIAGNOSTICS_SHOW_PREFIX_ONCE:
-          if (prefix_was_emitted_for (buffer))
-            {
-              output_indent (buffer);
-              break;
-            }
-          output_indentation (buffer) += 3;          
-          /* Fall through.  */
-
-        case DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE:
-          {
-            int prefix_length = strlen (output_prefix (buffer));
-            output_append_r (buffer, output_prefix (buffer), prefix_length);
-            prefix_was_emitted_for (buffer) = 1;
-          }
-          break;
-        }
+      switch (output_prefixing_rule (buffer))
+       {
+       default:
+       case DIAGNOSTICS_SHOW_PREFIX_NEVER:
+         break;
+
+       case DIAGNOSTICS_SHOW_PREFIX_ONCE:
+         if (prefix_was_emitted_for (buffer))
+           {
+             output_indent (buffer);
+             break;
+           }
+         output_indentation (buffer) += 3;
+         /* Fall through.  */
+
+       case DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE:
+         {
+           int prefix_length = strlen (output_prefix (buffer));
+           output_append_r (buffer, output_prefix (buffer), prefix_length);
+           prefix_was_emitted_for (buffer) = 1;
+         }
+         break;
+       }
     }
 }
 
@@ -518,8 +513,8 @@ output_append (buffer, start, end)
     {
       output_emit_prefix (buffer);
       if (output_is_line_wrapping (buffer))
-        while (start != end && *start == ' ')
-          ++start;
+       while (start != end && *start == ' ')
+         ++start;
     }
   output_append_r (buffer, start, end - start);
 }
@@ -544,30 +539,30 @@ wrap_text (buffer, start, end)
      const char *end;
 {
   int is_wrapping = output_is_line_wrapping (buffer);
-  
+
   while (start != end)
     {
-      /* Dump anything bodered by whitespaces.  */ 
+      /* Dump anything bordered by whitespaces.  */
       {
-        const char *p = start;
-        while (p != end && *p != ' ' && *p != '\n')
-          ++p;
-        if (is_wrapping && p - start >= output_space_left (buffer))
-          output_add_newline (buffer);
-        output_append (buffer, start, p);
-        start = p;
+       const char *p = start;
+       while (p != end && *p != ' ' && *p != '\n')
+         ++p;
+       if (is_wrapping && p - start >= output_space_left (buffer))
+         output_add_newline (buffer);
+       output_append (buffer, start, p);
+       start = p;
       }
 
       if (start != end && *start == ' ')
-        {
-          output_add_space (buffer);
-          ++start;
-        }
+       {
+         output_add_space (buffer);
+         ++start;
+       }
       if (start != end && *start == '\n')
-        {
-          output_add_newline (buffer);
-          ++start;
-        }
+       {
+         output_add_newline (buffer);
+         ++start;
+       }
     }
 }
 
@@ -633,110 +628,110 @@ output_format (buffer)
 
       /* Ignore text.  */
       {
-        const char *p = output_buffer_text_cursor (buffer);
-        while (*p && *p != '%')
-          ++p;
-        wrap_text (buffer, output_buffer_text_cursor (buffer), p);
-        output_buffer_text_cursor (buffer) = p;
+       const char *p = output_buffer_text_cursor (buffer);
+       while (*p && *p != '%')
+         ++p;
+       wrap_text (buffer, output_buffer_text_cursor (buffer), p);
+       output_buffer_text_cursor (buffer) = p;
       }
 
       if (!*output_buffer_text_cursor (buffer))
-        break;
+       break;
 
       /* We got a '%'.  Let's see what happens. Record whether we're
          parsing a long integer format specifier.  */
       if (*++output_buffer_text_cursor (buffer) == 'l')
-        {
-          long_integer = 1;
-          ++output_buffer_text_cursor (buffer);
-        }
+       {
+         long_integer = 1;
+         ++output_buffer_text_cursor (buffer);
+       }
 
       /* Handle %c, %d, %i, %ld, %li, %lo, %lu, %lx, %o, %s, %u,
          %x, %.*s; %%.  And nothing else.  Front-ends should install
          printers to grok language specific format specifiers.  */
       switch (*output_buffer_text_cursor (buffer))
-        {
-        case 'c':
-          output_add_character
-            (buffer, va_arg (output_buffer_format_args (buffer), int));
-          break;
-          
-        case 'd':
-        case 'i':
-          if (long_integer)
-            output_long_decimal
-              (buffer, va_arg (output_buffer_format_args (buffer), long int));
-          else
-            output_decimal
-              (buffer, va_arg (output_buffer_format_args (buffer), int));
-          break;
-
-        case 'o':
-          if (long_integer)
-            output_long_octal (buffer,
-                               va_arg (output_buffer_format_args (buffer),
-                                       unsigned long int));
-          else
-            output_octal (buffer,
-                          va_arg (output_buffer_format_args (buffer),
-                                  unsigned int));
-          break;
-
-        case 's':
-          output_add_string (buffer,
-                             va_arg (output_buffer_format_args (buffer),
-                                     const char *));
-          break;
-
-        case 'u':
-          if (long_integer)
-            output_long_unsigned_decimal
-              (buffer, va_arg (output_buffer_format_args (buffer),
-                               long unsigned int));
-          else
-            output_unsigned_decimal
-              (buffer, va_arg (output_buffer_format_args (buffer),
-                               unsigned int));
-          break;
-          
-        case 'x':
-          if (long_integer)
-            output_long_hexadecimal
-              (buffer, va_arg (output_buffer_format_args (buffer),
-                               unsigned long int));
-          else
-            output_hexadecimal
-              (buffer, va_arg (output_buffer_format_args (buffer),
-                               unsigned int));
-          break;
-
-        case '%':
-          output_add_character (buffer, '%');
-          break;
-
-        case '.':
-          {
-            int n;
-            const char *s;
-            /* We handle no precision specifier but `%.*s'.  */
-            if (*++output_buffer_text_cursor (buffer) != '*')
-              abort ();
-            else if (*++output_buffer_text_cursor (buffer) != 's')
-              abort();
-            n = va_arg (output_buffer_format_args (buffer), int);
-            s = va_arg (output_buffer_format_args (buffer), const char *);
-            output_append (buffer, s, s + n);
-          }
-          break;
-
-        default:
-          if (!buffer->format_decoder || !(*buffer->format_decoder) (buffer))
-            {
-              /* Hmmm.  The front-end failed to install a format translator
+       {
+       case 'c':
+         output_add_character
+           (buffer, va_arg (output_buffer_format_args (buffer), int));
+         break;
+
+       case 'd':
+       case 'i':
+         if (long_integer)
+           output_long_decimal
+             (buffer, va_arg (output_buffer_format_args (buffer), long int));
+         else
+           output_decimal
+             (buffer, va_arg (output_buffer_format_args (buffer), int));
+         break;
+
+       case 'o':
+         if (long_integer)
+           output_long_octal (buffer,
+                              va_arg (output_buffer_format_args (buffer),
+                                      unsigned long int));
+         else
+           output_octal (buffer,
+                         va_arg (output_buffer_format_args (buffer),
+                                 unsigned int));
+         break;
+
+       case 's':
+         output_add_string (buffer,
+                            va_arg (output_buffer_format_args (buffer),
+                                    const char *));
+         break;
+
+       case 'u':
+         if (long_integer)
+           output_long_unsigned_decimal
+             (buffer, va_arg (output_buffer_format_args (buffer),
+                              long unsigned int));
+         else
+           output_unsigned_decimal
+             (buffer, va_arg (output_buffer_format_args (buffer),
+                              unsigned int));
+         break;
+
+       case 'x':
+         if (long_integer)
+           output_long_hexadecimal
+             (buffer, va_arg (output_buffer_format_args (buffer),
+                              unsigned long int));
+         else
+           output_hexadecimal
+             (buffer, va_arg (output_buffer_format_args (buffer),
+                              unsigned int));
+         break;
+
+       case '%':
+         output_add_character (buffer, '%');
+         break;
+
+       case '.':
+         {
+           int n;
+           const char *s;
+           /* We handle no precision specifier but `%.*s'.  */
+           if (*++output_buffer_text_cursor (buffer) != '*')
+             abort ();
+           else if (*++output_buffer_text_cursor (buffer) != 's')
+             abort ();
+           n = va_arg (output_buffer_format_args (buffer), int);
+           s = va_arg (output_buffer_format_args (buffer), const char *);
+           output_append (buffer, s, s + n);
+         }
+         break;
+
+       default:
+         if (!buffer->format_decoder || !(*buffer->format_decoder) (buffer))
+           {
+             /* Hmmm.  The front-end failed to install a format translator
                  but called us with an unrecognized format.  Sorry.  */
-              abort ();
-            }
-        }
+             abort ();
+           }
+       }
     }
 }
 
@@ -752,7 +747,7 @@ vbuild_message_string (msg, ap)
 }
 
 /*  Return a malloc'd string containing MSG formatted a la
-    printf.  The caller is reponsible for freeing the memory.  */
+    printf.  The caller is responsible for freeing the memory.  */
 
 static char *
 build_message_string VPARAMS ((const char *msg, ...))
@@ -811,7 +806,7 @@ output_do_printf (buffer, msg)
      const char *msg;
 {
   char *message = vbuild_message_string (msg,
-                                         output_buffer_format_args (buffer));
+                                        output_buffer_format_args (buffer));
 
   wrap_text (buffer, message, message + strlen (message));
   free (message);
@@ -844,7 +839,7 @@ format_with_decl (buffer, decl)
      tree decl;
 {
   const char *p;
-  
+
   /* Do magic to get around lack of varargs support for insertion
      of arguments into existing list.  We know that the decl is first;
      we ass_u_me that it will be printed with "%s".  */
@@ -863,12 +858,12 @@ format_with_decl (buffer, decl)
 
   /* Print the left-hand substring.  */
   maybe_wrap_text (buffer, output_buffer_text_cursor (buffer), p);
-  
+
   if (*p == '%')               /* Print the name.  */
     {
-      const char *n = (DECL_NAME (decl)
-                ? (*decl_printable_name) (decl, 2)
-                : _("((anonymous))"));
+      const char *const n = (DECL_NAME (decl)
+                            ? (*lang_hooks.decl_printable_name) (decl, 2)
+                            : _("((anonymous))"));
       output_add_string (buffer, n);
       while (*p)
        {
@@ -912,9 +907,9 @@ diagnostic_for_decl (decl, msgid, args_ptr, warn)
       output_buffer_ptr_to_format_args (diagnostic_buffer) = args_ptr;
       output_buffer_text_cursor (diagnostic_buffer) = _(msgid);
       format_with_decl (diagnostic_buffer, decl);
-      diagnostic_finish ((output_buffer *)global_dc);
+      diagnostic_finish ((output_buffer *) global_dc);
       output_destroy_prefix (diagnostic_buffer);
-  
+
       output_buffer_state (diagnostic_buffer) = os;
     }
   diagnostic_lock--;
@@ -979,7 +974,7 @@ fatal_io_error VPARAMS ((const char *msgid, ...))
   output_buffer_ptr_to_format_args (diagnostic_buffer) = &ap;
   output_buffer_text_cursor (diagnostic_buffer) = _(msgid);
   output_format (diagnostic_buffer);
-  diagnostic_finish ((output_buffer *)global_dc);
+  diagnostic_finish ((output_buffer *) global_dc);
   output_buffer_state (diagnostic_buffer) = os;
   VA_CLOSE (ap);
   exit (FATAL_EXIT_CODE);
@@ -1049,16 +1044,16 @@ sorry VPARAMS ((const char *msgid, ...))
   VA_OPEN (ap, msgid);
   VA_FIXEDARG (ap, const char *, msgid);
 
+  ++sorrycount;
   os = output_buffer_state (diagnostic_buffer);
 
-  ++sorrycount;
   output_set_prefix
     (diagnostic_buffer, context_as_prefix (input_filename, lineno, 0));
   output_printf (diagnostic_buffer, "sorry, not implemented: ");
   output_buffer_ptr_to_format_args (diagnostic_buffer) = &ap;
   output_buffer_text_cursor (diagnostic_buffer) = _(msgid);
   output_format (diagnostic_buffer);
-  diagnostic_finish ((output_buffer *)global_dc);
+  diagnostic_finish ((output_buffer *) global_dc);
   output_buffer_state (diagnostic_buffer) = os;
   VA_CLOSE (ap);
 }
@@ -1075,7 +1070,7 @@ announce_function (decl)
       if (rtl_dump_and_exit)
        verbatim ("%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
       else
-        verbatim (" %s", (*decl_printable_name) (decl, 2));
+       verbatim (" %s", (*lang_hooks.decl_printable_name) (decl, 2));
       fflush (stderr);
       output_needs_newline (diagnostic_buffer) = 1;
       record_last_error_function ();
@@ -1086,7 +1081,7 @@ announce_function (decl)
    an error.  */
 
 void
-default_print_error_function (context, file)
+lhd_print_error_function (context, file)
      diagnostic_context *context;
      const char *file;
 {
@@ -1095,27 +1090,27 @@ default_print_error_function (context, file)
       char *prefix = file ? build_message_string ("%s: ", file) : NULL;
       output_state os;
 
-      os = output_buffer_state (context);
-      output_set_prefix ((output_buffer *)context, prefix);
-      
+      os = diagnostic_state (context);
+      output_set_prefix ((output_buffer *) context, prefix);
+
       if (current_function_decl == NULL)
-          output_add_string ((output_buffer *)context, _("At top level:"));
+       output_add_string ((output_buffer *) context, _("At top level:"));
       else
        {
          if (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
-            output_printf
-              ((output_buffer *)context, "In member function `%s':",
-               (*decl_printable_name) (current_function_decl, 2));
+           output_printf
+             ((output_buffer *) context, "In member function `%s':",
+              (*lang_hooks.decl_printable_name) (current_function_decl, 2));
          else
-            output_printf
-              ((output_buffer *)context, "In function `%s':",
-               (*decl_printable_name) (current_function_decl, 2));
+           output_printf
+             ((output_buffer *) context, "In function `%s':",
+              (*lang_hooks.decl_printable_name) (current_function_decl, 2));
        }
-      output_add_newline ((output_buffer *)context);
+      output_add_newline ((output_buffer *) context);
 
       record_last_error_function ();
-      output_buffer_to_stream ((output_buffer *)context);
-      output_buffer_state (context) = os;
+      output_buffer_to_stream ((output_buffer *) context);
+      diagnostic_state (context) = os;
       free ((char*) prefix);
     }
 }
@@ -1128,8 +1123,8 @@ void
 report_error_function (file)
   const char *file ATTRIBUTE_UNUSED;
 {
-  report_problematic_module ((output_buffer *)global_dc);
-  (*print_error_function) (global_dc, input_filename);
+  report_problematic_module ((output_buffer *) global_dc);
+  (*lang_hooks.print_error_function) (global_dc, input_filename);
 }
 
 void
@@ -1221,16 +1216,18 @@ internal_error VPARAMS ((const char *msgid, ...))
   if (diagnostic_lock)
     error_recursion ();
 
+#ifndef ENABLE_CHECKING
   if (errorcount > 0 || sorrycount > 0)
     {
       fnotice (stderr, "%s:%d: confused by earlier errors, bailing out\n",
               input_filename, lineno);
       exit (FATAL_EXIT_CODE);
     }
+#endif
 
   if (internal_error_function != 0)
     (*internal_error_function) (_(msgid), &ap);
-  
+
   set_diagnostic_context
     (&dc, msgid, &ap, input_filename, lineno, /* warn = */0);
   report_diagnostic (&dc);
@@ -1296,7 +1293,7 @@ diagnostic_finish (buffer)
   fflush (output_buffer_attached_stream (buffer));
 }
 
-/* Helper subroutine of output_verbatim and verbatim. Do the approriate
+/* Helper subroutine of output_verbatim and verbatim. Do the appropriate
    settings needed by BUFFER for a verbatim formatting.  */
 
 static void
@@ -1309,7 +1306,7 @@ output_do_verbatim (buffer, msgid, args_ptr)
 
   os = output_buffer_state (buffer);
   output_prefix (buffer) = NULL;
-  diagnostic_prefixing_rule (buffer) = DIAGNOSTICS_SHOW_PREFIX_NEVER;
+  output_prefixing_rule (buffer) = DIAGNOSTICS_SHOW_PREFIX_NEVER;
   output_buffer_text_cursor (buffer) = _(msgid);
   output_buffer_ptr_to_format_args (buffer) = args_ptr;
   output_set_maximum_length (buffer, 0);
@@ -1366,7 +1363,7 @@ report_diagnostic (dc)
       (*diagnostic_starter (dc)) (diagnostic_buffer, dc);
       output_format (diagnostic_buffer);
       (*diagnostic_finalizer (dc)) (diagnostic_buffer, dc);
-      diagnostic_finish ((output_buffer *)global_dc);
+      diagnostic_finish ((output_buffer *) global_dc);
       output_buffer_state (diagnostic_buffer) = os;
     }
 
@@ -1382,7 +1379,7 @@ static void
 error_recursion ()
 {
   if (diagnostic_lock < 3)
-    diagnostic_finish ((output_buffer *)global_dc);
+    diagnostic_finish ((output_buffer *) global_dc);
 
   fnotice (stderr,
           "Internal compiler error: Error reporting routines re-entered.\n");
@@ -1492,10 +1489,10 @@ report_problematic_module (buffer)
       for (p = input_file_stack->next; p; p = p->next)
        if (p == input_file_stack->next)
          output_verbatim
-            (buffer, "In file included from %s:%d", p->name, p->line);
+           (buffer, "In file included from %s:%d", p->name, p->line);
        else
          output_verbatim
-            (buffer, ",\n                 from %s:%d", p->name, p->line);
+           (buffer, ",\n                 from %s:%d", p->name, p->line);
       output_verbatim (buffer, ":\n");
       record_last_error_module ();
     }
@@ -1508,9 +1505,9 @@ default_diagnostic_starter (buffer, dc)
 {
   report_error_function (diagnostic_file_location (dc));
   output_set_prefix (buffer,
-                     context_as_prefix (diagnostic_file_location (dc),
-                                        diagnostic_line_location (dc),
-                                        diagnostic_is_warning (dc)));
+                    context_as_prefix (diagnostic_file_location (dc),
+                                       diagnostic_line_location (dc),
+                                       diagnostic_is_warning (dc)));
 }
 
 static void
@@ -1520,3 +1517,41 @@ default_diagnostic_finalizer (buffer, dc)
 {
   output_destroy_prefix (buffer);
 }
+
+void
+warn_deprecated_use (node)
+     tree node;
+{
+  if (node == 0 || !warn_deprecated_decl)
+    return;
+
+  if (DECL_P (node))
+    warning ("`%s' is deprecated (declared at %s:%d)",
+            IDENTIFIER_POINTER (DECL_NAME (node)),
+            DECL_SOURCE_FILE (node), DECL_SOURCE_LINE (node));
+  else if (TYPE_P (node))
+    {
+      const char *what = NULL;
+      tree decl = TYPE_STUB_DECL (node);
+
+      if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
+       what = IDENTIFIER_POINTER (TYPE_NAME (node));
+      else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
+              && DECL_NAME (TYPE_NAME (node)))
+       what = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node)));
+
+      if (what)
+       {
+         if (decl)
+           warning ("`%s' is deprecated (declared at %s:%d)", what,
+                    DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
+         else
+           warning ("`%s' is deprecated", what);
+       }
+      else if (decl)
+       warning ("type is deprecated (declared at %s:%d)",
+                DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
+      else
+       warning ("type is deprecated");
+    }
+}