OSDN Git Service

Replace inclusion of <stdio.h> with "system.h"
[pf3gnuchains/gcc-fork.git] / gcc / diagnostic.h
1 /* Various declarations for language-independent diagnostics subroutines.
2    Copyright (C) 2000 Free Software Foundation, Inc.
3    Contributed by Gabriel Dos Reis <gdr@codesourcery.com>
4
5 This file is part of GNU CC.
6
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING.  If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.  */
21
22 #ifndef __GCC_DIAGNOSTIC_H__
23 #define __GCC_DIAGNOSTIC_H__
24
25 #include "obstack.h"
26
27 /*  Forward declarations.  */
28 typedef struct output_buffer output_buffer;
29
30 /* The type of front-end specific hook that formats trees into an
31    output_buffer.  */
32 typedef void (*printer_fn) PARAMS ((output_buffer *));
33
34 /* The output buffer datatype.  This is best seen as an abstract datatype.  */
35 struct output_buffer
36 {
37   /* Internal data.  These fields should not be accessed directly by
38      front-ends.  */
39
40   /* The obstack where the text is built up.  */  
41   struct obstack obstack;
42   /* The prefix for each new line.   */
43   const char *prefix;
44   /* The amount of characters output so far.  */  
45   int line_length;
46   /* The real upper bound of number of characters per line, taking into
47      accompt the case of a very very looong prefix.  */  
48   int maximum_length;
49   /* The ideal upper bound of number of characters per line, as suggested
50      by front-end. */  
51   int ideal_maximum_length;
52
53   /* Public fields.  These are used by front-ends to extract formats and
54      arguments from the variable argument-list passed to output_format.  */
55
56   /* The current char to output.  Updated by front-end (*format_map) when
57      it is called to report front-end printer for a specified format.  */  
58   const char *cursor;
59   /* Variable argument-list for formatting.  */  
60   va_list format_args;
61 };
62
63 /* If non-NULL, this function formats data in the BUFFER.
64    BUFFER->CURSOR points to a format code.  LANG_PRINTER should
65    call output_add_string (and related functions) to add data to
66    the BUFFER.  LANG_PRINTER can read arguments from
67    BUFFER->FORMAT_ARGS using VA_ARG.  If the BUFFER needs
68    additional characters from the format string, it should advance
69    the BUFFER->CURSOR as it goes.  When LANG_PRINTER returns,
70    BUFFER->CURSOR should point to the last character processed.  */
71
72 extern printer_fn lang_printer;
73
74 /* Prototypes */
75 void init_output_buffer         PARAMS ((output_buffer *, const char *, int));
76 void output_clear               PARAMS ((output_buffer *));
77 const char *output_get_prefix   PARAMS ((const output_buffer *));
78 void output_set_prefix          PARAMS ((output_buffer *, const char *));
79 void output_set_maximum_length  PARAMS ((output_buffer *, int));
80 void output_emit_prefix         PARAMS ((output_buffer *));
81 void output_add_newline         PARAMS ((output_buffer *));
82 void output_add_space           PARAMS ((output_buffer *));
83 int output_space_left           PARAMS ((const output_buffer *));
84 void output_append              PARAMS ((output_buffer *, const char *,
85                                          const char *));
86 void output_add_character       PARAMS ((output_buffer *, int));
87 void output_add_integer         PARAMS ((output_buffer *, HOST_WIDE_INT));
88 void output_add_string          PARAMS ((output_buffer *, const char *));
89 const char *output_finish       PARAMS ((output_buffer *));
90 void output_flush_on            PARAMS ((output_buffer *, FILE *));
91 void output_printf              PARAMS ((output_buffer *, const char *,
92                                          ...)) ATTRIBUTE_PRINTF_2;
93 void output_format              PARAMS ((output_buffer *, const char *));
94 int output_is_line_wrapping     PARAMS ((output_buffer *));
95
96 #endif /* __GCC_DIAGNOSTIC_H__ */