OSDN Git Service

* crontab: Spread snapshot building more evenly throughout the
[pf3gnuchains/gcc-fork.git] / gcc / pretty-print.c
index 3f5b4f1..f20a8de 100644 (file)
@@ -1,5 +1,5 @@
 /* Various declarations for language-independent pretty-print subroutines.
-   Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
    Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
 
 This file is part of GCC.
@@ -26,6 +26,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "coretypes.h"
 #include "intl.h"
 #include "pretty-print.h"
+#include "tree.h"
 
 #define obstack_chunk_alloc xmalloc
 #define obstack_chunk_free  free
@@ -165,6 +166,40 @@ pp_base_indent (pretty_printer *pp)
     pp_space (pp);
 }
 
+/* Prepare PP to format a message pointed to by TEXT, with tentative
+   location LOCUS.  It is expected that a call to pp_format_text with
+   exactly the same PP and TEXT arguments will follow.  This routine
+   may modify the data in memory at TEXT and LOCP, and if it does,
+   caller is expected to notice.
+
+   Currently, all this does is notice a %H or %J escape at the beginning
+   of the string, and update LOCUS to match.  */
+void
+pp_base_prepare_to_format (pretty_printer *pp ATTRIBUTE_UNUSED,
+                          text_info *text,
+                          location_t *locus)
+{
+  const char *p = text->format_spec;
+  tree t;
+
+  /* Extract the location information if any.  */
+  if (p[0] == '%')
+    switch (p[1])
+      {
+      case 'H':
+       *locus = *va_arg (*text->args_ptr, location_t *);
+       text->format_spec = p + 2;
+       break;
+
+      case 'J':
+       t = va_arg (*text->args_ptr, tree);
+       *locus = DECL_SOURCE_LOCATION (t);
+       text->format_spec = p + 2;
+       break;
+      }
+}
+
+
 /* Format a message pointed to by TEXT.  The following format specifiers are
    recognized as being client independent:
    %d, %i: (signed) integer in base ten.
@@ -322,6 +357,7 @@ pp_base_format_text (pretty_printer *pp, text_info *text)
            gcc_assert (*text->format_spec == '*');
            ++text->format_spec;
            gcc_assert (*text->format_spec == 's');
+
            n = va_arg (*text->args_ptr, int);
            s = va_arg (*text->args_ptr, const char *);
            pp_append_text (pp, s, s + n);
@@ -331,13 +367,10 @@ pp_base_format_text (pretty_printer *pp, text_info *text)
        default:
          {
            bool ok;
-
-           /* Make sure there's a format translator. */
+           
            gcc_assert (pp_format_decoder (pp));
            ok = pp_format_decoder (pp) (pp, text);
-           /* and make sure it recognized the format.  */
            gcc_assert (ok);
-           break;
          }
        }
       if (quoted)
@@ -573,7 +606,7 @@ pp_base_string (pretty_printer *pp, const char *str)
   pp_maybe_wrap_text (pp, str, str + (str ? strlen (str) : 0));
 }
 
-/* Maybe print out a whitespace if needed.   */
+/* Maybe print out a whitespace if needed.  */
 
 void
 pp_base_maybe_space (pretty_printer *pp)