From 2a2b2d432ebd677d4232eb07666e3be4ea668c5d Mon Sep 17 00:00:00 2001 From: Gabriel Dos Reis Date: Sun, 10 Jun 2001 13:48:04 +0000 Subject: [PATCH] Makefile.in (c-parse.o): Depend on diagnostic.h gcc/ 2001-06-10 Mark Mitchell Gabriel Dos Reis * Makefile.in (c-parse.o): Depend on diagnostic.h (dwarf2out.o): Likewise. * dwarf2out.c: #include diagnostic.h * toplev.h (warningcount, errorcount, sorrycount): Remove declarations. * toplev.c (warningcount, errorcount, sorrycount): Remove definitions. * diagnostic.h (struct output_buffer): Reorder fields. (diagnostic_kind_count): New macro. (errorcount, warningcount, sorrycount): Define as macros. (diagnostic_report_warnings_p): New macro. (output_state): Add diagnostic_count field. * diagnostic.c (warningcount, errorcount, inhibit_warnings): Remove tentative declaration. (count_error): Use diagnostic_report_warnings_p. * c-parse.in: #include diagnostic.h ch/ 2001-06-10 Gabriel Dos Reis * decl.c: #include diagnostic.h * actions.c: #include diagnostic.h * Makefile.in (actions.o): Depend on diagnostic.h (decl.o): Depend on diagnostic.h cp/ 2001-06-10 Mark Mitchell Gabriel Dos Reis * Make-lang.in (cp/call.o): Depend on diagnostic.h (cp/typeck.o): Depend on diagnostic.h (cp/typeck2.o): Depend on diagnostic.h (cp/repo.o): Depend on dignostic.h * typeck.c: #include diagnostic.h (convert_for_initialization): Remove extern declaration for warningcount and errorcount. * call.c: #include diagnostic.h (convert_like_real): Remove extern declaration for warnincount and errorcount. * repo.c: #include diagnostic.h * typeck2.c: #include diagnostic.h From-SVN: r43140 --- gcc/ChangeLog | 26 ++++++++++++++++++++++++++ gcc/Makefile.in | 5 +++-- gcc/c-parse.in | 1 + gcc/ch/ChangeLog | 7 +++++++ gcc/ch/Makefile.in | 4 ++-- gcc/ch/actions.c | 1 + gcc/ch/decl.c | 1 + gcc/cp/ChangeLog | 18 ++++++++++++++++++ gcc/cp/Make-lang.in | 11 +++++++---- gcc/cp/call.c | 2 +- gcc/cp/repo.c | 1 + gcc/cp/typeck.c | 2 +- gcc/cp/typeck2.c | 1 + gcc/diagnostic.c | 7 +------ gcc/diagnostic.h | 32 ++++++++++++++++++++++++++++++-- gcc/dwarf2out.c | 1 + gcc/toplev.c | 6 ------ gcc/toplev.h | 3 --- 18 files changed, 102 insertions(+), 27 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 634634a91e3..4efb3ba388b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,29 @@ +2001-06-10 Mark Mitchell + Gabriel Dos Reis + + * Makefile.in (c-parse.o): Depend on diagnostic.h + (dwarf2out.o): Likewise. + + * dwarf2out.c: #include diagnostic.h + + * toplev.h (warningcount, errorcount, sorrycount): Remove + declarations. + + * toplev.c (warningcount, errorcount, sorrycount): Remove + definitions. + + * diagnostic.h (struct output_buffer): Reorder fields. + (diagnostic_kind_count): New macro. + (errorcount, warningcount, sorrycount): Define as macros. + (diagnostic_report_warnings_p): New macro. + (output_state): Add diagnostic_count field. + + * diagnostic.c (warningcount, errorcount, inhibit_warnings): + Remove tentative declaration. + (count_error): Use diagnostic_report_warnings_p. + + * c-parse.in: #include diagnostic.h + 2001-06-10 Stephane Carrez * config/m68hc11/m68hc11.md ("extendhisi2"): Fix constraints to diff --git a/gcc/Makefile.in b/gcc/Makefile.in index c3ff7139994..a9af1e1cdf9 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1133,7 +1133,8 @@ s-crt0: $(CRT0_S) $(MCRT0_S) $(GCC_PASSES) $(CONFIG_H) c-errors.o: c-errors.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(C_TREE_H) flags.h \ diagnostic.h $(TM_P_H) c-parse.o : $(srcdir)/c-parse.c $(CONFIG_H) $(TREE_H) c-lex.h $(GGC_H) intl.h \ - $(C_TREE_H) input.h flags.h $(SYSTEM_H) toplev.h output.h cpplib.h + $(C_TREE_H) input.h flags.h $(SYSTEM_H) toplev.h output.h cpplib.h \ + diagnostic.h $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) -c $(srcdir)/c-parse.c $(srcdir)/c-parse.c: $(srcdir)/c-parse.y @@ -1386,7 +1387,7 @@ sdbout.o : sdbout.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(RTL_H) flags.h except.h dwarfout.o : dwarfout.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(RTL_H) dwarf.h \ flags.h insn-config.h reload.h output.h toplev.h dwarfout.h $(TM_P_H) dwarf2out.o : dwarf2out.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(RTL_H) dwarf2.h \ - flags.h insn-config.h reload.h output.h \ + flags.h insn-config.h reload.h output.h diagnostic.h \ hard-reg-set.h $(REGS_H) $(EXPR_H) toplev.h dwarf2out.h varray.h \ $(GGC_H) except.h dwarf2asm.h $(TM_P_H) dwarf2asm.o : dwarf2asm.c $(CONFIG_H) $(SYSTEM_H) flags.h $(RTL_H) $(TREE_H) \ diff --git a/gcc/c-parse.in b/gcc/c-parse.in index bcbd15f8701..45b04dab71a 100644 --- a/gcc/c-parse.in +++ b/gcc/c-parse.in @@ -51,6 +51,7 @@ end ifc #include "output.h" #include "toplev.h" #include "ggc.h" +#include "diagnostic.h" #ifdef MULTIBYTE_CHARS #include diff --git a/gcc/ch/ChangeLog b/gcc/ch/ChangeLog index cc1358c0ce8..be600bd3da5 100644 --- a/gcc/ch/ChangeLog +++ b/gcc/ch/ChangeLog @@ -1,3 +1,10 @@ +2001-06-10 Gabriel Dos Reis + + * decl.c: #include diagnostic.h + * actions.c: #include diagnostic.h + * Makefile.in (actions.o): Depend on diagnostic.h + (decl.o): Depend on diagnostic.h + 2001-06-02 Joseph S. Myers * chill.texi: Move contents to just after title page. diff --git a/gcc/ch/Makefile.in b/gcc/ch/Makefile.in index a15c1ce7506..deb26f3a9bd 100644 --- a/gcc/ch/Makefile.in +++ b/gcc/ch/Makefile.in @@ -269,12 +269,12 @@ $(srcdir)/hash.h: actions.o : actions.c $(CONFIG_H) $(CHILL_TREE_H) actions.h $(RTL_H) \ lex.h $(srcdir)/../flags.h $(srcdir)/../input.h \ - $(EXPR_H) $(srcdir)/../system.h $(srcdir)/../toplev.h + $(EXPR_H) $(srcdir)/../system.h $(srcdir)/../toplev.h diagnostic.h convert.o : convert.c $(CONFIG_H) $(CHILL_TREE_H) $(srcdir)/../flags.h \ $(srcdir)/../tree.h $(srcdir)/../system.h $(srcdir)/../toplev.h \ $(srcdir)/../convert.h decl.o : decl.c $(CONFIG_H) $(CHILL_TREE_H) $(srcdir)/../flags.h lex.h \ - $(srcdir)/../system.h $(srcdir)/../toplev.h + $(srcdir)/../system.h $(srcdir)/../toplev.h diagnostic.h except.o : except.c $(CONFIG_H) $(srcdir)/../tree.h $(RTL_H) $(CHILL_TREE_H) \ $(srcdir)/../system.h $(srcdir)/../toplev.h expr.o : expr.c $(CONFIG_H) $(RTL_H) $(CHILL_TREE_H) $(srcdir)/../flags.h \ diff --git a/gcc/ch/actions.c b/gcc/ch/actions.c index 09c8a5a23f7..a0e50d68a5f 100644 --- a/gcc/ch/actions.c +++ b/gcc/ch/actions.c @@ -32,6 +32,7 @@ Boston, MA 02111-1307, USA. */ #include "obstack.h" #include "assert.h" #include "toplev.h" +#include "diagnostic.h" static int id_cmp PARAMS ((tree *, tree *)); static void warn_unhandled PARAMS ((const char *)); diff --git a/gcc/ch/decl.c b/gcc/ch/decl.c index 6cdec6c9bee..a433fa7b79b 100644 --- a/gcc/ch/decl.c +++ b/gcc/ch/decl.c @@ -191,6 +191,7 @@ Boston, MA 02111-1307, USA. */ #include "input.h" #include "rtl.h" #include "toplev.h" +#include "diagnostic.h" #define IS_UNKNOWN_TYPE(type) (TYPE_SIZE(type)==0) #define BUILTIN_NESTING_LEVEL (-1) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ad66b7ce930..f4527206cb7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,21 @@ +2001-06-10 Mark Mitchell + Gabriel Dos Reis + + * Make-lang.in (cp/call.o): Depend on diagnostic.h + (cp/typeck.o): Depend on diagnostic.h + (cp/typeck2.o): Depend on diagnostic.h + (cp/repo.o): Depend on dignostic.h + * typeck.c: #include diagnostic.h + (convert_for_initialization): Remove extern declaration for + warningcount and errorcount. + + * call.c: #include diagnostic.h + (convert_like_real): Remove extern declaration for warnincount and + errorcount. + + * repo.c: #include diagnostic.h + * typeck2.c: #include diagnostic.h + 2001-06-08 Nathan Sidwell * decl.c (duplicate_decls): Fix DECL_TEMPLATE_RESULT thinko diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in index 84baffb4043..9965c5e737e 100644 --- a/gcc/cp/Make-lang.in +++ b/gcc/cp/Make-lang.in @@ -245,10 +245,13 @@ cp/decl.o: cp/decl.c $(CXX_TREE_H) flags.h cp/lex.h cp/decl.h stack.h \ cp/operators.def $(TM_P_H) cp/decl2.o: cp/decl2.c $(CXX_TREE_H) flags.h cp/lex.h cp/decl.h $(EXPR_H) \ output.h except.h toplev.h dwarf2out.h dwarfout.h $(GGC_H) $(RTL_H) -cp/typeck2.o: cp/typeck2.c $(CXX_TREE_H) flags.h toplev.h output.h $(TM_P_H) -cp/typeck.o: cp/typeck.c $(CXX_TREE_H) flags.h $(RTL_H) $(EXPR_H) toplev.h +cp/typeck2.o: cp/typeck2.c $(CXX_TREE_H) flags.h toplev.h output.h $(TM_P_H) \ + diagnostic.h +cp/typeck.o: cp/typeck.c $(CXX_TREE_H) flags.h $(RTL_H) $(EXPR_H) toplev.h \ + diagnostic.h cp/class.o: cp/class.c $(CXX_TREE_H) flags.h toplev.h $(RTL_H) -cp/call.o: cp/call.c $(CXX_TREE_H) flags.h toplev.h $(RTL_H) $(EXPR_H) $(GGC_H) +cp/call.o: cp/call.c $(CXX_TREE_H) flags.h toplev.h $(RTL_H) $(EXPR_H) \ + $(GGC_H) diagnostic.h cp/friend.o: cp/friend.c $(CXX_TREE_H) flags.h $(RTL_H) toplev.h $(EXPR_H) cp/init.o: cp/init.c $(CXX_TREE_H) flags.h $(RTL_H) $(EXPR_H) toplev.h \ $(GGC_H) except.h @@ -269,7 +272,7 @@ cp/pt.o: cp/pt.c $(CXX_TREE_H) cp/decl.h cp/parse.h cp/lex.h toplev.h \ $(GGC_H) $(RTL_H) except.h cp/error.o: cp/error.c $(CXX_TREE_H) toplev.h diagnostic.h cp/errfn.o: cp/errfn.c $(CXX_TREE_H) toplev.h -cp/repo.o: cp/repo.c $(CXX_TREE_H) toplev.h $(GGC_H) +cp/repo.o: cp/repo.c $(CXX_TREE_H) toplev.h $(GGC_H) diagnostic.h cp/semantics.o: cp/semantics.c $(CXX_TREE_H) cp/lex.h except.h toplev.h \ flags.h $(GGC_H) output.h $(RTL_H) $(TIMEVAR_H) $(EXPR_H) cp/dump.o: cp/dump.c $(CXX_TREE_H) c-dump.h diff --git a/gcc/cp/call.c b/gcc/cp/call.c index f09659acbcc..e7b6bbd824b 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -34,6 +34,7 @@ Boston, MA 02111-1307, USA. */ #include "toplev.h" #include "expr.h" #include "ggc.h" +#include "diagnostic.h" extern int inhibit_warnings; @@ -3716,7 +3717,6 @@ convert_like_real (convs, expr, fn, argnum, inner) int argnum; int inner; { - extern int warningcount, errorcount; int savew, savee; tree totype = TREE_TYPE (convs); diff --git a/gcc/cp/repo.c b/gcc/cp/repo.c index f2f95919d56..74c5ee86b12 100644 --- a/gcc/cp/repo.c +++ b/gcc/cp/repo.c @@ -33,6 +33,7 @@ Boston, MA 02111-1307, USA. */ #include "obstack.h" #include "toplev.h" #include "ggc.h" +#include "diagnostic.h" static tree repo_get_id PARAMS ((tree)); static char *extract_string PARAMS ((char **)); diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 01805c664fa..3c2ea8d9666 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -40,6 +40,7 @@ Boston, MA 02111-1307, USA. */ #include "flags.h" #include "output.h" #include "toplev.h" +#include "diagnostic.h" static tree convert_for_assignment PARAMS ((tree, tree, const char *, tree, int)); @@ -6431,7 +6432,6 @@ convert_for_initialization (exp, type, rhs, flags, errtype, fndecl, parmnum) if (codel == REFERENCE_TYPE) { /* This should eventually happen in convert_arguments. */ - extern int warningcount, errorcount; int savew = 0, savee = 0; if (fndecl) diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 959d979872d..09621d4cb57 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -38,6 +38,7 @@ Boston, MA 02111-1307, USA. */ #include "flags.h" #include "toplev.h" #include "output.h" +#include "diagnostic.h" static tree process_init_constructor PARAMS ((tree, tree, tree *)); diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index eb0e5214fa5..bb75846c99b 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -103,10 +103,7 @@ static void default_diagnostic_finalizer PARAMS ((output_buffer *, static void error_recursion PARAMS ((void)) ATTRIBUTE_NORETURN; extern int rtl_dump_and_exit; -extern int inhibit_warnings; extern int warnings_are_errors; -extern int warningcount; -extern int errorcount; /* Front-end specific tree formatter, if non-NULL. */ printer_fn lang_printer = NULL; @@ -1049,9 +1046,7 @@ int count_error (warningp) int warningp; { - if (warningp - && (inhibit_warnings - || (in_system_header && !warn_system_headers))) + if (warningp && !diagnostic_report_warnings_p ()) return 0; if (warningp && !warnings_are_errors) diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h index 9d017584aaf..02029ea59c7 100644 --- a/gcc/diagnostic.h +++ b/gcc/diagnostic.h @@ -55,9 +55,11 @@ typedef struct { /* The prefix for each new line. */ const char *prefix; + /* The real upper bound of number of characters per line, taking into account the case of a very very looong prefix. */ int maximum_length; + /* The ideal upper bound of number of characters per line, as suggested by front-end. */ int ideal_maximum_length; @@ -77,11 +79,16 @@ typedef struct o DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE: emit current PREFIX each time a physical line is started. */ int prefixing_rule; + /* The current char to output. Updated by front-end (*format_map) when it is called to report front-end printer for a specified format. */ const char *cursor; + /* A pointer to the variable argument-list for formatting. */ va_list *format_args; + + /* The number of times we have issued diagnostics. */ + int diagnostic_count[DK_LAST_DIAGNOSTIC_KIND]; } output_state; /* The output buffer datatype. This is best seen as an abstract datatype. */ @@ -90,16 +97,20 @@ struct output_buffer /* Internal data. These fields should not be accessed directly by front-ends. */ + /* The current state of the buffer. */ + output_state state; + /* Where to output formatted text. */ FILE* stream; + /* The obstack where the text is built up. */ struct obstack obstack; + /* The amount of characters output so far. */ int line_length; - /* The current state of the buffer. */ - output_state state; }; +#define output_buffer_state(BUFFER) (BUFFER)->state #define output_buffer_attached_stream(BUFFER) (BUFFER)->stream #define output_buffer_text_cursor(BUFFER) (BUFFER)->state.cursor #define output_buffer_format_args(BUFFER) *((BUFFER)->state.format_args) @@ -178,6 +189,23 @@ extern int diagnostic_message_length_per_line; has been removed. */ extern output_buffer *diagnostic_buffer; +#define diagnostic_kind_count(BUFFER, DK) \ + (BUFFER)->state.diagnostic_count[(int) DK] + +/* The number of errors that have been issued so far. Ideally, these + would take an output_buffer as an argument. */ +#define errorcount diagnostic_kind_count (diagnostic_buffer, DK_ERROR) +/* Similarly, but for warnings. */ +#define warningcount diagnostic_kind_count (diagnostic_buffer, DK_WARNING) +/* Similarly, but for sorrys. */ +#define sorrycount diagnostic_kind_count (diagnostic_buffer, DK_SORRY) + +/* Returns non-zero if warnings should be emitted. */ +#define diagnostic_report_warnings_p() \ + (!inhibit_warnings \ + && !(in_system_header && !warn_system_headers)) + + /* Prototypes */ extern void set_diagnostic_context PARAMS ((diagnostic_context *, const char *, va_list *, diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 5d561840e6a..5257b914619 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -56,6 +56,7 @@ Boston, MA 02111-1307, USA. */ #include "ggc.h" #include "md5.h" #include "tm_p.h" +#include "diagnostic.h" /* DWARF2 Abbreviation Glossary: CFA = Canonical Frame Address diff --git a/gcc/toplev.c b/gcc/toplev.c index 2f803aa44bb..16a1de5f45c 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -379,12 +379,6 @@ int optimize = 0; int optimize_size = 0; -/* Number of error messages and warning messages so far. */ - -int errorcount = 0; -int warningcount = 0; -int sorrycount = 0; - /* Nonzero if we should exit after parsing options. */ static int exit_after_options = 0; diff --git a/gcc/toplev.h b/gcc/toplev.h index 8d0d2a6de02..ca09e0ef2e8 100644 --- a/gcc/toplev.h +++ b/gcc/toplev.h @@ -132,9 +132,6 @@ extern void note_deferral_of_defined_inline_function PARAMS ((union tree_node *)); extern void note_outlining_of_inline_function PARAMS ((union tree_node *)); -extern int errorcount; -extern int warningcount; -extern int sorrycount; extern const char *progname; extern const char *dump_base_name; -- 2.30.2