Commit 856b6244 by Gabriel Dos Reis Committed by Gabriel Dos Reis

diagnostic.h (DIAGNOSTICS_SHOW_PREFIX_ONCE): New macro.

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=.

From-SVN: r33890
parent 54dce48b
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.
Sat May 13 11:05:47 2000 Philippe De Muyter <phdm@macqel.be>
* ifcvt.c (if_convert): Do not free NULL.
......
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=.
2000-05-12 Nathan Sidwell <nathan@codesourcery.com>
* tinfo.cc: Revert my 2000-05-08 and 2000-05-07 changes.
......
......@@ -45,6 +45,7 @@ Boston, MA 02111-1307, USA. */
#include "dwarfout.h"
#include "ggc.h"
#include "timevar.h"
#include "diagnostic.h"
#if USE_CPPLIB
#include "cpplib.h"
......@@ -648,6 +649,15 @@ lang_decode_option (argc, argv)
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')
......
......@@ -75,6 +75,7 @@ DEFINE_LANG_NAME ("C++")
{ "-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", "" },
......
......@@ -41,6 +41,7 @@ Boston, MA 02111-1307, USA. */
#include "ggc.h"
#include "tm_p.h"
#include "timevar.h"
#include "diagnostic.h"
#ifdef MULTIBYTE_CHARS
#include "mbchar.h"
......@@ -441,6 +442,9 @@ lang_init_options ()
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
......
......@@ -109,6 +109,10 @@ void (*print_error_function) PARAMS ((const char *)) =
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. */
......@@ -127,6 +131,13 @@ set_message_length (n)
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)
......@@ -183,6 +194,7 @@ output_set_prefix (buffer, prefix)
{
buffer->prefix = prefix;
set_real_maximum_length (buffer);
buffer->emitted_prefix_p = 0;
}
/* Construct an output BUFFER with PREFIX and of MAXIMUM_LENGTH
......@@ -197,6 +209,8 @@ init_output_buffer (buffer, prefix, maximum_length)
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;
}
......@@ -237,8 +251,25 @@ output_emit_prefix (buffer)
{
if (buffer->prefix)
{
buffer->line_length = strlen (buffer->prefix);
obstack_grow (&buffer->obstack, buffer->prefix, buffer->line_length);
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;
}
}
}
......
......@@ -27,6 +27,10 @@ Boston, MA 02111-1307, USA. */
/* 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 *));
......@@ -49,6 +53,14 @@ struct output_buffer
/* 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. */
......@@ -92,5 +104,6 @@ void output_printf PARAMS ((output_buffer *, const char *,
...)) 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__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment