Commit 764dbbf2 by Gabriel Dos Reis Committed by Gabriel Dos Reis

diagnostic.c (output_maximum_width): Remove.

2000-06-06  Gabriel Dos Reis  <gdr@codesourcery.com>

        * diagnostic.c (output_maximum_width): Remove.
        (doing_line_wrapping): Tweak.
        (diagnostic_buffer): New object.
        (global_output_buffer): New object.
        (output_destroy_prefix): New function.
        (default_initialize_buffer): Likewise.
        (reshape_diagnostic_buffer): Likewise.
        (initialize_diagnostics): Likewise.
        (output_clear): Tweak.
        (line_wrapper_printf): Adjust call to init_output_buffer.
        (vline_wrapper_message_with_location): Likewise.  Use
        output_destroy_prefix.
        (v_message_with_decl): Likewise.

        * diagnostic.h (struct output_buffer): Constify prefix.
        (init_output_buffer, output_get_prefix): Constify.
        (diagnostic_message_length_per_line): Likewise.
        (reshape_diagnostic_buffer): Declare.
        (default_initialize_buffer): Declare.
        (initialize_diagnostics): Declare.
        (diagnostic_buffer): Declare new obbject.

        * toplev.c: #include diagnostic.h
        (display_help): Document diagnostic formatting options.
        (decode_f_option): Handle diagnostic formatting options.
        (main): Setup initialization for diagnostic messages outputter.

        * toplev.h (set_message_length): Remove.

        * Makefile.in (toplev.o): Depends upon diagnostic.h

        * invoke.texi : Document diagnostics formatting options.

cp/
2000-06-06  Gabriel Dos Reis  <gdr@codesourcery.com>

        * lex.c (lang_init_options): Tweak.

        * decl2.c: Remove #inclusion of diagnostic.h
        (lang_decode_option): Move diagnostic formatting options to
        toplevel.

        * lang-options.h: Remove documentation for diagnostic options.

        * Makefile.in (lex.o): Depends upon diagnostic.h

From-SVN: r34435
parent 93136754
2000-06-06 Gabriel Dos Reis <gdr@codesourcery.com>
* diagnostic.c (output_maximum_width): Remove.
(doing_line_wrapping): Tweak.
(diagnostic_buffer): New object.
(global_output_buffer): New object.
(output_destroy_prefix): New function.
(default_initialize_buffer): Likewise.
(reshape_diagnostic_buffer): Likewise.
(initialize_diagnostics): Likewise.
(output_clear): Tweak.
(line_wrapper_printf): Adjust call to init_output_buffer.
(vline_wrapper_message_with_location): Likewise. Use
output_destroy_prefix.
(v_message_with_decl): Likewise.
* diagnostic.h (struct output_buffer): Constify prefix.
(init_output_buffer, output_get_prefix): Constify.
(diagnostic_message_length_per_line): Likewise.
(reshape_diagnostic_buffer): Declare.
(default_initialize_buffer): Declare.
(initialize_diagnostics): Declare.
(diagnostic_buffer): Declare new obbject.
* toplev.c: #include diagnostic.h
(display_help): Document diagnostic formatting options.
(decode_f_option): Handle diagnostic formatting options.
(main): Setup initialization for diagnostic messages outputter.
* toplev.h (set_message_length): Remove.
* Makefile.in (toplev.o): Depends upon diagnostic.h
* invoke.texi : Document diagnostics formatting options.
Tue Jun 6 19:25:32 2000 Philippe De Muyter <phdm@macqel.be>
* configure.in (Make the links): Typo fix : the file that must be
......
......@@ -1231,7 +1231,7 @@ diagnostic.o : diagnostic.c diagnostic.h \
$(CONFIG_H) system.h $(TREE_H) $(RTL_H) tm_p.h flags.h \
$(GGC_H) input.h insn-attr.h insn-codes.h insn-config.h toplev.h intl.h
toplev.o : toplev.c $(CONFIG_H) system.h $(TREE_H) $(RTL_H) function.h \
flags.h input.h insn-attr.h xcoffout.h defaults.h output.h \
flags.h input.h insn-attr.h xcoffout.h defaults.h output.h diagnostic.h \
insn-codes.h insn-config.h intl.h $(RECOG_H) Makefile toplev.h dwarfout.h \
dwarf2out.h sdbout.h dbxout.h $(EXPR_H) hard-reg-set.h $(BASIC_BLOCK_H) \
graph.h loop.h except.h regs.h $(TIMEVAR_H) $(lang_options_files)
......
2000-06-06 Gabriel Dos Reis <gdr@codesourcery.com>
* lex.c (lang_init_options): Tweak.
* decl2.c: Remove #inclusion of diagnostic.h
(lang_decode_option): Move diagnostic formatting options to
toplevel.
* lang-options.h: Remove documentation for diagnostic options.
* Makefile.in (lex.o): Depends upon diagnostic.h
2000-06-06 Mark Mitchell <mark@codesourcery.com>
* decl.c (redeclaration_error_message): If two TEMPLATE_DECLs have
......
......@@ -254,7 +254,7 @@ lex.o : lex.c $(CXX_TREE_H) \
$(PARSE_H) input.c $(srcdir)/../flags.h hash.h lex.h \
$(srcdir)/../c-pragma.h $(srcdir)/../toplev.h \
$(srcdir)/../output.h $(srcdir)/../mbchar.h $(GGC_H) \
$(srcdir)/../input.h operators.def
$(srcdir)/../input.h $(srcdir)/../diagnostic.h operators.def
decl.o : decl.c $(CXX_TREE_H) $(srcdir)/../flags.h \
lex.h decl.h $(srcdir)/../stack.h $(srcdir)/../output.h $(srcdir)/../expr.h \
$(srcdir)/../except.h $(srcdir)/../toplev.h \
......
......@@ -45,7 +45,6 @@ Boston, MA 02111-1307, USA. */
#include "dwarfout.h"
#include "ggc.h"
#include "timevar.h"
#include "diagnostic.h"
#if USE_CPPLIB
#include "cpplib.h"
......@@ -679,21 +678,6 @@ lang_decode_option (argc, argv)
name_mangling_version
= read_integral_parameter (option_value, p - 2, name_mangling_version);
else if ((option_value
= skip_leading_substring (p, "message-length=")))
set_message_length
(read_integral_parameter (option_value, p - 2,
/* default line-wrap length */ 72));
else if ((option_value
= skip_leading_substring (p, "diagnostics-show-location=")))
{
if (!strcmp (option_value, "once"))
set_message_prefixing_rule (DIAGNOSTICS_SHOW_PREFIX_ONCE);
else if (!strcmp (option_value, "every-line"))
set_message_prefixing_rule (DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE);
else
error ("Unrecognized option `%s'", p - 2);
}
else if ((option_value
= skip_leading_substring (p, "dump-translation-unit-")))
{
if (p[22] == '\0')
......
......@@ -74,8 +74,6 @@ DEFINE_LANG_NAME ("C++")
{ "-flabels-ok", "Labels can be used as first class objects" },
{ "-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", "" },
......
......@@ -392,7 +392,7 @@ lang_init_options ()
/* Mark as "unspecified". */
flag_bounds_check = -1;
/* By default wrap lines at 72 characters. */
set_message_length (72);
diagnostic_message_length_per_line = 72;
/* By default, emit location information once for every
diagnostic message. */
set_message_prefixing_rule (DIAGNOSTICS_SHOW_PREFIX_ONCE);
......
......@@ -89,6 +89,10 @@ extern int errorcount;
/* Front-end specific tree formatter, if non-NULL. */
printer_fn lang_printer = NULL;
/* An output_buffer surrogate for stderr. */
static output_buffer global_output_buffer;
output_buffer *diagnostic_buffer = &global_output_buffer;
static int need_error_newline;
/* Function of last error message;
......@@ -108,27 +112,30 @@ void (*print_error_function) PARAMS ((const char *)) =
/* Maximum characters per line in automatic line wrapping mode.
Zero means don't wrap lines. */
static int output_maximum_width = 0;
int diagnostic_message_length_per_line;
/* Used to control every diagnostic message formatting. Front-ends should
call set_message_prefixing_rule to set up their politics. */
static int current_prefixing_rule = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE;
static int current_prefixing_rule;
/* Predicate. Return 1 if we're in automatic line wrapping mode. */
/* Initialize the diagnostic message outputting machinery. */
static int
doing_line_wrapping ()
void
initialize_diagnostics ()
{
return output_maximum_width > 0;
/* By default, we don't line-wrap messages. */
diagnostic_message_length_per_line = 0;
set_message_prefixing_rule (DIAGNOSTICS_SHOW_PREFIX_ONCE);
/* Proceed to actual initialization. */
default_initialize_buffer (diagnostic_buffer);
}
/* Set Maximum characters per line in automatic line wrapping mode. */
/* Predicate. Return 1 if we're in automatic line wrapping mode. */
void
set_message_length (n)
int n;
static int
doing_line_wrapping ()
{
output_maximum_width = n;
return diagnostic_message_length_per_line > 0;
}
void
......@@ -147,7 +154,7 @@ output_is_line_wrapping (buffer)
}
/* Return BUFFER's prefix. */
char *
const char *
output_get_prefix (buffer)
const output_buffer *buffer;
{
......@@ -190,19 +197,32 @@ output_set_maximum_length (buffer, length)
void
output_set_prefix (buffer, prefix)
output_buffer *buffer;
char *prefix;
const char *prefix;
{
buffer->prefix = prefix;
set_real_maximum_length (buffer);
buffer->emitted_prefix_p = 0;
}
/* Free BUFFER's prefix, a previously malloc()'d string. */
void
output_destroy_prefix (buffer)
output_buffer *buffer;
{
if (buffer->prefix)
{
free ((char *) buffer->prefix);
buffer->prefix = NULL;
}
}
/* Construct an output BUFFER with PREFIX and of MAXIMUM_LENGTH
characters per line. */
void
init_output_buffer (buffer, prefix, maximum_length)
output_buffer *buffer;
char *prefix;
const char *prefix;
int maximum_length;
{
obstack_init (&buffer->obstack);
......@@ -215,6 +235,25 @@ init_output_buffer (buffer, prefix, maximum_length)
buffer->cursor = NULL;
}
/* Initialize BUFFER with a NULL prefix and current diagnostic message
length cutoff. */
void
default_initialize_buffer (buffer)
output_buffer *buffer;
{
init_output_buffer (buffer, NULL, diagnostic_message_length_per_line);
}
/* Recompute diagnostic_buffer's attributes to reflect any change
in diagnostic formatting global options. */
void
reshape_diagnostic_buffer ()
{
diagnostic_buffer->ideal_maximum_length = diagnostic_message_length_per_line;
diagnostic_buffer->prefixing_rule = current_prefixing_rule;
set_real_maximum_length (diagnostic_buffer);
}
/* Reinitialize BUFFER. */
void
output_clear (buffer)
......@@ -223,6 +262,7 @@ output_clear (buffer)
obstack_free (&buffer->obstack, obstack_base (&buffer->obstack));
buffer->line_length = 0;
buffer->cursor = NULL;
buffer->emitted_prefix_p = 0;
}
/* Finishes to construct a NULL-terminated character string representing
......@@ -541,7 +581,7 @@ line_wrapper_printf VPARAMS ((FILE *file, const char *msgid, ...))
#endif
output_buffer buffer;
init_output_buffer (&buffer, NULL, output_maximum_width);
init_output_buffer (&buffer, NULL, diagnostic_message_length_per_line);
VA_START (buffer.format_args, msgid);
#ifndef ANSI_PROTOTYPES
......@@ -567,12 +607,12 @@ vline_wrapper_message_with_location (file, line, warn, msgid, ap)
output_buffer buffer;
init_output_buffer (&buffer, build_location_prefix (file, line, warn),
output_maximum_width);
diagnostic_message_length_per_line);
va_copy (buffer.format_args, ap);
output_notice (&buffer, msgid);
output_flush_on (&buffer, stderr);
free (output_get_prefix (&buffer));
output_destroy_prefix (&buffer);
fputc ('\n', stderr);
}
......@@ -657,7 +697,7 @@ v_message_with_decl (decl, warn, msgid, ap)
init_output_buffer
(&buffer, build_location_prefix
(DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl), warn),
output_maximum_width);
diagnostic_message_length_per_line);
}
else
report_file_and_line (DECL_SOURCE_FILE (decl),
......@@ -720,7 +760,7 @@ v_message_with_decl (decl, warn, msgid, ap)
if (doing_line_wrapping())
{
output_flush_on (&buffer, stderr);
free (output_get_prefix (&buffer));
output_destroy_prefix (&buffer);
}
fputc ('\n', stderr);
......@@ -1176,7 +1216,8 @@ default_print_error_function (file)
prefix = build_message_string ("%s: ", file);
if (doing_line_wrapping ())
init_output_buffer (&buffer, prefix, output_maximum_width);
init_output_buffer
(&buffer, prefix, diagnostic_message_length_per_line);
else
{
if (file)
......
......@@ -44,7 +44,7 @@ struct output_buffer
/* The obstack where the text is built up. */
struct obstack obstack;
/* The prefix for each new line. */
char *prefix;
const char *prefix;
/* The amount of characters output so far. */
int line_length;
/* The real upper bound of number of characters per line, taking into
......@@ -83,11 +83,24 @@ struct output_buffer
extern printer_fn lang_printer;
extern int diagnostic_message_length_per_line;
/* This output buffer is used by front-ends that directly output
diagnostic messages without going through `error', `warning',
and simillar functions. In general, such usage should be
avoided. This global buffer will go away, once all such usage
has been removed. */
extern output_buffer *diagnostic_buffer;
/* Prototypes */
void init_output_buffer PARAMS ((output_buffer *, char *, int));
void initialize_diagnostics PARAMS ((void));
void reshape_diagnostic_buffer PARAMS ((void));
void default_initialize_buffer PARAMS ((output_buffer *));
void init_output_buffer PARAMS ((output_buffer *, const char *, int));
void output_clear PARAMS ((output_buffer *));
char *output_get_prefix PARAMS ((const output_buffer *));
void output_set_prefix PARAMS ((output_buffer *, char *));
const char *output_get_prefix PARAMS ((const output_buffer *));
void output_set_prefix PARAMS ((output_buffer *, const char *));
void output_destroy_prefix PARAMS ((output_buffer *));
void output_set_maximum_length PARAMS ((output_buffer *, int));
void output_emit_prefix PARAMS ((output_buffer *));
void output_add_newline PARAMS ((output_buffer *));
......
......@@ -59,6 +59,8 @@ only one of these two forms, whichever one is not the default.
* Invoking G++:: Compiling C++ programs.
* C Dialect Options:: Controlling the variant of C language compiled.
* C++ Dialect Options:: Variations on C++.
* Language Independent Options:: Controlling how diagnostics should be
formatted.
* Warning Options:: How picky should the compiler be?
* Debugging Options:: Symbol tables, measurements, and debugging dumps.
* Optimize Options:: How much optimization?
......@@ -116,6 +118,13 @@ in the following sections.
-Wsign-promo -Wsynth
@end smallexample
@item Language Independent Options
@xref{Language Independent Options,,Options to Control Diagnostic Messages Formatting}.
@smallexample
-fmessage-length=@var{n}
-fdiagnostics-show-location=@r{[}once@r{|}every-line@r{]}
@end smallexample
@item Warning Options
@xref{Warning Options,,Options to Request or Suppress Warnings}.
@smallexample
......@@ -467,6 +476,8 @@ in the following sections.
or preprocessed source.
* C Dialect Options:: Controlling the variant of C language compiled.
* C++ Dialect Options:: Variations on C++.
* Language Independent Options:: Controlling how diagnostics should be
formatted.
* Warning Options:: How picky should the compiler be?
* Debugging Options:: Symbol tables, measurements, and debugging dumps.
* Optimize Options:: How much optimization?
......@@ -1120,12 +1131,6 @@ This flag is not useful when compiling with -fvtable-thunks.
Like all options that change the ABI, all C++ code, @emph{including
libgcc} must be built with the same setting of this option.
@item -fmessage-length=@var{n}
Try to format error messages so that they fit on lines of about @var{n}
characters. The default is 72 characters. If @var{n} is zero, then no
line-wrapping will be done; each error message will appear on a single
line.
@item -fno-implicit-templates
Never emit code for non-inline templates which are instantiated
implicitly (i.e. by use); only emit code for explicit instantiations.
......@@ -1367,6 +1372,44 @@ In this example, g++ will synthesize a default @samp{A& operator =
(const A&);}, while cfront will use the user-defined @samp{operator =}.
@end table
@node Language Independent Options
@section Options to Control Diagnostic Messages Formatting
@cindex options to control diagnostics formatting
@cindex diagnostic messages
@cindex message formatting
Traditionally, diagnostic messages have been formatted irrespetive of
the output device's aspect (e.g. its width, ...). The options described
below can be used to control the diagnostic messages formatting
algorithm, e.g. how many characters per line, how often source location
information should be reported. Right now, only the C++ front-end can
honor these options. However it is expected, in the near future, that
the remaining front-ends would be able to digest them correctly.
@table @code
@item -fmessage-length=@var{n}
Try to format error messages so that they fit on lines of about @var{n}
characters. The default is 72 characters for g++ and 0 for the rest of
the front-ends supported by GCC. If @var{n} is zero, then no
line-wrapping will be done; each error message will appear on a single
line.
@item -fdiagnostics-show-location=once
Only meaningful in line-wrapping mode. Intructs the diagnostic messages
reporter to emit @emph{once} source location information; that is, in
case the message is too long to fit on a single physical line and has to
be wrapped, the source location won't be emitted (as prefix) again,
over and over, in subsequent continuation lines. This is the default
behaviour.
@item -fdiagnostics-show-location=every-line
Only meaningful in line-wrapping mode. Instructs the diagnostic
messages reporter to emit the same source location information (as
prefix) for physical lines that result from the process of breaking a
a message which is too long to fit on a signe line.
@end table
@node Warning Options
@section Options to Request or Suppress Warnings
@cindex options to control warnings
......
......@@ -62,6 +62,7 @@ Boston, MA 02111-1307, USA. */
#include "loop.h"
#include "regs.h"
#include "timevar.h"
#include "diagnostic.h"
#ifndef ACCUMULATE_OUTGOING_ARGS
#define ACCUMULATE_OUTGOING_ARGS 0
......@@ -3703,6 +3704,8 @@ display_help ()
printf (" -fcall-used-<register> Mark <register> as being corrupted by function calls\n");
printf (" -fcall-saved-<register> Mark <register> as being preserved across functions\n");
printf (" -finline-limit=<number> Limits the size of inlined functions to <number>\n");
printf (" -fmessage-length=<number> Limits diagnostics messages lengths to <number> characters per line. 0 suppresses line-wrapping\n");
printf (" -fdiagnostics-show-location=[once | never] Indicates how often source location information should be emitted, as prefix, at the beginning of diagnostics when line-wrapping\n");
for (i = NUM_ELEM (f_options); i--;)
{
......@@ -3990,6 +3993,21 @@ decode_f_option (arg)
nm = xstrdup (option_value);
stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, nm);
}
else if ((option_value
= skip_leading_substring (arg, "message-length=")))
diagnostic_message_length_per_line =
read_integral_parameter (option_value, arg - 2,
diagnostic_message_length_per_line);
else if ((option_value
= skip_leading_substring (arg, "diagnostics-show-location=")))
{
if (!strcmp (option_value, "once"))
set_message_prefixing_rule (DIAGNOSTICS_SHOW_PREFIX_ONCE);
else if (!strcmp (option_value, "every-line"))
set_message_prefixing_rule (DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE);
else
error ("Unrecognized option `%s'", arg - 2);
}
else if (!strcmp (arg, "no-stack-limit"))
stack_limit_rtx = NULL_RTX;
else if (!strcmp (arg, "preprocessed"))
......@@ -4433,6 +4451,9 @@ main (argc, argv)
ggc_add_tree_root (&current_function_decl, 1);
ggc_add_tree_root (&current_function_func_begin_label, 1);
/* Initialize the diagnostics reporting machinery. */
initialize_diagnostics();
/* Perform language-specific options intialization. */
lang_init_options ();
......@@ -4589,6 +4610,9 @@ main (argc, argv)
i++;
}
}
/* Reflect any language-specific diagnostic option setting. */
reshape_diagnostic_buffer ();
/* Checker uses the frame pointer. */
if (flag_check_memory_usage)
......
......@@ -134,7 +134,6 @@ extern void fnotice PARAMS ((FILE *, const char *, ...))
extern int wrapup_global_declarations PARAMS ((union tree_node **, int));
extern void check_global_declarations PARAMS ((union tree_node **, int));
extern void note_deferral_of_defined_inline_function PARAMS ((union tree_node *));
extern void set_message_length PARAMS ((int));
extern int errorcount;
extern int warningcount;
extern int sorrycount;
......
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