summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorGabriel Dos Reis <gdr@codesourcery.com>2000-05-14 08:44:48 +0000
committerGabriel Dos Reis <gdr@gcc.gnu.org>2000-05-14 08:44:48 +0000
commit856b62442f6fc5e4302ae9ee1ebce8a19bbd8681 (patch)
treedac211226e72c1c066f0126c59594854c2e7a190 /gcc
parent54dce48b80a26bce6c05a38f2faa68ee87d41e98 (diff)
downloadgcc-856b62442f6fc5e4302ae9ee1ebce8a19bbd8681.tar.gz
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog15
-rw-r--r--gcc/cp/ChangeLog10
-rw-r--r--gcc/cp/decl2.c10
-rw-r--r--gcc/cp/lang-options.h1
-rw-r--r--gcc/cp/lex.c4
-rw-r--r--gcc/diagnostic.c35
-rw-r--r--gcc/diagnostic.h13
7 files changed, 86 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 556b7052a95..886b022d7f6 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,18 @@
+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.
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index e1ecb4729d6..be2d29539c9 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,13 @@
+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.
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index ca660e098bf..de72cc39443 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -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')
diff --git a/gcc/cp/lang-options.h b/gcc/cp/lang-options.h
index 55db2042496..232a40cbaff 100644
--- a/gcc/cp/lang-options.h
+++ b/gcc/cp/lang-options.h
@@ -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", "" },
diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c
index 34fea7e1cd4..279b42d44e4 100644
--- a/gcc/cp/lex.c
+++ b/gcc/cp/lex.c
@@ -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
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c
index 369d4a3a73d..5c498c9b599 100644
--- a/gcc/diagnostic.c
+++ b/gcc/diagnostic.c
@@ -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;
+ }
}
}
diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h
index d6a5748eb69..38edfc9c3db 100644
--- a/gcc/diagnostic.h
+++ b/gcc/diagnostic.h
@@ -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__ */