C++ err msgs
Gabriel Dos Reis
gdr@codesourcery.com
Fri May 12 16:06:00 GMT 2000
Benjamin Kosnik <bkoz@cygnus.com> writes:
| Hmmmmmm. Gaby, now you have me all excited. Do you have any pointers
| to what's the current ideas/approaches are? I know Ulrich and I talked
| a long long time ago about some kind of state-based system where the
| end user could set environment variables (or bits in the specs file)
| to set up things like column width, details on the header display
| (display once, display every line, don't display, etc.) and then
| formatting information (seems best to have some kind of lang-specific
| dialect for this part.)
[...]
The following patch makes it possible not to emit the _same_ prefix over
and over. It adds the option
-fdiagnostics-show-location=<option>
where <option> is one of:
o once: the prefix is emitted once, nnot repeated on subsequent
lines in case the message is wrapped. This is now the default.
o every-line: keeps the behaviour we've been seeing right now.
Bootstrapped and tested on i686-pc-gnu-linux
OK?
-- Gaby
CodeSourcery, LLC http://www.codesourcery.com
2000-05-13 Gabriel Dos Reis <gdr@codesourcery.com>
* diagnostic.h (DIAGNOSTICS_SHOW_PREFIX_ONCE): New macro.
(DIAGNOSTICS_SHOW_PREFIX_NEVER): Likewise.
(DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE): Likewise.
(struct output_buffer: emitted_prefix_p, prefixing_rule): New
fields.
(set_message_prefixing_rule): Declare.
* diagnostic.c: (current_prefixing_rule): New variable.
(set_message_prefixing_rule): Define.
(output_set_prefix): Adjust buffer->emitted_prefix_p.
(init_output_buffer): Adjust Initialization.
(output_emit_prefix): Rewrite. Take prefixing rules into account.
cp/
2000-05-13 Gabriel Dos Reis <gdr@codesourcery.com>
* lex.c: #include diagnostic.h.
(lang_init_options): Set default prefixing rules.
* lang-options.h: Add -fdiagnostics-show-location=.
* decl2.c: #include diagnostic.h.
(lang_decode_option): Handle -fdiagnostics-show-location=.
Index: diagnostic.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/diagnostic.h,v
retrieving revision 1.2
diff -p -r1.2 diagnostic.h
*** diagnostic.h 2000/05/04 17:58:40 1.2
--- diagnostic.h 2000/05/12 22:13:54
*************** Boston, MA 02111-1307, USA. */
*** 27,32 ****
--- 27,36 ----
/* Forward declarations. */
typedef struct output_buffer output_buffer;
+ #define DIAGNOSTICS_SHOW_PREFIX_ONCE 0x0
+ #define DIAGNOSTICS_SHOW_PREFIX_NEVER 0x1
+ #define DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE 0x2
+
/* The type of front-end specific hook that formats trees into an
output_buffer. */
typedef void (*printer_fn) PARAMS ((output_buffer *));
*************** struct output_buffer
*** 49,54 ****
--- 53,66 ----
/* The ideal upper bound of number of characters per line, as suggested
by front-end. */
int ideal_maximum_length;
+ /* Nonzero if current PREFIX was emitted at least once. */
+ int emitted_prefix_p;
+ /* Tells how often current PREFIX should be emitted:
+ o DIAGNOSTICS_SHOW_PREFIX_NEVER: never - not yet supported;
+ o DIAGNOSTICS_SHOW_PREFIX_ONCE: emit current PREFIX only once;
+ o DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE: emit current PREFIX each time
+ a physical line is started. */
+ int prefixing_rule;
/* Public fields. These are used by front-ends to extract formats and
arguments from the variable argument-list passed to output_format. */
*************** void output_printf PARAMS ((output_buff
*** 92,96 ****
--- 104,109 ----
...)) ATTRIBUTE_PRINTF_2;
void output_format PARAMS ((output_buffer *, const char *));
int output_is_line_wrapping PARAMS ((output_buffer *));
+ void set_message_prefixing_rule PARAMS ((int));
#endif /* __GCC_DIAGNOSTIC_H__ */
Index: diagnostic.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/diagnostic.c,v
retrieving revision 1.13
diff -p -r1.13 diagnostic.c
*** diagnostic.c 2000/05/04 17:58:40 1.13
--- diagnostic.c 2000/05/12 22:13:54
*************** void (*print_error_function) PARAMS ((co
*** 109,114 ****
--- 109,118 ----
Zero means don't wrap lines. */
static int output_maximum_width = 0;
+
+ /* Used to control every diagnostic message formatting. Front-ends should
+ call set_message_prefixing_rule to set up their politics. */
+ static current_prefixing_rule = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE;
/* Predicate. Return 1 if we're in automatic line wrapping mode. */
*************** set_message_length (n)
*** 127,132 ****
--- 131,143 ----
output_maximum_width = n;
}
+ void
+ set_message_prefixing_rule (rule)
+ int rule;
+ {
+ current_prefixing_rule = rule;
+ }
+
/* Returns true if BUFFER is in line-wrappind mode. */
int
output_is_line_wrapping (buffer)
*************** output_set_prefix (buffer, prefix)
*** 183,188 ****
--- 194,200 ----
{
buffer->prefix = prefix;
set_real_maximum_length (buffer);
+ buffer->emitted_prefix_p = 0;
}
/* Construct an output BUFFER with PREFIX and of MAXIMUM_LENGTH
*************** init_output_buffer (buffer, prefix, maxi
*** 197,202 ****
--- 209,216 ----
buffer->ideal_maximum_length = maximum_length;
buffer->line_length = 0;
output_set_prefix (buffer, prefix);
+ buffer->emitted_prefix_p = 0;
+ buffer->prefixing_rule = current_prefixing_rule;
buffer->cursor = NULL;
}
*************** output_emit_prefix (buffer)
*** 237,244 ****
{
if (buffer->prefix)
{
! buffer->line_length = strlen (buffer->prefix);
! obstack_grow (&buffer->obstack, buffer->prefix, buffer->line_length);
}
}
--- 251,275 ----
{
if (buffer->prefix)
{
! switch (buffer->prefixing_rule)
! {
! default:
! case DIAGNOSTICS_SHOW_PREFIX_NEVER:
! break;
!
! case DIAGNOSTICS_SHOW_PREFIX_ONCE:
! if (buffer->emitted_prefix_p)
! break;
! else
! buffer->emitted_prefix_p = 1;
! /* Fall through. */
!
! case DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE:
! buffer->line_length += strlen (buffer->prefix);
! obstack_grow
! (&buffer->obstack, buffer->prefix, buffer->line_length);
! break;
! }
}
}
Index: cp/decl2.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl2.c,v
retrieving revision 1.345
diff -p -r1.345 decl2.c
*** decl2.c 2000/05/09 19:55:50 1.345
--- decl2.c 2000/05/12 22:13:55
*************** Boston, MA 02111-1307, USA. */
*** 45,50 ****
--- 45,51 ----
#include "dwarfout.h"
#include "ggc.h"
#include "timevar.h"
+ #include "diagnostic.h"
#if USE_CPPLIB
#include "cpplib.h"
*************** lang_decode_option (argc, argv)
*** 648,653 ****
--- 649,663 ----
set_message_length
(read_integral_parameter (p + 15, p - 2,
/* default line-wrap length */ 72));
+ else if (!strncmp (p, "diagnostics-show-location=", 24))
+ {
+ if (!strncmp (p + 24, "once", 4))
+ set_message_prefixing_rule (DIAGNOSTICS_SHOW_PREFIX_ONCE);
+ else if (!strncmp (p + 24, "every-line", 10))
+ set_message_prefixing_rule (DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE);
+ else
+ error ("Unrecognized option `%s'", p - 2);
+ }
else if (!strncmp (p, "dump-translation-unit-", 22))
{
if (p[22] == '\0')
Index: cp/lang-options.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/lang-options.h,v
retrieving revision 1.34
diff -p -r1.34 lang-options.h
*** lang-options.h 2000/04/11 06:01:53 1.34
--- lang-options.h 2000/05/12 22:13:55
*************** DEFINE_LANG_NAME ("C++")
*** 75,80 ****
--- 75,81 ----
{ "-fno-labels-ok", "" },
{ "-fmemoize-lookups", "" },
{ "-fmessage-length=", "" },
+ { "-fdiagnostics-show-location=", "" },
{ "-fno-memoize-lookups", "" },
{ "-fms-extensions", "Don't pedwarn about uses of Microsoft extensions" },
{ "-fno-ms-extensions", "" },
Index: cp/lex.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/lex.c,v
retrieving revision 1.196
diff -p -r1.196 lex.c
*** lex.c 2000/05/09 19:55:50 1.196
--- lex.c 2000/05/12 22:13:56
*************** Boston, MA 02111-1307, USA. */
*** 41,46 ****
--- 41,47 ----
#include "ggc.h"
#include "tm_p.h"
#include "timevar.h"
+ #include "diagnostic.h"
#ifdef MULTIBYTE_CHARS
#include "mbchar.h"
*************** lang_init_options ()
*** 441,446 ****
--- 442,450 ----
flag_bounds_check = -1;
/* By default wrap lines at 72 characters. */
set_message_length (72);
+ /* By default, emit location information once for every
+ diagnostic message. */
+ set_message_prefixing_rule (DIAGNOSTICS_SHOW_PREFIX_ONCE);
}
void
More information about the Libstdc++
mailing list