Commit Graph

21 Commits

Author SHA1 Message Date
Jakub Jelinek 7adcbafe45 Update copyright years. 2022-01-03 10:42:10 +01:00
Jakub Jelinek 99dee82307 Update copyright years. 2021-01-04 10:26:59 +01:00
David Malcolm 4bc1899b2e Add diagnostic paths
This patch adds support for associating a "diagnostic_path" with a
diagnostic: a sequence of events predicted by the compiler that leads to
the problem occurring, with their locations in the user's source,
text descriptions, and stack information (for handling interprocedural
paths).

For example, the following (hypothetical) error has a 3-event
intraprocedural path:

test.c: In function 'demo':
test.c:29:5: error: passing NULL as argument 1 to 'PyList_Append' which
  requires a non-NULL parameter
   29 |     PyList_Append(list, item);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~
  'demo': events 1-3
     |
     |   25 |   list = PyList_New(0);
     |      |          ^~~~~~~~~~~~~
     |      |          |
     |      |          (1) when 'PyList_New' fails, returning NULL
     |   26 |
     |   27 |   for (i = 0; i < count; i++) {
     |      |   ~~~
     |      |   |
     |      |   (2) when 'i < count'
     |   28 |     item = PyLong_FromLong(random());
     |   29 |     PyList_Append(list, item);
     |      |     ~~~~~~~~~~~~~~~~~~~~~~~~~
     |      |     |
     |      |     (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
     |

The patch adds a new "%@" format code for printing event IDs, so that
in the above, the description of event (3) mentions event (1), showing
the user where the bogus NULL value comes from (the event IDs are
colorized to draw the user's attention to them).

There is a separation between data vs presentation: the above shows how
the diagnostic-printing code has consolidated the path into a single run
of events, since all the events are near each other and within the same
function; more complicated examples (such as interprocedural paths)
might be printed as multiple runs of events.

Examples of how interprocedural paths are printed can be seen in the
test suite (which uses a plugin to exercise the code without relying
on specific warnings using this functionality).

Other output formats include
- JSON,
- printing each event as a separate "note", and
- to not emit paths.

gcc/ChangeLog:
	* Makefile.in (OBJS): Add tree-diagnostic-path.o.
	* common.opt (fdiagnostics-path-format=): New option.
	(diagnostic_path_format): New enum.
	(fdiagnostics-show-path-depths): New option.
	* coretypes.h (diagnostic_event_id_t): New forward decl.
	* diagnostic-color.c (color_dict): Add "path".
	* diagnostic-event-id.h: New file.
	* diagnostic-format-json.cc (json_from_expanded_location): Make
	non-static.
	(json_end_diagnostic): Call context->make_json_for_path if it
	exists and the diagnostic has a path.
	(diagnostic_output_format_init): Clear context->print_path.
	* diagnostic-path.h: New file.
	* diagnostic-show-locus.c (colorizer::set_range): Special-case
	when printing a run of events in a diagnostic_path so that they
	all get the same color.
	(layout::m_diagnostic_path_p): New field.
	(layout::layout): Initialize it.
	(layout::print_any_labels): Don't colorize the label text for an
	event in a diagnostic_path.
	(gcc_rich_location::add_location_if_nearby): Add
	"restrict_to_current_line_spans" and "label" params.  Pass the
	former to layout.maybe_add_location_range; pass the latter
	when calling add_range.
	* diagnostic.c: Include "diagnostic-path.h".
	(diagnostic_initialize): Initialize context->path_format and
	context->show_path_depths.
	(diagnostic_show_any_path): New function.
	(diagnostic_path::interprocedural_p): New function.
	(diagnostic_report_diagnostic): Call diagnostic_show_any_path.
	(simple_diagnostic_path::num_events): New function.
	(simple_diagnostic_path::get_event): New function.
	(simple_diagnostic_path::add_event): New function.
	(simple_diagnostic_event::simple_diagnostic_event): New ctor.
	(simple_diagnostic_event::~simple_diagnostic_event): New dtor.
	(debug): New overload taking a diagnostic_path *.
	* diagnostic.def (DK_DIAGNOSTIC_PATH): New.
	* diagnostic.h (enum diagnostic_path_format): New enum.
	(json::value): New forward decl.
	(diagnostic_context::path_format): New field.
	(diagnostic_context::show_path_depths): New field.
	(diagnostic_context::print_path): New callback field.
	(diagnostic_context::make_json_for_path): New callback field.
	(diagnostic_show_any_path): New decl.
	(json_from_expanded_location): New decl.
	* doc/invoke.texi (-fdiagnostics-path-format=): New option.
	(-fdiagnostics-show-path-depths): New option.
	(-fdiagnostics-color): Add "path" to description of default
	GCC_COLORS; describe it.
	(-fdiagnostics-format=json): Document how diagnostic paths are
	represented in the JSON output format.
	* gcc-rich-location.h (gcc_rich_location::add_location_if_nearby):
	Add optional params "restrict_to_current_line_spans" and "label".
	* opts.c (common_handle_option): Handle
	OPT_fdiagnostics_path_format_ and
	OPT_fdiagnostics_show_path_depths.
	* pretty-print.c: Include "diagnostic-event-id.h".
	(pp_format): Implement "%@" format code for printing
	diagnostic_event_id_t *.
	(selftest::test_pp_format): Add tests for "%@".
	* selftest-run-tests.c (selftest::run_tests): Call
	selftest::tree_diagnostic_path_cc_tests.
	* selftest.h (selftest::tree_diagnostic_path_cc_tests): New decl.
	* toplev.c (general_init): Initialize global_dc->path_format and
	global_dc->show_path_depths.
	* tree-diagnostic-path.cc: New file.
	* tree-diagnostic.c (maybe_unwind_expanded_macro_loc): Make
	non-static.  Drop "diagnostic" param in favor of storing the
	original value of "where" and re-using it.
	(virt_loc_aware_diagnostic_finalizer): Update for dropped param of
	maybe_unwind_expanded_macro_loc.
	(tree_diagnostics_defaults): Initialize context->print_path and
	context->make_json_for_path.
	* tree-diagnostic.h (default_tree_diagnostic_path_printer): New
	decl.
	(default_tree_make_json_for_path): New decl.
	(maybe_unwind_expanded_macro_loc): New decl.

gcc/c-family/ChangeLog:
	* c-format.c (local_event_ptr_node): New.
	(PP_FORMAT_CHAR_TABLE): Add entry for "%@".
	(init_dynamic_diag_info): Initialize local_event_ptr_node.
	* c-format.h (T_EVENT_PTR): New define.

gcc/testsuite/ChangeLog:
	* gcc.dg/format/gcc_diag-10.c (diagnostic_event_id_t): New
	typedef.
	(test_diag): Add coverage of "%@".
	* gcc.dg/plugin/diagnostic-path-format-default.c: New test.
	* gcc.dg/plugin/diagnostic-path-format-inline-events-1.c: New test.
	* gcc.dg/plugin/diagnostic-path-format-inline-events-2.c: New test.
	* gcc.dg/plugin/diagnostic-path-format-inline-events-3.c: New test.
	* gcc.dg/plugin/diagnostic-path-format-none.c: New test.
	* gcc.dg/plugin/diagnostic-test-paths-1.c: New test.
	* gcc.dg/plugin/diagnostic-test-paths-2.c: New test.
	* gcc.dg/plugin/diagnostic-test-paths-3.c: New test.
	* gcc.dg/plugin/diagnostic-test-paths-4.c: New test.
	* gcc.dg/plugin/diagnostic_plugin_test_paths.c: New.
	* gcc.dg/plugin/plugin.exp: Add the new plugin and test cases.

libcpp/ChangeLog:
	* include/line-map.h (class diagnostic_path): New forward decl.
	(rich_location::get_path): New accessor.
	(rich_location::set_path): New function.
	(rich_location::m_path): New field.
	* line-map.c (rich_location::rich_location): Initialize m_path.

From-SVN: r280142
2020-01-10 21:22:12 +00:00
Jakub Jelinek 8d9254fc8a Update copyright years.
From-SVN: r279813
2020-01-01 12:51:42 +01:00
Jakub Jelinek a554497024 Update copyright years.
From-SVN: r267494
2019-01-01 13:31:55 +01:00
Jakub Jelinek 85ec4feb11 Update copyright years.
From-SVN: r256169
2018-01-03 11:03:58 +01:00
Jakub Jelinek cbe34bb5ed Update copyright years.
From-SVN: r243994
2017-01-01 13:07:43 +01:00
Jakub Jelinek 818ab71a41 Update copyright years.
From-SVN: r232055
2016-01-04 15:30:50 +01:00
Jakub Jelinek b55f40c122 diagnostic-core.h (internal_error_no_backtrace): New prototype.
* diagnostic-core.h (internal_error_no_backtrace): New prototype.
	* diagnostic.def (DK_ICE_NOBT): New kind.
	* diagnostic.c (diagnostic_action_after_output): Handle DK_ICE_NOBT
	like DK_ICE, but never print backtrace.
	(diagnostic_report_diagnostic): Handle DK_ICE_NOBT like DK_ICE.
	(internal_error_no_backtrace): New function.
	* gcc.c (execute): Use internal_error_no_backtrace instead of
	internal_error.
fortran/
	* gfc-diagnostic.def (DK_ICE_NOBT): New kind.

From-SVN: r220030
2015-01-23 09:51:10 +01:00
Jakub Jelinek 5624e564d2 Update copyright years.
From-SVN: r219188
2015-01-05 13:33:28 +01:00
Richard Sandiford 23a5b65a92 Update copyright years in gcc/
From-SVN: r206289
2014-01-02 22:23:26 +00:00
Jakub Jelinek 4b84d650e8 opts.c: Include diagnostic-color.h.
* opts.c: Include diagnostic-color.h.
	(common_handle_option): Handle OPT_fdiagnostics_color_.
	* Makefile.in (OBJS-libcommon): Add diagnostic-color.o.
	(diagnostic.o, opts.o, pretty-print.o): Depend on diagnostic-color.h.
	(diagnostic-color.o): New.
	* common.opt (fdiagnostics-color, fdiagnostics-color=): New options.
	(diagnostic_color_rule): New enum.
	* dwarf2out.c (gen_producer_string): Don't print -fdiagnostics-color*.
	* langhooks.c (lhd_print_error_function): Add %r "locus" and %R around
	the location string.
	* diagnostic.def: Add 3rd argument to DEFINE_DIAGNOSTIC_KIND macros,
	either NULL, or color kind.
	* diagnostic-color.c: New file.
	* diagnostic-color.h: New file.
	* diagnostic-core.h (DEFINE_DIAGNOSTIC_KIND): Adjust macro for 3
	arguments.
	* doc/invoke.texi (-fdiagnostics-color): Document.
	* pretty-print.h (pp_show_color): Define.
	(struct pretty_print_info): Add show_color field.
	* diagnostic.c: Include diagnostic-color.h.
	(diagnostic_build_prefix): Adjust for 3 argument DEFINE_DIAGNOSTIC_KIND
	macros.  Colorize error:, warning: etc. strings and also the location
	string.
	(diagnostic_show_locus): Colorize the caret line.
	* pretty-print.c: Include diagnostic-color.h.
	(pp_base_format): Handle %r and %R format specifiers.  Colorize strings
	inside of %< %> quotes or quoted through q format modifier.
c-family/
	* c-format.c (gcc_diag_char_table, gcc_tdiag_char_table,
	gcc_cdiag_char_table, gcc_cxxdiag_char_table): Add %r and %R format
	specifiers.
cp/
	* error.c (cp_print_error_function,
	print_instantiation_partial_context_line,
	maybe_print_constexpr_context): Colorize locus strings.

From-SVN: r197841
2013-04-12 08:19:58 +02:00
Jakub Jelinek 37e9911604 re PR middle-end/48087 (-Wall -Werror adds warnings over and above those generated by -Wall)
PR middle-end/48087
	* diagnostic.def (DK_WERROR): New kind.
	* diagnostic.h (werrorcount): Define.
	* diagnostic.c (diagnostic_report_diagnostic): For DK_WARNING
	promoted to DK_ERROR, increment DK_WERROR counter instead of
	DK_ERROR counter.
	* toplev.c (toplev_main): Call print_ignored_options even if
	just werrorcount is non-zero.  Exit with FATAL_EXIT_CODE
	even if just werrorcount is non-zero.

	* pt.c (convert_nontype_argument): Count werrorcount as warnings.
	* call.c (build_temp): Likewise.
	* method.c (synthesize_method): Likewise.
	* typeck.c (convert_for_initialization): Likewise.

From-SVN: r196887
2013-03-21 18:36:47 +01:00
Richard Sandiford d1e082c2c2 Update copyright years in gcc/
From-SVN: r195098
2013-01-10 20:38:27 +00:00
Joseph Myers ad41bd84ff ABOUT-GCC-NLS, [...]: Add copyright and license notices.
* ABOUT-GCC-NLS, ChangeLog, ChangeLog-1997, ChangeLog-1998,
	ChangeLog-1999, ChangeLog-2000, ChangeLog-2001, ChangeLog-2002,
	ChangeLog-2003, ChangeLog-2004, ChangeLog-2005, ChangeLog-2006,
	ChangeLog-2007, ChangeLog-2008, ChangeLog.dataflow, ChangeLog.lib,
	ChangeLog.ptr, ChangeLog.tree-ssa, ChangeLog.tuples, FSFChangeLog,
	FSFChangeLog.10, FSFChangeLog.11, LANGUAGES, ONEWS, acinclude.m4,
	config/alpha/gnu.h, config/alpha/libgcc-alpha-ldbl.ver,
	config/alpha/t-osf4, config/alpha/t-vms, config/alpha/va_list.h,
	config/alpha/x-vms, config/arc/t-arc,
	config/arm/README-interworking, config/arm/arm-c.c,
	config/arm/gentune.sh, config/arm/libgcc-bpabi.ver,
	config/arm/t-arm, config/arm/t-arm-elf, config/arm/t-arm-softfp,
	config/arm/t-bpabi, config/arm/t-linux, config/arm/t-linux-eabi,
	config/arm/t-netbsd, config/arm/t-pe, config/arm/t-strongarm-elf,
	config/arm/t-symbian, config/arm/t-vxworks, config/arm/t-wince-pe,
	config/avr/t-avr, config/bfin/elf.h, config/bfin/libgcc-bfin.ver,
	config/bfin/linux.h, config/bfin/t-bfin, config/bfin/t-bfin-elf,
	config/bfin/t-bfin-linux, config/bfin/t-bfin-uclinux,
	config/bfin/uclinux.h, config/cris/mulsi3.asm, config/cris/t-cris,
	config/cris/t-elfmulti, config/crx/t-crx,
	config/darwin-ppc-ldouble-patch.def, config/darwin-sections.def,
	config/divmod.c, config/fr30/t-fr30, config/frv/libgcc-frv.ver,
	config/frv/t-frv, config/frv/t-linux, config/h8300/genmova.sh,
	config/h8300/t-h8300, config/i386/athlon.md,
	config/i386/darwin-libgcc.10.4.ver,
	config/i386/darwin-libgcc.10.5.ver, config/i386/libgcc-glibc.ver,
	config/i386/mach.h, config/i386/netbsd.h, config/i386/t-crtpc,
	config/i386/t-cygming, config/i386/t-cygwin, config/i386/t-i386,
	config/i386/t-linux64, config/i386/t-nwld,
	config/i386/t-rtems-i386, config/i386/t-sol2-10,
	config/i386/x-mingw32, config/ia64/div.md, config/ia64/elf.h,
	config/ia64/ia64.opt, config/ia64/libgcc-glibc.ver,
	config/ia64/libgcc-ia64.ver, config/ia64/linux.h,
	config/ia64/sysv4.h, config/ia64/t-hpux, config/ia64/t-ia64,
	config/iq2000/abi, config/iq2000/lib2extra-funcs.c,
	config/iq2000/t-iq2000, config/libgcc-glibc.ver,
	config/m32r/libgcc-glibc.ver, config/m32r/t-linux,
	config/m32r/t-m32r, config/m68hc11/t-m68hc11,
	config/m68k/t-floatlib, config/m68k/t-linux, config/m68k/t-mlibs,
	config/m68k/t-uclinux, config/mcore/t-mcore,
	config/mcore/t-mcore-pe, config/mips/20kc.md, config/mips/4130.md,
	config/mips/5400.md, config/mips/5500.md, config/mips/crti.asm,
	config/mips/crtn.asm, config/mips/irix-crti.asm,
	config/mips/irix-crtn.asm, config/mips/libgcc-mips16.ver,
	config/mips/mips-dsp.md, config/mips/mips-dspr2.md,
	config/mips/mips-fixed.md, config/mips/sb1.md,
	config/mips/sr71k.md, config/mips/t-elf, config/mips/t-gofast,
	config/mips/t-iris6, config/mips/t-isa3264,
	config/mips/t-libgcc-mips16, config/mips/t-linux64,
	config/mips/t-mips, config/mips/t-r3900, config/mips/t-rtems,
	config/mips/t-sb1, config/mips/t-sde, config/mips/t-sdemtk,
	config/mips/t-slibgcc-irix, config/mips/t-sr71k, config/mips/t-st,
	config/mips/t-vr, config/mips/t-vxworks, config/mmix/t-mmix,
	config/mn10300/t-linux, config/mn10300/t-mn10300,
	config/pa/pa32-regs.h, config/pa/t-hpux-shlib, config/pa/t-linux,
	config/pa/t-linux64, config/pa/t-pa64, config/pdp11/t-pdp11,
	config/picochip/libgccExtras/clzsi2.asm,
	config/picochip/t-picochip, config/rs6000/darwin-ldouble-format,
	config/rs6000/darwin-libgcc.10.4.ver,
	config/rs6000/darwin-libgcc.10.5.ver,
	config/rs6000/libgcc-ppc-glibc.ver, config/rs6000/ppc-asm.h,
	config/rs6000/t-aix43, config/rs6000/t-aix52,
	config/rs6000/t-darwin, config/rs6000/t-fprules,
	config/rs6000/t-fprules-fpbit, config/rs6000/t-linux64,
	config/rs6000/t-lynx, config/rs6000/t-netbsd,
	config/rs6000/t-ppccomm, config/rs6000/t-ppcendian,
	config/rs6000/t-ppcgas, config/rs6000/t-rs6000,
	config/rs6000/t-rtems, config/rs6000/t-spe,
	config/rs6000/t-vxworks, config/s390/libgcc-glibc.ver,
	config/score/t-score-elf, config/sh/divcost-analysis,
	config/sh/libgcc-glibc.ver, config/sh/t-netbsd, config/sh/t-sh,
	config/sh/t-sh64, config/sh/t-superh, config/sh/t-symbian,
	config/sparc/libgcc-sparc-glibc.ver, config/sparc/sol2-bi.h,
	config/sparc/sol2-gas.h, config/sparc/sol2-gld-bi.h,
	config/sparc/t-elf, config/sparc/t-linux64, config/sparc/t-sol2,
	config/stormy16/stormy-abi, config/stormy16/t-stormy16,
	config/t-darwin, config/t-libunwind, config/t-libunwind-elf,
	config/t-linux, config/t-lynx, config/t-slibgcc-elf-ver,
	config/t-slibgcc-sld, config/t-sol2, config/t-vxworks,
	config/udivmod.c, config/udivmodsi4.c, config/v850/t-v850,
	config/v850/t-v850e, config/xtensa/t-xtensa, diagnostic.def,
	gdbinit.in, glimits.h, gstab.h, gsyms.h, java/ChangeLog,
	java/ChangeLog.ptr, java/ChangeLog.tree-ssa, libgcc-std.ver,
	limitx.h, version.c, xcoff.h: Add copyright and license notices.
	* config/h8300/genmova.sh: Include copyright and license notices
	in generated output.
	* config/h8300/mova.md: Regenerate.
	* doc/install.texi2html: Include word "Copyright" in copyright
	notice and use name "Free Software Foundation, Inc.".
	* ChangeLog, ChangeLog-2000, ChangeLog-2001, ChangeLog-2002,
	ChangeLog-2003, ChangeLog-2004, ChangeLog-2005, ChangeLog-2006,
	ChangeLog-2007, ChangeLog-2008: Correct dates.

ada:
	* ChangeLog, ChangeLog.ptr, ChangeLog.tree-ssa: Add copyright and
	license notices.

cp:
	* ChangeLog, ChangeLog-1993, ChangeLog-1994, ChangeLog-1995,
	ChangeLog-1996, ChangeLog-1997, ChangeLog-1998, ChangeLog-1999,
	ChangeLog-2000, ChangeLog-2001, ChangeLog-2002, ChangeLog-2003,
	ChangeLog-2004, ChangeLog-2005, ChangeLog-2006, ChangeLog-2007,
	ChangeLog-2008, ChangeLog.ptr, ChangeLog.tree-ssa, NEWS,
	cfns.gperf: Add copyright and license notices.
	* cfns.h: Regenerate.
	* ChangeLog, ChangeLog-2004: Correct dates.

fortran:
	* ChangeLog, ChangeLog-2002, ChangeLog-2003, ChangeLog-2004,
	ChangeLog-2005, ChangeLog-2006, ChangeLog-2007, ChangeLog-2008,
	ChangeLog.ptr, config-lang.in, ioparm.def, mathbuiltins.def: Add
	copyright and license notices.
	* ChangeLog, ChangeLog-2005, ChangeLog-2006, ChangeLog-2007,
	ChangeLog-2008: Correct dates.

java:
	* ChangeLog, ChangeLog.ptr, ChangeLog.tree-ssa: Add copyright and
	license notices.

objc:
	* ChangeLog: Add copyright and license notices.

objcp:
	* ChangeLog: Add copyright and license notices.

po:
	* ChangeLog, EXCLUDES: Add copyright and license notices.

testsuite:
	* ChangeLog, ChangeLog-1993-2007, ChangeLog-2008, ChangeLog.ptr,
	ChangeLog.tree-ssa, README, README.QMTEST, README.compat,
	README.gcc, g++.dg/README, g++.dg/compat/break/README,
	g++.dg/gomp/gomp.exp, g++.old-deja/g++.brendan/README,
	g++.old-deja/g++.oliva/ChangeLog, g++.old-deja/g++.robertl/README,
	gcc.c-torture/ChangeLog.0,
	gcc.c-torture/execute/builtins/builtins.exp, gcc.dg/README,
	gcc.dg/gomp/gomp.exp, gcc.target/frv/frv.exp,
	gcc.target/i386/math-torture/math-torture.exp,
	gcc.target/mips/inter/mips16-inter.exp,
	gcc.target/mips/mips-nonpic/README,
	gcc.target/x86_64/abi/README.gcc,
	gcc.target/xstormy16/xstormy16.exp, gcc.test-framework/README,
	gfortran.dg/g77/README, gfortran.dg/gomp/gomp.exp,
	gfortran.fortran-torture/ChangeLog.g95: Add copyright and license
	notices.
	* ChangeLog-1993-2007, ChangeLog: Correct dates.

From-SVN: r146533
2009-04-21 20:03:23 +01:00
Manuel López-Ibáñez 71205d170c re PR other/36901 (pedwarn() + -pedantic-errors + -w (inhibit_warnings) should not emit errors)
2008-08-09  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

	PR 36901
	* diagnostic.def (DK_PEDWARN, DK_PERMERROR): New.  
	* diagnostic.c (pedantic_warning_kind, permissive_error_kind):
	Moved from diagnostic.h
	(diagnostic_report_diagnostic): Return bool. Handle DK_PEDWARN and
	DK_PERMERROR.
	(emit_diagnostic): New.
	(warning0, pedwarn0): Delete.
	(warning, warning_at, pedwarn, permerror): Return bool.  
	* diagnostic.h (pedantic_warning_kind, permissive_error_kind):
	Moved to diagnostic.c.
	(struct diagnostic_context): Use correct type for
	classify_diagnostic.
	(diagnostic_report_diagnostic): Update declaration.
	(emit_diagnostic): Declare.
	* errors.c (warning): Return bool.  
	* errors.h (warning): Update declaration.
	* toplev.h (warning0, pedwarn0): Delete.
	(warning, warning_at, pedwarn, permerror): Return bool.
	* c-errors.c (pedwarn_c99, pedwarn_c90): Use DK_PEDWARN.
	* c-decl.c (locate_old_decl): Delete 'diag' argument. Always use
	inform. Update all calls.
	(diagnose_mismatched_decls): Check return value of warning/pedwarn
	before giving informative note.
	(implicit_decl_warning): Likewise.  
	* c-typeck.c (build_function_call): Likewise.  
	* tree-sssa.c (warn_uninit): Likewise.  
	* builtins.c (gimplify_va_arg_expr): Likewise.
fortran/
	* f95-lang.c (gfc_mark_addressable): Use "pedwarn (0," instead of
	'pedwarn0'.
cp/
	* cp-tree.h (struct diagnostic_context, struct diagnostic_info):
	Delete forward declarations. Check that toplev.h has not been
	included before this file. Include toplev.h and diagnostic.h.
	* error.c (cp_cpp_error): Use DK_PEDWARN.
	(cxx_incomplete_type_diagnostic): Update declaration.
	(cxx_incomplete_type_error): Use DK_ERROR.
	* typeck2.c (cxx_incomplete_type_diagnostic): Take a diagnostic_t
	as argument. Use emit_diagnostic.
	(cxx_incomplete_type_error): Use DK_ERROR.
	(add_exception_specifier): Use diagnostic_t instead of custom
	codes.  
	* typeck.c (complete_type_or_else): Update call to
	cxx_incomplete_type_diagnostic.
	* init.c (build_delete): Likewise.  
	* call.c (diagnostic_fn_t): Remove unused typedef.
	(build_temp): Pass a pointer to diagnostic_t.
	(convert_like_real): Use emit_diagnostic.
	(joust): Check return value of warning before giving informative
	note.  
	* friend.c (do_friend): Check return value of warning
	before giving informative note.
	* parser.c (cp_parser_template_id): Likewise.

testsuite/
	* gcc.dg/pr36901-1.c: New.
	* gcc.dg/pr36901-3.c: New.
	* gcc.dg/pr36901-2.c: New.
	* gcc.dg/pr36901-4.c: New.
	* gcc.dg/pr36901-system.h: New.
	* gcc.dg/pr36901.h: New.
	* gcc.target/powerpc/altivec-macros.c: Update.
	* gcc.target/i386/regparm.c: Update.
	* gcc.dg/funcdef-var-1.c: Update.
	* gcc.dg/parm-mismatch-1.c: Update.
	* gcc.dg/attr-noinline.c: Update.
	* gcc.dg/wtr-static-1.c: Update.
	* gcc.dg/redecl-11.c: Update.
	* gcc.dg/pr27953.c: Update.
	* gcc.dg/proto-1.c: Update.
	* gcc.dg/decl-3.c: Update.
	* gcc.dg/redecl-13.c: Update.
	* gcc.dg/pr15360-1.c: Update.
	* gcc.dg/redecl-15.c: Update.
	* gcc.dg/enum-compat-1.c: Update.
	* gcc.dg/dll-3.c: Update.
	* gcc.dg/array-5.c: Update.
	* gcc.dg/Wredundant-decls-2.c: Update.
	* gcc.dg/inline4.c: Update.
	* gcc.dg/redecl-2.c: Update.
	* gcc.dg/inline-14.c: Update.
	* gcc.dg/tls/diag-3.c: Update.
	* gcc.dg/funcdef-var-2.c: Update.
	* gcc.dg/20041213-1.c: Update.
	* gcc.dg/old-style-then-proto-1.c: Update.
	* gcc.dg/decl-2.c: Update.
	* gcc.dg/redecl-12.c: Update.
	* gcc.dg/decl-4.c: Update.
	* gcc.dg/Wshadow-1.c: Update.
	* gcc.dg/transparent-union-2.c: Update.
	* gcc.dg/visibility-7.c: Update.
	* gcc.dg/dll-2.c: Update.
	* gcc.dg/redecl-16.c: Update.
	* gcc.dg/inline1.c: Update.
	* gcc.dg/decl-8.c: Update.
	* gcc.dg/nested-redef-1.c: Update.
	* gcc.dg/inline3.c: Update.
	* gcc.dg/redecl-1.c: Update.
	* gcc.dg/inline5.c: Update.
	* gcc.dg/pr35899.c: Update.
	* gcc.dg/noncompile/label-lineno-1.c: Update.
	* gcc.dg/noncompile/label-1.c: Update.
	* gcc.dg/noncompile/20020220-1.c: Update.
	* gcc.dg/noncompile/redecl-1.c: Update.
	* gcc.dg/redecl-5.c: Update.
	* gcc.dg/qual-return-3.c: Update.
	* gcc.dg/label-decl-4.c: Update.

From-SVN: r138893
2008-08-08 23:57:19 +00:00
DJ Delorie 79cf599406 c-pragma.c (handle_pragma_diagnostic): New.
* c-pragma.c (handle_pragma_diagnostic): New.
(init_pragma): Register it.
* doc/extend.texi: Document it.

* diagnostic.def: Add DK_UNSPECIFIED and DK_IGNORED.
* diagnostic.h (diagnostic_classify_diagnostic): Declare.
(diagnostic_context): Add classify_diagnostic[].
* diagnostic.c (diagnostic_count_diagnostic): Don't count warnings
as errors if they're overridden to DK_WARNING.
(diagnostic_initialize): Initialize classify_diagnostic[].
(diagnostic_set_kind_override): New.
(diagnostic_report_diagnostic): Check for kind changes.
* opts.c (common_handle_option): Take lang_mask.  Update callers.
Handle OPT_Werror_.
* common.opt (Werror=): New.
* doc/invoke.texi: Document -Werror=*

From-SVN: r109907
2006-01-18 15:02:42 -05:00
Gabriel Dos Reis b0e3f7ec30 re PR c++/11531 (ICE on invalid code (returning to void))
PR c++/11531
        * diagnostic.c (diagnostic_report_diagnostic): Don't ICE if we're
        not recursing on hard error.
        (diagnostic_for_decl): Likewise.
        * diagnostic.def: Rearrange.

cp/
        * typeck.c (check_return_expr): Fix thinko in diagnostic.

From-SVN: r69425
2003-07-15 23:31:52 +00:00
Gabriel Dos Reis 9b32718c73 diagnostic.h (output_formatted_scalar): Rename from output_formatted_integer.
* diagnostic.h (output_formatted_scalar): Rename from
        output_formatted_integer.
        * diagnostic.def: Add DK_DEBUG.
        * diagnostic.c (output_decimal): Adjust.
        (output_long_decimal): Likewise.
        (output_unsigned_decimal): Likewise.
        (output_octal): Likewise.
        (output_long_octal): Likewise.
        (output_hexadecimal): Likewise.
        (output_long_hexadecimal): Likewise.
        * c-pretty-print.c (pp_c_type_specifier): New function.
        (pp_c_specifier_qualifier_list): Likewise.
        (pp_c_abstract_declarator): Likewise.
        (pp_c_char): Replace pp_format_integer with pp_format_scalar.

From-SVN: r56236
2002-08-12 18:34:51 +00:00
Gabriel Dos Reis bf3f2a12a7 * diagnostic.def: Don't capitalize diagnostic descriptors.
From-SVN: r54370
2002-06-08 11:25:28 +00:00
Gabriel Dos Reis d0e66dbb95 diagnostic.def: New file.
* diagnostic.def: New file.
      * diagnostic.h (diagnostic_t): New enum.
      * Makefile.in (diagnostic.o): Depend on diagnostic.def

From-SVN: r41717
2001-05-01 08:19:45 +00:00