Commit Graph

233 Commits

Author SHA1 Message Date
Manuel López-Ibáñez fbecdc8382 re PR fortran/44054 (Handle -Werror, -Werror=, -fdiagnostics-show-option, !GCC$ diagnostic (pragmas) and color)
gcc/ChangeLog:

2014-08-21  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR fortran/44054
	* diagnostic.c: Set default caret.
	(diagnostic_show_locus): Use it. Tell pretty-printer that a new
	line is needed.
	* diagnostic.h (struct diagnostic_context):


gcc/fortran/ChangeLog:

2014-08-21  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR fortran/44054
	* error.c (gfc_diagnostic_build_locus_prefix): New function.
	(gfc_diagnostic_starter): Follow Fortran FE diagnostics.
	(gfc_diagnostic_finalizer): Do not call default finalizer.

From-SVN: r214251
2014-08-21 00:27:25 +00:00
Manuel López-Ibáñez 18767f6502 re PR fortran/44054 (Handle -Werror, -Werror=, -fdiagnostics-show-option, !GCC$ diagnostic (pragmas) and color)
gcc/ChangeLog:

2014-08-21  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR fortran/44054
	* diagnostic.c (default_diagnostic_finalizer): Move caret printing
	 to here ...
	(diagnostic_report_diagnostic): ... from here.
	* toplev.c (general_init): Move code to c-family.

gcc/cp/ChangeLog:

2014-08-21  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR fortran/44054
	* error.c (cp_diagnostic_finalizer): Delete.
	(init_error): Do not set diagnostic_finalizer here.

gcc/c-family/ChangeLog:

2014-08-21  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR fortran/44054
	* c-opts.c: Include tree-diagnostics.h.
	(c_diagnostic_finalizer): New.
	(c_common_initialize_diagnostics): Use it.

gcc/fortran/ChangeLog:

2014-08-21  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR fortran/44054
	* error.c (gfc_diagnostic_finalizer): Call default finalizer.

From-SVN: r214245
2014-08-20 23:07:29 +00:00
Manuel López-Ibáñez 3ba421e8be re PR c/59304 (#pragma diagnostic pop after warning fails for options unspecified in the command-line and disabled by default)
gcc/ChangeLog:

2014-08-20  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR c/59304
	* opts-common.c (set_option): Call diagnostic_classify_diagnostic
	before setting the option.
	* diagnostic.c (diagnostic_classify_diagnostic): Record
	command-line status.

gcc/testsuite/ChangeLog:

2014-08-20  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR c/59304
	* gcc.dg/pr59304.c: New test.

From-SVN: r214221
2014-08-20 12:48:16 +00:00
Marek Polacek 544c27ba10 re PR c/62059 (signed integer overflow in diagnostic.c adjust_line)
PR c/62059
	* diagnostic.c (adjust_line): Add gcc_checking_assert.
	(diagnostic_show_locus): Don't print caret diagnostic
	if a column is larger than the line_width.

Co-Authored-By: Manuel López-Ibáñez <manu@gcc.gnu.org>

From-SVN: r214074
2014-08-17 16:19:43 +00:00
Manuel López-Ibáñez 8e54f6d3ba re PR fortran/44054 (Handle -Werror, -Werror=, -fdiagnostics-show-option, !GCC$ diagnostic (pragmas) and color)
2014-08-15  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR fortran/44054
gcc/
	* diagnostic.c (build_message_string): Make it extern.
	* diagnostic.h (build_message_string): Make it extern.
c-family/
	* c-format.c: Handle Fortran flags.
fortran/
	* gfortran.h: Define GCC_DIAG_STYLE.
	(gfc_diagnostics_init,gfc_warning_cmdline): Declare.
	* trans-array.c: Include gfortran.h before diagnostic-core.h.
	* trans-expr.c: Likewise.
	* trans-openmp.c: Likewise.
	* trans-const.c: Likewise.
	* trans.c: Likewise.
	* trans-types.c: Likewise.
	* f95-lang.c: Likewise.
	* trans-decl.c: Likewise.
	* trans-io.c: Likewise.
	* trans-intrinsic.c: Likewise.
	* error.c: Include diagnostic.h and diagnostic-color.h.
	(gfc_diagnostic_build_prefix): New.
	(gfc_diagnostic_starter): New.
	(gfc_diagnostic_finalizer): New.
	(gfc_warning_cmdline): New.
	(gfc_diagnostics_init): New.
	* gfc-diagnostic.def: New.
	* options.c (gfc_init_options): Call gfc_diagnostics_init.
	(gfc_post_options): Use gfc_warning_cmdline.

From-SVN: r214024
2014-08-15 15:10:15 +00:00
Dodji Seketeli 7ecc3eb9e6 PR preprocessor/58580 - preprocessor goes OOM with warning for zero literals
In this problem report, the compiler is fed a (bogus) translation unit
in which some literals contain bytes whose value is zero.  The
preprocessor detects that and proceeds to emit diagnostics for that
king of bogus literals.  But then when the diagnostics machinery
re-reads the input file again to display the bogus literals with a
caret, it attempts to calculate the length of each of the lines it got
using fgets.  The line length calculation is done using strlen.  But
that doesn't work well when the content of the line can have several
zero bytes.  The result is that the read_line never sees the end of
the line because strlen repeatedly reports that the line ends before
the end-of-line character; so read_line thinks its buffer for reading
the line is too small; it thus increases the buffer, leading to a huge
memory consumption and disaster.

Here is what this patch does.

location_get_source_line is modified to return the length of a source
line that can now contain bytes with zero value.
diagnostic_show_locus() is then modified to consider that a line can
have characters of value zero, and so just shows a white space when
instructed to display one of these characters.

Additionally location_get_source_line is modified to avoid re-reading
each and every line from the beginning of the file until it reaches
the line number N that it is instructed to get; this was leading to
annoying quadratic behaviour when reading adjacent lines near the end
of (big) files.  So a cache is now associated to the file opened in
text mode.  When the content of the file is read, that content is
stashed in the file cache.  That file cache is searched for line
delimiters.  A number of line positions are saved in the cache and a
number of file caches are kept in memory.  That way when
location_get_source_line is asked to read line N + 1, it just has to
start reading from line N that it has already read.

libcpp/ChangeLog:

	* include/line-map.h (linemap_get_file_highest_location): Declare
	new function.
	* line-map.c (linemap_get_file_highest_location): Define it.

gcc/ChangeLog:

	* input.h (location_get_source_line): Take an additional line_size
	parameter.
	(void diagnostics_file_cache_fini): Declare new function.
	* input.c (struct fcache): New type.
	(fcache_tab_size, fcache_buffer_size, fcache_line_record_size):
	New static constants.
	(diagnostic_file_cache_init, total_lines_num)
	(lookup_file_in_cache_tab, evicted_cache_tab_entry)
	(add_file_to_cache_tab, lookup_or_add_file_to_cache_tab)
	(needs_read, needs_grow, maybe_grow, read_data, maybe_read_data)
	(get_next_line, read_next_line, goto_next_line, read_line_num):
	New static function definitions.
	(diagnostic_file_cache_fini): New function.
	(location_get_source_line): Take an additional output line_len
	parameter.  Re-write using lookup_or_add_file_to_cache_tab and
	read_line_num.
	* diagnostic.c (diagnostic_finish): Call
	diagnostic_file_cache_fini.
	(adjust_line): Take an additional input parameter for the length
	of the line, rather than calculating it with strlen.
	(diagnostic_show_locus): Adjust the use of
	location_get_source_line and adjust_line with respect to their new
	signature.  While displaying a line now, do not stop at the first
	null byte.  Rather, display the zero byte as a space and keep
	going until we reach the size of the line.
	* Makefile.in: Add vec.o to OBJS-libcommon

gcc/testsuite/ChangeLog:

	* c-c++-common/cpp/warning-zero-in-literals-1.c: New test file.

Signed-off-by: Dodji Seketeli <dodji@seketeli.org>

From-SVN: r206957
2014-01-23 10:13:08 +01:00
Richard Sandiford 23a5b65a92 Update copyright years in gcc/
From-SVN: r206289
2014-01-02 22:23:26 +00:00
Dodji Seketeli 7f4d640cd9 Revert "preprocessor/58580 - preprocessor goes OOM with warning for zero literals"
This reverts commit fc3eff8854861fcd70d33d26095b17fe456fae31.

From-SVN: r204490
2013-11-06 23:51:36 +01:00
Dodji Seketeli 9789a91276 preprocessor/58580 - preprocessor goes OOM with warning for zero literals
In this problem report, the compiler is fed a (bogus) translation unit
in which some literals contain bytes whose value is zero.  The
preprocessor detects that and proceeds to emit diagnostics for that
king of bogus literals.  But then when the diagnostics machinery
re-reads the input file again to display the bogus literals with a
caret, it attempts to calculate the length of each of the lines it got
using fgets.  The line length calculation is done using strlen.  But
that doesn't work well when the content of the line can have several
zero bytes.  The result is that the read_line never sees the end of
the line because strlen repeatedly reports that the line ends before
the end-of-line character; so read_line thinks its buffer for reading
the line is too small; it thus increases the buffer, leading to a huge
memory consumption, pain and disaster.

The patch below introduces a new get_line function that returns the
next line of a file and return the length of that line even if the
line contains zero bytes.  That get_line function has been adapted
from the getline function from the GNU C Library because getline being
a GNU extension it is not necessarily supported on all platforms.
read_line is then modified to return the length of the line along with
the line itself, as the line can now contain zero bytes.  Callers of
read_line are adjusted consequently.

diagnostic_show_locus() is modified to consider that a line can have
characters of value zero, and so just shows a white space when
instructed to display one of these characters.

gcc/ChangeLog:

	* input.h (location_get_source_line): Take an additional line_size
	parameter.
	* input.c (get_line): New static function definition.
	(read_line): Take an additional line_length output parameter to be
	set to the size of the line.  Use the new get_line function do the
	actual line reading.
	(location_get_source_line): Take an additional output line_len
	parameter.  Update the use of read_line to pass it the line_len
	parameter.
	* diagnostic.c (adjust_line): Take an additional input parameter
	for the length of the line, rather than calculating it with
	strlen.
	(diagnostic_show_locus): Adjust the use of
	location_get_source_line and adjust_line with respect to their new
	signature.  While displaying a line now, do not stop at the first
	null byte.  Rather, display the zero byte as a space and keep
	going until we reach the size of the line.

gcc/testsuite/ChangeLog:

	* c-c++-common/cpp/warning-zero-in-literals-1.c: New test file.

From-SVN: r204453
2013-11-06 12:33:52 +01:00
Richard Sandiford c328471880 alloc-pool.c, [...]: Add missing whitespace before "(".
gcc/
	* alloc-pool.c, asan.c, auto-inc-dec.c, basic-block.h, bb-reorder.c,
	bitmap.c, bitmap.h, bt-load.c, builtins.c, calls.c, cfgcleanup.c,
	cfgexpand.c, cfghooks.c, cfgloop.c, cfgloopmanip.c, cfgrtl.c, cgraph.c,
	cgraph.h, cgraphbuild.c, cgraphclones.c, cgraphunit.c, collect2.c,
	combine-stack-adj.c, combine.c, compare-elim.c, context.c, context.h,
	cprop.c, cse.c, cselib.c, dbxout.c, dce.c, defaults.h, df-core.c,
	df-problems.c, df-scan.c, df.h, diagnostic.c, double-int.c, dse.c,
	dumpfile.c, dwarf2asm.c, dwarf2cfi.c, dwarf2out.c, emit-rtl.c,
	errors.c, except.c, expmed.c, expr.c, file-find.c, final.c,
	fixed-value.c, fold-const.c, function.c, fwprop.c, gcc-ar.c, gcc.c,
	gcov-io.c, gcov-io.h, gcov.c, gcse.c, genattr-common.c, genattr.c,
	genattrtab.c, genautomata.c, genconfig.c, genemit.c, genextract.c,
	genflags.c, gengenrtl.c, gengtype-state.c, gengtype.c, genmodes.c,
	genopinit.c, genoutput.c, genpeep.c, genpreds.c, genrecog.c,
	gensupport.c, ggc-common.c, ggc-page.c, gimple-fold.c, gimple-low.c,
	gimple-pretty-print.c, gimple-ssa-strength-reduction.c, gimple.c,
	gimple.h, godump.c, graphite-clast-to-gimple.c,
	graphite-optimize-isl.c, graphite-poly.h, graphite-sese-to-poly.c,
	graphite.c, haifa-sched.c, hash-table.c, hash-table.h, hwint.c,
	hwint.h, ifcvt.c, incpath.c, init-regs.c, input.h, intl.c, intl.h,
	ipa-cp.c, ipa-devirt.c, ipa-inline-analysis.c, ipa-inline.c,
	ipa-profile.c, ipa-pure-const.c, ipa-reference.c, ipa-split.c,
	ipa-utils.c, ipa.c, ira-build.c, ira.c, jump.c, loop-doloop.c,
	loop-init.c, loop-invariant.c, loop-iv.c, lower-subreg.c, lto-cgraph.c,
	lto-streamer-in.c, lto-streamer-out.c, lto-wrapper.c, mcf.c,
	mode-switching.c, modulo-sched.c, omp-low.c, optabs.c, opts.c,
	pass_manager.h, passes.c, plugin.c, postreload-gcse.c, postreload.c,
	predict.c, prefix.c, pretty-print.c, print-rtl.c, print-tree.c,
	profile.c, read-md.c, real.c, real.h, recog.c, ree.c, reg-stack.c,
	regcprop.c, reginfo.c, regmove.c, regrename.c, regs.h, regstat.c,
	reload1.c, reorg.c, rtl.c, rtl.h, rtlanal.c, sbitmap.c, sched-rgn.c,
	sdbout.c, sel-sched-ir.c, sel-sched.c, sparseset.c, stack-ptr-mod.c,
	statistics.c, stmt.c, stor-layout.c, store-motion.c, streamer-hooks.h,
	system.h, target-hooks-macros.h, targhooks.c, targhooks.h, toplev.c,
	tracer.c, trans-mem.c, tree-browser.c, tree-call-cdce.c, tree-cfg.c,
	tree-cfgcleanup.c, tree-complex.c, tree-data-ref.c, tree-data-ref.h,
	tree-eh.c, tree-emutls.c, tree-flow.h, tree-if-conv.c, tree-into-ssa.c,
	tree-iterator.c, tree-loop-distribution.c, tree-mudflap.c,
	tree-nested.c, tree-nomudflap.c, tree-nrv.c, tree-object-size.c,
	tree-optimize.c, tree-pass.h, tree-pretty-print.c, tree-profile.c,
	tree-scalar-evolution.c, tree-sra.c, tree-ssa-ccp.c,
	tree-ssa-coalesce.c, tree-ssa-copy.c, tree-ssa-copyrename.c,
	tree-ssa-dce.c, tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
	tree-ssa-ifcombine.c, tree-ssa-live.c, tree-ssa-loop-ch.c,
	tree-ssa-loop-im.c, tree-ssa-loop-ivopts.c, tree-ssa-loop-prefetch.c,
	tree-ssa-loop.c, tree-ssa-math-opts.c, tree-ssa-operands.c,
	tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
	tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
	tree-ssa-structalias.c, tree-ssa-threadedge.c, tree-ssa-threadupdate.c,
	tree-ssa-uncprop.c, tree-ssa-uninit.c, tree-ssa.c, tree-ssanames.c,
	tree-stdarg.c, tree-switch-conversion.c, tree-tailcall.c,
	tree-vect-data-refs.c, tree-vect-generic.c, tree-vect-loop-manip.c,
	tree-vect-stmts.c, tree-vectorizer.c, tree-vectorizer.h, tree-vrp.c,
	tree.c, tree.h, tsan.c, tsystem.h, value-prof.c, var-tracking.c,
	varasm.c, vec.h, vmsdbgout.c, vtable-verify.c, web.c: Add missing
	whitespace before "(".

From-SVN: r203004
2013-09-28 08:42:34 +00:00
Paolo Carlini 97f1f314fe re PR c++/54941 (do not print line/column numbers for <built-in>:0:0)
2013-09-08  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/54941
	* diagnostic.c (diagnostic_build_prefix): When s.file is
	"<built-in>" don't output line and column numbers.

/testsuite
2013-09-08  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/54941
	* g++.dg/overload/new1.C: Adjust.

From-SVN: r202366
2013-09-08 14:30:27 +00:00
Gabriel Dos Reis 025311c4bb diagnostic.c (diagnostic_set_caret_max_width): Use pp_buffer.
* diagnostic.c (diagnostic_set_caret_max_width): Use pp_buffer.
	* gimple-pretty-print.c (gimple_dump_bb_buff): Likewise.
	* pretty-print.c (pp_formatted_text_data): Likewise.
	(pp_write_text_to_stream): Likewise.
	(pp_write_text_as_dot_label_to_stream): Likewise.
	(pp_append_r): Likewise.
	(pp_format): Likewise.
	(pp_flush): Likewise.
	(pp_clear_output_area): Likewise.
	(pp_append_text): Likewise.
	(pp_formatted_text): Likewise.
	(pp_remaining_character_count_for_line): Likewise.
	(pp_newline): Likewise.
	(pp_character): Likewise.
	(output_buffer::~output_buffer): Define.
	(pretty_printer::~pretty_printer): Destruct output buffer.
	* pretty-print.h (output_buffer::~output_buffer): Declare.
	(pretty_printer::~pretty_printer): Declare virtual.

c/
	* c-objc-common.c (c_tree_printer): Document the nature of the cast.
	(c_initialize_diagnostics): Call a destructor for the early printer.

cp/
	* cp-objcp-common.c (cxx_initialize_diagnostics): Call a
	destructor for the early printer.
	* error.c (type_to_string): Use pp_buffer.

From-SVN: r201956
2013-08-23 23:58:55 +00:00
Gabriel Dos Reis da6ca2b5ee pretty-print.h (output_buffer::output_buffer): Declare.
* pretty-print.h (output_buffer::output_buffer): Declare.
	(pretty_printer::pretty_printer): Likewise.
	(pp_construct): Remove.
	* pretty-print.c (output_buffer::output_buffer): Define.
	(pretty_printer::pretty_printer): Rename from pp_construct.  Simplify.
	* gimple-pretty-print.c (print_gimple_stmt): Do not call pp_construct.
	(print_gimple_expr): Likewise.
	(print_gimple_seq): Likewise.
	(gimple_dump_bb): Likewise.
	* sched-vis.c (dump_value_slim): Likewise.
	(dump_insn_slim): Likewise.
	(dump_rtl_slim): Likewise.
	(str_pattern_slim): Likewise.
	* tree-mudflap.c (mf_varname_tree): Likewise.
	* graph.c (print_graph_cfg): Likewise.
	(start_graph_dump): Likewise.
	* tree-pretty-print.c (maybe_init_pretty_print): Likewise.  Use
	placement-new.
	* diagnostic.c (diagnostic_initialize): Simplify early diagnostic
	pretty printer initialization.
	* coretypes.h (diagnostic_context): Remove superflous type alias
	declaration.
	(pretty_printer): Likewise.  Declare directly as a class.
	(pretty_print_info): Remove declaration as class.
	* asan.c (asan_emit_stack_protection): Remove call to pp_construct
	and pp_clear_output_area.
	(asan_add_global): Likewise.

c/
	* c-objc-common.c (c_initialize_diagnostics): Simplify C pretty
	printer initialization.

c-family/
	* c-pretty-print.h (pp_c_pretty_printer_init): Remove.
	(c_pretty_printer::c_pretty_printer): Declare.
	* c-pretty-print.c (pretty_printer::c_pretty_printer): Rename from
	c_pretty_printer_init.  Adjust.
	(print_c_tree): Do not call c_pretty_printer_init.
	* c-ada-spec.c (dump_ads): Remove call to pp_construct.

cp/
	* error.c (init_error): Remove calls to pp_construct and
	pp_cxx_pretty_printer_init.  Initialize cxx_pp with placement-new.
	* cxx-pretty-print.h (cxx_pretty_printer::cxx_pretty_printer): Declare.
	(cxx_pretty_printer_init): Remove.
	* cxx-pretty-print.c (cxx_pretty_printer::cxx_pretty_printer):
	Rename from cxx_pretty_printer_init.  Adjust.
	* cp-objcp-common.c (cxx_initialize_diagnostics): Simplify
	initialization of C++ diagnostics pretty printer.

From-SVN: r201918
2013-08-22 10:14:46 +00:00
Eric Botcazou 3c8ca1abde diagnostic.c (diagnostic_classify_diagnostic): Accept zero index and document its semantics.
* diagnostic.c (diagnostic_classify_diagnostic): Accept zero index and
	document its semantics.
	(diagnostic_report_diagnostic): Adjust accordingly.

From-SVN: r201574
2013-08-07 17:15:25 +00:00
Gabriel Dos Reis 07838b1363 pretty-print.h (pp_underscore): New.
* pretty-print.h (pp_underscore): New.
	(pp_comma): Tidy.
	* gimple-pretty-print.c (dump_unary_rhs): Use specialized pretty
	printer functions instead of pp_character.
	(dump_binary_rhs): Likewise.
	(dump_ternary_rhs): Likewise.
	(dump_gimple_call_args): Likewise.
	(pp_points_to_solution): Likewise.
	(dump_gimple_call): Likewise.
	(dump_gimple_switch): Likewise.
	(dump_gimple_cond): Likewise.
	(dump_gimple_bind): Likewise.
	(dump_gimple_try): Likewise.
	(dump_gimple_omp_for): Likewise.
	(dump_gimple_omp_continue): Likewise.
	(dump_gimple_omp_single): Likewise.
	(dump_gimple_omp_sections): Likewise.
	(dump_gimple_omp_block): Likewise.
	(dump_gimple_omp_critical): Likewise.
	(dump_gimple_transaction): Likewise.
	(dump_gimple_asm): Likewise.
	(dump_gimple_phi): Likewise.
	(dump_gimple_omp_parallel): Likewise.
	(dump_gimple_omp_task): Likewise.
	(dump_gimple_omp_atomic_load): Likewise.
	(dump_gimple_omp_atomic_store): Likewise.
	(dump_gimple_mem_ops): Likewise.
	(pp_gimple_stmt_1): Likewise.
	(pp_cfg_jump): Likewise.
	(dump_implicit_edges): Likewise.
	(gimple_dump_bb_for_graph): Likewise.
	* graph.c (draw_cfg_node): Likewise.
	* langhooks.c (lhd_print_error_function): Likewise.
	* sched-vis.c (print_exp): Likewise.
	(print_value): Likewise.
	(print_pattern): Likewise.
	(print_insn): Likewise.
	(rtl_dump_bb_for_graph): Likewise.
	* tree-pretty-print.c (dump_function_declaration): Likewise.
	(dump_array_domain): Likewise.
	(dump_omp_clause): Likewise.
	(dump_location): Likewise.
	(dump_generic_node): Likewise.
	(print_struct_decl): Likewise.
	* diagnostic.c (diagnostic_show_locus): Use pp_space.

c-family/
	* c-ada-spec.c (print_ada_macros): Use specialized pretty printer
	functions instead of pp_character.
	(pp_ada_tree_identifier): Likewise.
	(dump_ada_double_name): Likewise.
	(dump_ada_function_declaration): Likewise.
	(dump_ada_array_domains): Likewise.
	(dump_template_types): Likewise.
	(dump_generic_ada_node): Likewise.
	(print_ada_declaration): Likewise.
	(print_ada_struct_decl): Likewise.
	* c-pretty-print.c (pp_c_integer_constant): Likewise.

cp/
	* error.c (dump_aggr_type): Use specialized pretty printer
	functions instead of pp_character.
	(dump_type_prefix): Likewise.
	(dump_simple_decl): Likewise.
	(type_to_string): Likewise.

From-SVN: r201467
2013-08-03 18:57:25 +00:00
Jakub Jelinek 2e55d06281 tree.c (warn_deprecated_use): Print file:line using locus color.
* tree.c (warn_deprecated_use): Print file:line using locus color.
	* diagnostic.c (diagnostic_report_current_module): Print file:line
	and file:line:column using locus color.

From-SVN: r198900
2013-05-14 21:41:13 +02:00
Jakub Jelinek e78e8a0b19 diagnostic.h (file_name_as_prefix): Add context argument.
* diagnostic.h (file_name_as_prefix): Add context argument.
	* diagnostic.c (file_name_as_prefix): Likewise.  Colorize
	the string as locus.
	* langhooks.c (lhd_print_error_function): Adjust caller.
cp/
	* error.c (cp_print_error_function): Adjust file_name_as_prefix
	caller.

From-SVN: r198331
2013-04-26 08:54:54 +02: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
Jakub Jelinek 4432aa6c81 re PR middle-end/56461 (GCC is leaking lots of memory)
PR middle-end/56461
	* diagnostic.c (diagnostic_append_note): Save and restore old prefix.

From-SVN: r196445
2013-03-04 22:52:08 +01:00
Richard Sandiford d1e082c2c2 Update copyright years in gcc/
From-SVN: r195098
2013-01-10 20:38:27 +00:00
Tobias Burnus 3b4adfb357 diagnostic.c (diagnostic_append_note): Also call va_end when inhibit_notes_p is true.
2012-11-12  Tobias Burnus  <burnus@net-b.de>

        * diagnostic.c (diagnostic_append_note): Also call va_end when
        inhibit_notes_p is true.

From-SVN: r193428
2012-11-12 12:00:58 +01:00
Manuel López-Ibáñez dfa3226153 re PR c++/54928 (Infinite output with after ICE with macro)
2012-10-24  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR c++/54928
	* tree-diagnostic.c (maybe_unwind_expanded_macro_loc):
	Use diagnostic_append_note.
	* diagnostic.c (diagnostic_build_prefix): Make diagnostic const.
	(default_diagnostic_finalizer): Do not destroy prefix here.
	(diagnostic_report_diagnostic): Destroy it here.
	(diagnostic_append_note): New.
	* diagnostic.h (diagnostic_append_note): Declare.

From-SVN: r192786
2012-10-24 22:01:50 +00:00
Ian Lance Taylor a67a73fd0c * diagnostic.c (bt_callback): Cast pc when calling fprintf.
From-SVN: r191766
2012-09-26 17:49:38 +00:00
Ian Lance Taylor d83697f4f0 Makefile.def: Make all-gcc depend on all-libbacktrace.
./:	* Makefile.def: Make all-gcc depend on all-libbacktrace.
	* Makefile.in: Rebuild.
gcc/:
	* diagnostic.c: Include "demangle.h" and "backtrace.h".
	(bt_stop): New static array.
	(bt_callback, bt_err_callback): New static functions.
	(diagnostic_action_after_output): Call backtrace_full for DK_ICE.
	* Makefile.in (BACKTRACE): New variable.
	(BACKTRACEINC, LIBBACKTRACE): New variables.
	(BACKTRACE_H): New variable.
	(LIBDEPS, LIBS): Add $(LIBBACKTRACE).
	(INCLUDES): Add $(BACKTRACEINC).
	(diagnostic.o): Depend upon $(DEMANGLE_H) and $(BACKTRACE_H).

From-SVN: r191757
2012-09-26 12:38:08 +00:00
Steven Bosscher f8923f7ead cfg.c (debug_bb): Do not set TDF_BLOCKS.
gcc/
	* cfg.c (debug_bb): Do not set TDF_BLOCKS.
	* cfghooks.c (dump_bb): Honor ~TDF_BLOCKS.
	* pretty-print.c (pp_base_flush): Do not add a newline, and do not
	clear pp_needs_newline.
	* pretty-print.h (pp_newline_and_flush): New macro with the behavior
	of pp_base_flush before the above change.
	* langhooks.c (lhd_print_error_function): Use pp_newline_and_flush
	instead of pp_flush.
	* diagnostic.c (diagnostic_finish): Likewise.
	(diagnostic_report_diagnostic): Likewise.
	(verbatim): Likewise.
	(error_recursion): Likewise.
	* tree-pretty-print.c (print_generic_stmt): Likewise.
	(print_generic_stmt_indented): LIkewise.
	* gimple-pretty-print.c (print_gimple_stmt): Likewise.
	(print_gimple_seq): Likewise.
	(gimple_dump_bb_buff): Likewise.

c-family/
	* c-pretty-print.c (pp_c_function_definition): Use pp_newline_and_flush
	instead of separate pp_newline and pp_flush.
	(print_c_tree): Likewise.

cp/
	* error.c (print_instantiation_context): Pretty-print a newline before
	diagnostic_flush_buffer.
	* cxx-pretty-print.c (pp_cxx_function_definition): Use
	pp_newline_and_flush instead of separate pp_newline and pp_flush.

testsuite/
	* gcc.dg/tree-prof/update-loopch.c: Ask for dump with blocks info.
	* gcc.dg/tree-ssa/attr-hotcold-2.c: Likewise.
	* gcc.dg/tree-ssa/pr18133-1.c: Likewise.

From-SVN: r190215
2012-08-07 22:14:29 +00:00
Manuel López-Ibáñez 1b8b126f38 re PR c++/53289 (unnecessary repetition of caret diagnostics)
2012-05-09  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR c++/53289
gcc/
	* diagnostic.h (diagnostic_context): Add last_location.
	* diagnostic.c (diagnostic_initialize): Initialize it.
	(diagnostic_show_locus): Use it.

From-SVN: r187355
2012-05-09 21:14:15 +00:00
Manuel López-Ibáñez 0c3641b0ea flags.h (flag_permissive): Do not declare.
2012-05-03  Manuel López-Ibáñez  <manu@gcc.gnu.org>

gcc/
	* flags.h (flag_permissive): Do not declare.
	* diagnostic.c (diagnostic_report_diagnostic): Handle fpermissive
	option specially.
	* toplev.c (flag_permissive): Do not define.
	* c-tree.h (system_header_p): Delete unused.
c-family/
	* c.opt (fpermissive): Add Var(flag_permissive).

From-SVN: r187123
2012-05-03 22:28:21 +00:00
Dodji Seketeli 7eb918cc4e Make expand_location resolve to locus in main source file
Apparently, quite some places in the compiler (like the C/C++
preprocessor, the debug info machinery) expect expand_location to
resolve to locations that are in the main source file, even if the
token at stake comes from a macro that was defined in a header
somewhere.  Turning on -ftrack-macro-expansion by default was
triggering a lot of failures (not necessarily related to diagnostics)
because expand_location resolves to spelling locations instead.

So I have changed expand_location to honour the initial expectation.

In addition, I came up with the new expand_location_to_spelling_point
used in diagnostic_build_prefix because the diagnostic system, on the
other hand, wants to point to the location of the token where it was
spelled, and then display the error context involving all the macro
whose expansion led to that spelling point - if we are in the context
of a macro expansion there.

This seems to me like a reasonable balance.

Tested and bootstrapped on x86_64-unknown-linux-gnu against trunk and
whitnessed that a lot more tests were PASSing.

Note that the bootstrap with -ftrack-macro-expansion exhibits other
separate issues that are addressed in subsequent patches.  This patch
just fixes one class of problems.

The patch does pass bootstrap with -ftrack-macro-expansion turned off,
though.

gcc/

	* input.c (expand_location_1): New.  Takes a parameter to choose
	whether to resolve the location to spelling or expansion point.
	Was factorized from ...
	(expand_location): ... here.
	(expand_location_to_spelling_point): New.  Implemented in terms of
	expand_location_1.
	* diagnostic.c (diagnostic_build_prefix): Use the new
	expand_location_to_spelling_point instead of expand_location.

From-SVN: r186969
2012-04-30 13:42:00 +02:00
Manuel López-Ibáñez c1771a200a re PR c/44774 (-Werror=edantic)
2012-04-22  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR c/44774
gcc/
	* doc/invoke.texi (pedantic): Rename to Wpedantic.
	* common.opt (Wpedantic): New.
	(pedantic): Alias Wpedantic.
	* diagnostic.c (warning_at): Likewise.
	* c-decl.c (diagnose_mismatched_decls): Likewise.
	(build_array_declarator): Likewise.
	(mark_forward_parm_decls):
	(check_bitfield_type_and_width): Likewise.
	(grokdeclarator): Likewise.
	(grokfield): Likewise.
	(finish_struct): Likewise.
	(build_enumerator): Likewise.
	(store_parm_decls_oldstyle): Likewise.
	(declspecs_add_qual): Likewise.
	(declspecs_add_type): Likewise.
	(finish_declspecs): Likewise.
	* c-typeck.c (composite_type): Likewise.
	(comp_target_types): Likewise.
	(build_array_ref): Likewise.
	(pointer_diff): Likewise.
	(build_unary_op): Likewise.
	(build_conditional_expr): Likewise.
	(build_c_cast): Likewise.
	(convert_for_assignment): Likewise.
	(maybe_warn_string_init): Likewise.
	(digest_init): Likewise.
	(pop_init_level): Likewise.
	(set_init_index): Likewise.
	(c_finish_goto_label): Likewise.
	(c_finish_return): Likewise.
	(do_case): Likewise.
	(build_binary_op): Likewise.
	* c-parser.c (static): Likewise.
	(c_parser_external_declaration): Likewise.
	(c_parser_declaration_or_fndef): Likewise.
	(c_parser_static_assert_declaration_no_se): Likewise.
	(c_parser_enum_specifier): Likewise.
	(c_parser_struct_or_union_specifier): Likewise.
	(c_parser_struct_declaration): Likewise.
	(c_parser_alignas_specifier): Likewise.
	(c_parser_braced_init): Likewise.
	(c_parser_initelt): Likewise.
	(c_parser_compound_statement_nostart): Likewise.
	(c_parser_conditional_expression): Likewise.
	(c_parser_alignof_expression): Likewise.
	(c_parser_postfix_expression): Likewise.
	(c_parser_postfix_expression_after_paren_): Likewise.
	(c_parser_objc_class_instance_variables): Likewise.
	(c_parser_objc_method_definition): Likewise.
	(c_parser_objc_methodprotolist): Likewise.

c-family/
	* c.opt (Wpedantic): New.
	(pedantic): Alias Wpedantic.
	* c-opts.c (c_common_handle_option): Replace -pedantic with -Wpedantic.
	(c_common_post_options): Likewise.
	(sanitize_cpp_opts): Likewise.
	* c-lex.c (interpret_float): Likewise.
	* c-format.c (check_format_types): Likewise.
	* c-common.c (pointer_int_sum): Likewise.
	(c_sizeof_or_alignof_type): Likewise.
	(c_add_case_label): Likewise.
	(c_do_switch_warnings): Likewise.
	* c-pragma.c (handle_pragma_float_const_decimal64): Likewise.
cp/
	* typeck.c (composite_pointer_type): Likewise.
	(cxx_sizeof_or_alignof_type): Likewise.
	(cp_build_array_ref): Likewise.
	(cp_build_function_call_vec): Likewise.
	(cp_build_addr_expr_1): Likewise.
	(convert_member_func_to_ptr): Likewise.
	* decl.c (check_tag_decl): Likewise.
	(check_static_variable_definition): Likewise.
	(compute_array_index_type): Likewise.
	(create_array_type_for_decl): Likewise.
	(grokdeclarator): Likewise.
	(grok_op_properties): Likewise.
	* error.c (maybe_warn_cpp0x): Likewise.
	* pt.c (maybe_process_partial_specialization): Likewise.
	(convert_template_argument): Likewise.
	(do_decl_instantiation): Likewise.
	(do_type_instantiation): Likewise.
	* parser.c (cp_parser_primary_expression): Likewise.
	(cp_parser_postfix_expression): Likewise.
	(cp_parser_unary_expression): Likewise.
	(cp_parser_question_colon_clause): Likewise.
	(cp_parser_lambda_introducer): Likewise.
	(cp_parser_lambda_declarator_opt): Likewise.
	(cp_parser_compound_statement): Likewise.
	(cp_parser_jump_statement): Likewise.
	(cp_parser_declaration_seq_opt): Likewise.
	(cp_parser_enum_specifier): Likewise.
	(cp_parser_enumerator_list): Likewise.
	(cp_parser_initializer_list): Likewise.
	(cp_parser_member_declaration): Likewise.
	* call.c (build_conditional_expr_1): Likewise.
	* friend.c (make_friend_class): Likewise.
	* name-lookup.c (pushdecl_maybe_friend_1): Likewise.

From-SVN: r186681
2012-04-22 19:17:47 +00:00
Michael Matz 80f2435130 diagnostic.c (emit_diagnostic): Move va_end call after user of the va_list.
* diagnostic.c (emit_diagnostic): Move va_end call after user
	of the va_list.
	(warning, warning_at, pedwarn, permerror): Ditto.

From-SVN: r186591
2012-04-19 12:51:25 +00:00
Manuel López-Ibáñez 9fec00429d re PR c++/24985 (caret diagnostics)
2012-04-11  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR 24985
gcc/
        * diagnostic.h (show_caret): Declare.
	(caret_max_width): Declare.
	(diagnostic_show_locus): Declare.
        * diagnostic.c (diagnostic_initialize): Initialize to false.
        (diagnostic_show_locus): New.
        (diagnostic_report_diagnostic): Call it.
	(getenv_columns): New.
	(adjust_line): New.
	(diagnostic_set_caret_max_width): New.
        * input.c (read_line): New.
	(location_get_source_line): New.
        * input.h (location_get_source_line): Declare.
        * toplev.c (general_init): Initialize show_caret from options.
        * dwarf2out.c (gen_producer_string): Handle fdiagnostics-show-caret.
        * opts.c (common_handle_option): Likewise.
	* pretty-print.h (pp_get_prefix): New.
	(pp_base_get_prefix): New.
        * common.opt (fdiagnostics-show-caret): New option.
	* doc/invoke.texi (fdiagnostics-show-caret): Document it.
testsuite/
        * lib/prune.exp: Add -fno-diagnostics-show-caret.
libstdc++-v3/
	* testsuite/lib/prune.exp: Handle caret.
libmudflap/
	* testsuite/lib/libmudflap.exp: Handle caret.

From-SVN: r186305
2012-04-11 09:26:48 +00:00
Jakub Jelinek 1f01c3ecd1 re PR middle-end/48071 (Blank line after 'all warnings being treated as errors')
PR middle-end/48071
	* diagnostic.c (diagnostic_finish): Remove trailing newlines.

From-SVN: r183847
2012-02-02 21:46:06 +01:00
Tom Tromey 07a0b324eb Emit macro expansion related diagnostics
In this third instalment the diagnostic machinery -- when faced with
the virtual location of a token resulting from macro expansion -- uses
the new linemap APIs to unwind the stack of macro expansions that led
to that token and emits a [hopefully] more useful message than what we
have today.

diagnostic_report_current_module has been slightly changed to use the
location given by client code instead of the global input_location
variable.  This results in more precise diagnostic locations in
general but then the patch adjusts some C++ tests which output changed
as a result of this.

Three new regression tests have been added.

The mandatory screenshot goes like this:

[dodji@adjoa gcc]$ cat -n test.c
     1    #define OPERATE(OPRD1, OPRT, OPRD2) \
     2      OPRD1 OPRT OPRD2;
     3
     4    #define SHIFTL(A,B) \
     5      OPERATE (A,<<,B)
     6
     7    #define MULT(A) \
     8      SHIFTL (A,1)
     9
    10    void
    11    g ()
    12    {
    13      MULT (1.0);/* 1.0 << 1; <-- so this is an error.  */
    14    }

[dodji@adjoa gcc]$ ./cc1 -quiet -ftrack-macro-expansion test.c
test.c: In function 'g':
test.c:5:14: erreur: invalid operands to binary << (have 'double' and 'int')
test.c:2:9: note: in expansion of macro 'OPERATE'
test.c:5:3: note: expanded from here
test.c:5:14: note: in expansion of macro 'SHIFTL'
test.c:8:3: note: expanded from here
test.c:8:3: note: in expansion of macro 'MULT2'
test.c:13:3: note: expanded from here

Co-Authored-By: Dodji Seketeli <dodji@redhat.com>

From-SVN: r180083
2011-10-17 11:59:27 +02:00
Tom Tromey 46427374e1 Linemap infrastructure for virtual locations
This is the first instalment of a set which goal is to track locations
of tokens across macro expansions.  Tom Tromey did the original work
and attached the patch to PR preprocessor/7263.  This opus is a
derivative of that original work.

This patch modifies the linemap module of libcpp to add virtual
locations support.

A virtual location is a mapped location that can resolve to several
different physical locations.  It can always resolve to the spelling
location of a token.  For tokens resulting from macro expansion it can
resolve to:
  - either the location of the expansion point of the macro.
  - or the location of the token in the definition of the
  macro
  - or, if the token is an argument of a function-like macro,
  the location of the use of the matching macro parameter in
  the definition of the macro

The patch creates a new type of line map called a macro map.  For every
single macro expansion, there is a macro map that generates a virtual
location for every single resulting token of the expansion.

The good old type of line map we all know is now called an ordinary
map.  That one still encodes spelling locations as it has always had.

As a result linemap_lookup as been extended to return a macro map when
given a virtual location resulting from a macro expansion.  The layout
of structs line_map has changed to support this new type of map.  So
did the layout of struct line_maps.  Accessor macros have been
introduced to avoid messing with the implementation details of these
datastructures directly.  This helped already as we have been testing
different ways of arranging these datastructure.  Having to constantly
adjust client code that is too tied with the internals of line_map and
line_maps would have been even more painful.

Of course, many new public functions have been added to the linemap
module to handle the resolution of virtual locations.

This patch introduces the infrastructure but no part of the compiler
uses virtual locations yet.

However the client code of the linemap data structures has been
adjusted as per the changes.  E.g, it's not anymore reliable for a
client code to manipulate struct line_map directly if it just wants to
deal with spelling locations, because struct line_map can now
represent a macro map as well.  In that case, it's better to use the
convenient API to resolve the initial (possibly virtual) location to a
spelling location (or to an ordinary map) and use that.

This is the reason why the patch adjusts the Java, Ada and Fortran
front ends.

Also, note that virtual locations are not supposed to be ordered for
relations '<' and '>' anymore.  To test if a virtual location appears
"before" another one, one has to use a new operator exposed by the
line map interface.  The patch updates the only spot (in the
diagnostics module) I have found that was making the assumption that
locations were ordered for these relations.  This is the only change
that introduces a use of the new line map API in this patch, so I am
adding a regression test for it only.

From-SVN: r180081
2011-10-17 11:58:56 +02:00
Nathan Froyd 3a789837f5 re PR c/44782 (implement -ferror-limit=)
gcc/
	PR c/44782
	* common.opt (fmax-errors=): New option.
	* opts.c (common_handle_option) [OPT_fmax_errors_]: Handle it.
	* diagnostic.h (struct diagnostic_context): Add max_errors field.
	* diagnostic.c (diagnostic_initialize): Initialize it.
	(diagnostic_action_after_output): Exit if more than max_errors
	have been output.
	* doc/invoke.texi (Warning Options): Add -fmax-errors.
	(-fmax-errors): Document.

gcc/fortran/
	PR c/44782
	* options.c (gfc_post_options): Initialize gfc_option.max_errors.
	(gfc_handle_option) [OPT_fmax_errors_]: Remove.
	* lang.opt (fmax-errors=): Remove.

gcc/testsuite/
	PR c/44782
	* c-c++-common/fmax-errors.c: New test.

From-SVN: r166644
2010-11-12 03:38:15 +00:00
Joseph Myers 46625112d2 opt-functions.awk (static_var): Update comment.
* opt-functions.awk (static_var): Update comment.
	(var_ref): Return offsetof expression or -1, not variable address.
	* optc-gen.awk: Generate structure field initializers instead of
	static variables.  Expect -1 for missing variables instead of null
	pointer.  Add gcc_options parameters to generated functions.
	* opth-gen.awk: Generate structure fields for static variables.
	Add gcc_options parameters to generated functions.
	* common.opt (optimize, optimize_size): Add variables.
	* config/i386/i386-c.c (ix86_pragma_target_parse): Pass
	&global_options to cl_target_option_restore.
	* config/i386/i386.c (ix86_valid_target_attribute_p): Pass
	&global_options to cl_optimization_restore, cl_target_option_save
	and cl_target_option_restore.
	(ix86_set_current_function): Pass &global_options to
	cl_target_option_restore.
	* config/pdp11/pdp11.h (optimize): Remove.
	* config/rs6000/rs6000.h (optimize): Remove.
	* config/sh/sh.h (optimize): Remove.
	* config/xtensa/xtensa.h (optimize): Remove.
	* coretypes.h (struct gcc_options): Declare.
	* diagnostic.c (diagnostic_initialize): Initialize
	context->option_state.
	(diagnostic_report_diagnostic): Pass option_state to
	option_enabled hook.
	* diagnostic.h (diagnostic_context.option_enabled): Add void *
	parameter.
	(diagnostic_context.option_state): New field.
	* final.c (final_start_function, final, final_scan_insn): Rename
	optimize parameter to optimize_p.
	* flags.h (optimize, optimize_size): Remove.
	* function.c (invoke_set_current_function_hook): Pass
	&global_options to cl_optimization_restore.
	* gcc.c (driver_handle_option): Take gcc_options parameter.
	Assert that it is &global_options.
	(process_command): Pass &global_options to read_cmdline_option.
	* ipa-pure-const.c (suggest_attribute): Pass &global_options to
	option_enabled.
	* lto-opts.c (lto_reissue_options): Use option_flag_var.  Pass
	&global_options to set_option.
	* opts-common.c (handle_option, handle_generated_option,
	read_cmdline_option, set_option): Take explicit gcc_options
	parameters.  Use option_flag_var.
	(option_flag_var): New.
	* opts.c (common_handle_option, lang_handle_option,
	target_handle_option): Take gcc_options parameter.  Assert that it
	is &global_options.
	(read_cmdline_options): Pass &global_options to
	read_cmdline_option.
	(print_filtered_help): Use option_flag_var.  Pass &global_options
	to option_enabled.
	(common_handle_option): Use option_flag_var.
	(option_enabled): Take opts parameter.  Use option_flag_var.
	(get_option_state): Take gcc_options parameter.  Use
	option_flag_var.  Pass gcc_options parameter to option_enabled.
	(enable_warning_as_error): Pass &global_options to
	handle_generated_option.
	* opts.h (struct cl_option): Change flag_var to flag_var_offset.
	(cl_option_handler_func.handler): Take gcc_options parameter.
	(option_enabled, get_option_state, set_option, handle_option,
	handle_generated_option, read_cmdline_option): Take gcc_options
	parameters.
	* toplev.c (optimize, optimize_size): Remove.
	(print_switch_values): Pass &global_options to option_enabled.
	(option_affects_pch_p): Use option_flag_var.  Pass &global_options
	to get_option_state.
	(general_init): Initialize global_dc->option_state.
	* tree.c (build_optimization_node): Pass &global_options to
	cl_optimization_save.
	(build_target_option_node): Pass &global_options to
	cl_target_option_save.

c-family:
	* c-common.c (handle_optimize_attribute): Pass &global_options to
	cl_optimization_save and cl_optimization_restore.
	* c-opts.c (c_common_handle_option): Pass &global_options to
	handle_generated_option.
	* c-pragma.c (handle_pragma_diagnostic): Use option_flag_var.
	(handle_pragma_pop_options, handle_pragma_reset_options): Pass
	&global_options to cl_optimization_restore.

From-SVN: r164751
2010-09-30 14:53:12 +01:00
Joseph Myers e3339d0f33 optc-gen.awk: Generate global_options initializer instead of individual variables.
gcc:
	* optc-gen.awk: Generate global_options initializer instead of
	individual variables.  Add x_ prefix to names of structure
	members.
	* opth-gen.awk: Generate gcc_options structure.  Add x_ prefix to
	names of structure members.
	* doc/tm.texi.in (HARD_FRAME_POINTER_IS_FRAME_POINTER,
	HARD_FRAME_POINTER_IS_ARG_POINTER): Document.
	* doc/tm.texi: Regenerate.
	* alias.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER
	* builtins.c: Use HARD_FRAME_POINTER_IS_ARG_POINTER.
	* c-parser.c (disable_extension_diagnostics,
	restore_extension_diagnostics): Update names of cpp_options
	members.
	* combine.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER
	* common.opt (fcompare-debug-second): Don't use Var.
	* config/alpha/alpha.h (target_flags): Remove.
	* config/arm/arm.h (HARD_FRAME_POINTER_IS_FRAME_POINTER,
	HARD_FRAME_POINTER_IS_ARG_POINTER): Define.
	* config/bfin/bfin.h (target_flags): Remove.
	* config/cris/cris.h (target_flags): Remove.
	* config/i386/i386-c.c (ix86_pragma_target_parse): Update names of
	cl_target_option members.
	* config/i386/i386.c (ix86_force_align_arg_pointer): Remove.
	(ix86_function_specific_print, ix86_valid_target_attribute_tree,
	ix86_can_inline_p): Update names of cl_target_option members.
	* config/i386/i386.h (ix86_isa_flags): Remove.
	* config/lm32/lm32.h (target_flags): Remove.
	* config/mcore/mcore.h (mcore_stack_increment): Remove.
	* config/mcore/mcore.md (addsi3): Remove extern declaration of
	flag_omit_frame_pointer.
	* config/mep/mep.h (target_flags): Remove.
	* config/mips/mips.h (HARD_FRAME_POINTER_IS_FRAME_POINTER,
	HARD_FRAME_POINTER_IS_ARG_POINTER): Define.
	* config/mmix/mmix.h (target_flags): Remove.
	* config/rs6000/rs6000.h (rs6000_xilinx_fpu, flag_pic,
	flag_expensive_optimizations): Remove.
	* config/s390/s390.h (flag_pic): Remove.
	* config/score/score-conv.h (target_flags): Remove.
	* config/sh/sh.h (sh_fixed_range_str): Remove.
	* config/spu/spu.h (target_flags, spu_fixed_range_string): Remove.
	* dbxout.c: Use HARD_FRAME_POINTER_IS_ARG_POINTER
	* df-scan.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER.
	* diagnostic.c (diagnostic_initialize): Update names of
	diagnostic_context members.
	* diagnostic.h (diagnostic_context): Rename inhibit_warnings and
	warn_system_headers.
	(diagnostic_report_warnings_p): Update for new names.
	* dwarf2out.c: Use HARD_FRAME_POINTER_IS_ARG_POINTER
	* emit-rtl.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER and
	HARD_FRAME_POINTER_IS_ARG_POINTER.
	* flags.h (flag_compare_debug): Declare.
	* ira.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER
	* opts.c (flag_compare_debug): Define.
	(common_handle_option): Update names of diagnostic_context
	members.  Handle -fcompare-debug-second.
	(fast_math_flags_struct_set_p): Update names of cl_optimization
	members.
	* reginfo.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER.
	* regrename.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER.
	* reload.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER.
	* reload1.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER.
	* resource.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER.
	* rtl.h (HARD_FRAME_POINTER_IS_FRAME_POINTER,
	HARD_FRAME_POINTER_IS_ARG_POINTER): Define and use.
	* sel-sched.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER
	* stmt.c: Use HARD_FRAME_POINTER_IS_ARG_POINTER.

gcc/c-family:
	* c-common.c (c_cpp_error): Update names of diagnostic_context
	members.
	* c-cppbuiltin.c (c_cpp_builtins_optimize_pragma): Update names of
	cl_optimization members.
	* c-opts.c (warning_as_error_callback, c_common_handle_option,
	sanitize_cpp_opts, finish_options): Update names of cpp_options
	members.

gcc/fortran:
	* cpp.c (cpp_define_builtins): Update names of gfc_option_t
	members.
	(gfc_cpp_post_options): Update names of cpp_options members.
	(cb_cpp_error): Update names of diagnostic_context members.
	* f95-lang.c (gfc_init_builtin_functions): Update names of
	gfc_option_t members.
	* gfortran.h (gfc_option_t): Rename warn_conversion and
	flag_openmp.
	* intrinsic.c (gfc_convert_type_warn): Update names of
	gfc_option_t members.
	* options.c (gfc_init_options, gfc_post_options, set_Wall,
	gfc_handle_option): Update names of gfc_option_t members.
	* parse.c (next_free, next_fixed): Update names of gfc_option_t
	members.
	* scanner.c (pedantic): Remove extern declaration.
	(skip_free_comments, skip_fixed_comments, include_line): Update
	names of gfc_option_t members.
	* trans-decl.c (gfc_generate_function_code): Update names of
	gfc_option_t members.

gcc/java:
	* java-tree.h (flag_filelist_file, flag_assert, flag_jni,
	flag_force_classes_archive_check, flag_redundant, flag_newer,
	flag_use_divide_subroutine, flag_use_atomic_builtins,
	flag_use_boehm_gc, flag_hash_synchronization,
	flag_check_references, flag_optimize_sci, flag_indirect_classes,
	flag_indirect_dispatch, flag_store_check,
	flag_reduced_reflection): Remove.
	* jcf-dump.c (flag_newer): Remove.
	* jcf.h (quiet_flag): Remove.
	* parse.h (quiet_flag): Remove.

libcpp:
	* include/cpplib.h (cpp_options): Rename warn_deprecated,
	warn_traditional, warn_long_long and pedantic.
	* directives.c (directive_diagnostics, _cpp_handle_directive):
	Update names of cpp_options members.
	* expr.c (cpp_classify_number, eval_token): Update names of
	cpp_options members.
	* init.c (cpp_create_reader, post_options): Update names of
	cpp_options members.
	* internal.h (CPP_PEDANTIC, CPP_WTRADITIONAL): Update names of
	cpp_options members.
	* macro.c (parse_params): Update names of cpp_options members.

From-SVN: r164723
2010-09-29 15:49:14 +01:00
DJ Delorie cd7fe53b72 diagnostic.h (diagnostic_classification_change_t): New.
* diagnostic.h (diagnostic_classification_change_t): New.
(diagnostic_context): Add history and push/pop list.
(diagnostic_push_diagnostics): Declare.
(diagnostic_pop_diagnostics): Declare.
* diagnostic.c (diagnostic_classify_diagnostic): Store changes
from pragmas in a history chain instead of the global table.
(diagnostic_push_diagnostics): New.
(diagnostic_pop_diagnostics): New.
(diagnostic_report_diagnostic): Scan history chain to find state
of diagnostics as of the diagnostic location.
* opts.c (set_option): Pass UNKNOWN_LOCATION to
diagnostic_classify_diagnostic.
(enable_warning_as_error): Likewise.
* diagnostic-core.h (DK_POP): Add after "real" diagnostics, for
use in the history chain.
* c-family/c-pragma.c (handle_pragma_diagnostic): Add push/pop,
allow these pragmas anywhere.
* doc/extend.texi: Document pragma GCC diagnostic changes.

* gcc.dg/pragma-diag-1.c: New.

From-SVN: r161115
2010-06-21 16:58:57 -04:00
Joseph Myers 1da2ed5f19 diagnostic-core.h: New.
* diagnostic-core.h: New.  Contents moved from diagnostic.h and
	toplev.h.
	* diagnostic.c: Don't include toplev.h.
	(progname): Define.  Moved from toplev.c.
	(seen_error): New function.
	* diagnostic.h: Include diagnostic-core.h.
	(diagnostic_t, emit_diagnostic): Don't declare here.
	* toplev.c (progname): Move to toplev.c.
	(emit_debug_global_declarations, compile_file, finalize,
	do_compile, toplev_main): Use seen_error.
	* toplev.h: Include diagnostic-core.h.
	(trim_filename, GCC_DIAG_STYLE, ATTRIBUTE_GCC_DIAG,
	internal_error, warning, warning_at, error, error_n, error_at,
	fatal_error, pedwarn, permerror, sorry, inform, inform_n,
	verbatim, fnotice, progname): Move to diagnostic-core.h.
	* builtins.c: Include diagnostic-core.h instead of diagnostic.h.
	(expand_builtin_expect): Use seen_error.
	* c-decl.c: Include diagnostic-core.h instead of diagnostic.h.
	(c_make_fname_decl, c_write_global_declarations): Use seen_error.
	* c-format.c: Include diagnostic-core.h instead of diagnostic.h.
	* c-gimplify.c: Include diagnostic-core.h instead of diagnostic.h.
	* c-lang.c: Include diagnostic-core.h instead of diagnostic.h.
	* c-lex.c (c_lex_with_flags, interpret_float): Don't increment
	errorcount for errors.
	* c-opts.c (c_common_finish): Use seen_error.
	* cgraph.c: Include diagnostic-core.h instead of diagnostic.h.
	* cgraphunit.c (verify_cgraph_node, verify_cgraph,
	cgraph_output_pending_asms, cgraph_optimize): Use seen_error.
	* coverage.c: Include diagnostic-core.h instead of diagnostic.h.
	(get_coverage_counts): Use seen_error.
	* dwarf2out.c (dwarf2out_finish): Use seen_error.
	* gimplify.c (gimplify_var_or_parm_decl, gimple_push_cleanup,
	gimplify_body): Use seen_error.
	* ipa-inline.c (cgraph_early_inlining): Use seen_error.
	* ipa-pure-const.c (gate_pure_const): Use seen_error.
	* ipa-reference.c (gate_reference): Use seen_error.
	* jump.c: Include diagnostic-core.h instead of diagnostic.h.
	* lambda-code.c: Include diagnostic-core.h instead of
	diagnostic.h.
	* lto-cgraph.c: Include diagnostic-core.h instead of diagnostic.h.
	* lto-compress.c: Include diagnostic-core.h instead of
	diagnostic.h.
	* lto-section-in.c: Include diagnostic-core.h instead of
	diagnostic.h.
	* lto-streamer-out.c: Include diagnostic-core.h instead of
	diagnostic.h.
	* lto-streamer.c: Include diagnostic-core.h instead of
	diagnostic.h.
	(gate_lto_out): Use seen_error.
	* matrix-reorg.c: Include diagnostic-core.h instead of
	diagnostic.h.
	* omega.c: Include diagnostic-core.h instead of diagnostic.h.
	* omp-low.c: Include diagnostic-core.h instead of diagnostic.h.
	(gate_expand_omp, lower_omp_1): Use seen_error.
	* passes.c: Include diagnostic-core.h instead of diagnostic.h.
	(rest_of_decl_compilation, rest_of_type_compilation,
	gate_rest_of_compilation, ipa_write_summaries): Use seen_error.
	* tree-cfg.c (label_to_block_fn): Use seen_error.
	* tree-inline.c (optimize_inline_calls): Use seen_error.
	* tree-mudflap.c (mudflap_finish_file): Use
	seen_error.
	* tree-optimize.c (gate_all_optimizations,
	gate_all_early_local_passes, gate_all_early_optimizations): Use
	seen_error.
	* tree-ssa-structalias.c (gate_ipa_pta): Use seen_error.
	* varpool.c: Include diagnostic-core.h instead of diagnostic.h.
	(varpool_remove_unreferenced_decls,
	varpool_assemble_pending_decls): Use seen_error.
	* Makefile.in (DIAGNOSTIC_CORE_H): Define.
	(TOPLEV_H, DIAGNOSTIC_H): Update.
	(c-decl.o, c-lang.o, c-format.o, lto-compress.o, lto-cgraph.o,
	lto-streamer-out.o, lto-section-in.o, lto-streamer.o,
	c-gimplify.o, omp-low.o, omega.o, diagnostic.o, passes.o,
	builtins.o, jump.o, cgraph.o, varpool.o, matrix-reorg.o,
	coverage.o, lambda-code.o): Update dependencies.

cp:
	* call.c: Include diagnostic-core.h instead of diagnostic.h.
	* cp-lang.c: Don't include diagnostic.h
	* name-lookup.c: Include diagnostic-core.h instead of
	diagnostic.h.
	(cp_emit_debug_info_for_using): Use seen_error.
	* optimize.c: Include diagnostic-core.h instead of diagnostic.h.
	* parser.c: Include diagnostic-core.h instead of diagnostic.h.
	* pt.c (iterative_hash_template_arg): Use seen_error.
	* repo.c: Include diagnostic-core.h instead of diagnostic.h.
	* typeck2.c: Include diagnostic-core.h instead of diagnostic.h.
	* Make-lang.in (cp/cp-lang.o, cp/typeck2.o, cp/call.o, cp/repo.o,
	cp/optimize.o, cp/parser.o, cp/name-lookup.o): Update
	dependencies.

lto:
	* lto.c: Include diagnostic-core.h instead of diagnostic.h.
	(read_cgraph_and_symbols, lto_main): Use seen_error.
	* Make-lang.in (lto/lto.o): Update dependencies.

objc:
	* objc-act.c: Include diagnostic-core.h instead of diagnostic.h.
	* Make-lang.in (objc/objc-act.o): Update dependencies.

From-SVN: r159947
2010-05-27 21:16:07 +01:00
Joseph Myers 5f0f4a3bc5 diagnostic.c: Don't include opts.h.
* diagnostic.c: Don't include opts.h.
	(permissive_error_option): Define.
	(diagnostic_initialize): Take n_opts parameter.  Allocate memory
	for classify_diagnostic.  Don't use memset for
	classify_diagnostic.  Initialize new and recently added fields.
	(diagnostic_classify_diagnostic): Use context->n_opts instead of
	N_OPTS.
	(diagnostic_report_diagnostic): Pass context parameter to
	diagnostic_report_warnings_p.  Use option_enabled and option_name
	hooks from context.
	(emit_diagnostic): Use permissive_error_option.
	(permerror): Likewise.
	* diagnostic.h: Don't include options.h.
	(struct diagnostic_context): Add n_opts, opt_permissive,
	inhibit_warnings, warn_system_headers, option_enabled and
	option_name fields.  Change classify_diagnostic to a pointer.
	* opts-diagnostic.h: New file.
	* opts.c: Include opts-diagnostic.h.
	(common_handle_option): Set global_dc fields for -Wfatal-errors,
	-Wsystem-headers, -fshow-column, -pedantic-errors and -w.
	(option_name): New function.
	* c-opts.c (c_common_init_options): Set global_dc->opt_permissive.
	(c_common_handle_option): Set global_dc->permissive for
	-fpermissive.
	* c-common.c (c_cpp_error): Save and restore
	global_dc->warn_system_headers, not variable warn_system_headers.
	* toplev.c: Include opts-diagnostic.h.
	(general_init): Update call to diagnostic_initialize.  Set
	global_dc->show_column, global_dc->option_enabled and
	global_dc->option_name.
	(process_options): Don't set global_dc fields here.
	* Makefile.in (DIAGNOSTIC_H): Remove options.h.
	(diagnostic.o, opts.o, toplev.o): Update dependencies.

fortran:
	* cpp.c (cb_cpp_error): Save and restore
	global_dc->warn_system_headers, not variable warn_system_headers.

From-SVN: r159869
2010-05-26 14:40:53 +01:00
Joseph Myers a13812e2c8 diagnostic.c: Don't include plugin.h.
* diagnostic.c: Don't include plugin.h.
	(diagnostic_report_diagnostic): Don't handle plugins specially
	here.  Pass context to internal_error callback.
	* diagnostic.h (struct diagnostic_context): Add context parameter
	to internal_error callback.
	* plugin.c (warn_if_plugins, plugins_internal_error_function):
	New.
	* plugin.h (struct diagnostic_context): Declare.
	(warn_if_plugins, plugins_internal_error_function): Declare.
	* toplev.c (general_init): Set global_dc->internal_error.
	* Makefile.in (diagnostic.o): Update dependencies.

ada:
	* gcc-interface/misc.c (internal_error_function): Add context
	parameter.  Use it to access show_column flag and instead of using
	global_dc.  Call warn_if_plugins.
	* gcc-interface/Make-lang.in (ada/misc.o): Update dependencies.

From-SVN: r159819
2010-05-25 14:01:45 +01:00
Joseph Myers 243fbddd9c diagnostic.c: Don't include flags.h.
* diagnostic.c: Don't include flags.h.
	(pedantic_warning_kind, permissive_error_kind): Take diagnostic
	context parameters.  Check flags in the context passed as a
	parameter.
	(diagnostic_build_prefix): Add context parameter.  Check
	show_column flag in context.
	(diagnostic_action_after_output): Check fatal_errors flag in
	context.
	(diagnostic_report_current_module): Check show_column flag in
	context.
	(default_diagnostic_starter): Update call to
	diagnostic_build_prefix.
	(diagnostic_report_diagnostic): Pass context to
	pedantic_warning_kind.
	(emit_diagnostic): Pass context to permissive_error_kind.
	(permerror): Pass context to permissive_error_kind.
	* diagnostic.h (struct diagnostic_context): Add show_column,
	pedantic_errors, permissive and fatal_errors fields.
	(diagnostic_build_prefix): Update prototype.
	* langhooks.c
	* toplev.c (process_options): Set flags in global_dc from
	flag_show_column, flag_pedantic_errors, flag_permissive,
	flag_fatal_errors.
	* tree-diagnostic.c (default_tree_diagnostic_starter): Update call
	to diagnostic_build_prefix.
	* Makefile.in (diagnostic.o): Update dependencies.

cp:
	* error.c (cp_diagnostic_starter): Update call to
	diagnostic_build_prefix.
	(cp_print_error_function,
	print_instantiation_partial_context_line): Check show_column flag
	in context.

From-SVN: r159793
2010-05-24 19:55:44 +01:00
Joseph Myers cf8358387d diagnostic.c: Don't include tm.h, tree.h, tm_p.h, langhooks.h or langhooks-def.h.
* diagnostic.c: Don't include tm.h, tree.h, tm_p.h, langhooks.h or
	langhooks-def.h.
	(diagnostic_initialize): Initialize x_data not last_function.
	(diagnostic_report_current_function): Move to tree-diagnostic.c.
	(default_diagnostic_starter): Call
	diagnostic_report_current_module not
	diagnostic_report_current_function.
	(diagnostic_report_diagnostic): Initialize x_data not
	abstract_origin.
	(verbatim): Likewise.
	* diagnostic.h (struct diagnostic_info): Change abstract_origin to
	x_data.
	(struct diagnostic_context): Change last_function to x_data.
	(diagnostic_auxiliary_data): Replace with
	diagnostic_context_auxiliary_data and
	diagnostic_info_auxiliary_data.
	(diagnostic_last_function_changed, diagnostic_set_last_function,
	diagnostic_report_current_function): Move to tree-diagnostic.h.
	(print_declaration, dump_generic_node, print_generic_stmt,
	print_generic_stmt_indented, print_generic_expr,
	print_generic_decl, debug_c_tree, dump_omp_clauses,
	print_call_name, debug_generic_expr, debug_generic_stmt,
	debug_tree_chain, default_tree_printer): Move to
	tree-pretty-print.h.
	(debug_gimple_stmt, debug_gimple_seq, print_gimple_seq,
	print_gimple_stmt, print_gimple_expr, dump_gimple_stmt): Move to
	gimple-pretty-print.h.
	* pretty-print.c: Don't include tree.h
	(pp_base_format): Don't handle %K here.
	(pp_base_tree_identifier): Move to tree-pretty-print.c.
	* pretty-print.h (text_info): Change abstract_origin to x_data.
	(pp_tree_identifier, pp_unsupported_tree,
	pp_base_tree_identifier): Move to tree-pretty-print.h.
	* gimple-pretty-print.h, tree-diagnostic.c, tree-diagnostic.h,
	tree-pretty-print.h: New files.
	* tree-pretty-print.c: Include tree-pretty-print.h.
	(percent_K_format): New.  Moved from pretty-print.c.
	(pp_base_tree_identifier): Move from pretty-print.c.
	* c-objc-common.c: Include tree-pretty-print.h.
	(c_tree_printer): Handle %K here.
	* langhooks.c: Include tree-diagnostic.h.
	(lhd_print_error_function): Use diagnostic_abstract_origin macro.
	* toplev.c: Include tree-diagnostic.h and tree-pretty-print.h.
	(default_tree_printer): Handle %K using percent_K_format.
	(general_init): Use default_tree_diagnostic_starter.
	* tree.c: Include tree-diagnostic.h and tree-pretty-print.h.
	(free_lang_data): Use default_tree_diagnostic_starter.
	* c-pretty-print.c: Include tree-pretty-print.h.
	* cfgexpand.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* cgraphunit.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* dwarf2out.c: Include tree-pretty-print.h.
	* except.c: Include tree-pretty-print.h.
	* gimple-pretty-print.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* gimplify.c: Include tree-pretty-print.h.
	* graphite-poly.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* ipa-cp.c: Include tree-pretty-print.h.
	* ipa-inline.c: Include gimple-pretty-print.h.
	* ipa-prop.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* ipa-pure-const.c: Include gimple-pretty-print.h.
	* ipa-struct-reorg.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* ipa-type-escape.c: Include tree-pretty-print.h.
	* print-rtl.c: Include tree-pretty-print.h.
	* print-tree.c: Include gimple-pretty-print.h.
	* sese.c: Include tree-pretty-print.h.
	* tree-affine.c: Include tree-pretty-print.h.
	* tree-browser.c: Include tree-pretty-print.h.
	* tree-call-cdce.c: Include gimple-pretty-print.h.
	* tree-cfg.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-chrec.c: Include tree-pretty-print.h.
	* tree-data-ref.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-dfa.c: Include tree-pretty-print.h.
	* tree-if-conv.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-inline.c: Include tree-pretty-print.h.
	* tree-into-ssa.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-nrv.c: Include tree-pretty-print.h.
	* tree-object-size.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-outof-ssa.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-parloops.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-predcom.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-scalar-evolution.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-sra.c: Include tree-pretty-print.h.
	* tree-ssa-address.c: Include tree-pretty-print.h.
	* tree-ssa-alias.c: Include tree-pretty-print.h.
	* tree-ssa-ccp.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-ssa-coalesce.c: Include tree-pretty-print.h.
	* tree-ssa-copy.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-ssa-copyrename.c: Include tree-pretty-print.h.
	* tree-ssa-dce.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-ssa-dom.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-ssa-dse.c: Include gimple-pretty-print.h.
	* tree-ssa-forwprop.c: Include tree-pretty-print.h.
	* tree-ssa-ifcombine.c: Include tree-pretty-print.h.
	* tree-ssa-live.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-ssa-loop-im.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-ssa-loop-ivcanon.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-ssa-loop-ivopts.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-ssa-loop-niter.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-ssa-loop-prefetch.c: Include tree-pretty-print.h.
	* tree-ssa-math-opts.c: Include gimple-pretty-print.h.
	* tree-ssa-operands.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-ssa-phiprop.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-ssa-pre.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-ssa-propagate.c: Include gimple-pretty-print.h.
	* tree-ssa-reassoc.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-ssa-sccvn.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-ssa-sink.c: Include gimple-pretty-print.h.
	* tree-ssa-ter.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-ssa-uninit.c: Include gimple-pretty-print.h.
	* tree-ssa.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-stdarg.c: Include gimple-pretty-print.h.
	* tree-switch-conversion.c: Include gimple-pretty-print.h.
	* tree-tailcall.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-vect-data-refs.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-vect-loop-manip.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-vect-loop.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-vect-patterns.c: Include gimple-pretty-print.h.
	* tree-vect-slp.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-vect-stmts.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* tree-vectorizer.c: Include tree-pretty-print.h.
	* tree-vrp.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* value-prof.c: Include tree-pretty-print.h and
	gimple-pretty-print.h.
	* var-tracking.c: Include tree-pretty-print.h.
	* Makefile.in (OBJS-common): Add tree-diagnostic.o.
	(tree-diagnostic.o): New dependencies.
	(c-objc-common.o, c-pretty-print.o, langhooks.o, tree.o,
	tree-inline.o, print-tree.o, stor-layout.o, tree-ssa-uninit.o,
	tree-ssa.o, tree-into-ssa.o, tree-ssa-ter.o, tree-ssa-coalesce.o,
	tree-outof-ssa.o, tree-ssa-forwprop.o, tree-ssa-phiprop.o,
	tree-ssa-ifcombine.o, tree-nrv.o, tree-ssa-copy.o,
	tree-ssa-propagate.o, tree-ssa-dom.o, tree-ssa-uncprop.o,
	tree-ssa-live.o, tree-ssa-copyrename.o, tree-ssa-pre.o,
	tree-ssa-sccvn.o, tree-vrp.o, tree-cfg.o, tree-tailcall.o,
	tree-ssa-sink.o, tree-if-conv.o, tree-dfa.o, tree-ssa-operands.o,
	tree-ssa-address.o, tree-ssa-loop-niter.o,
	tree-ssa-loop-ivcanon.o, tree-ssa-loop-prefetch.o, tree-predcom.o,
	tree-ssa-loop-ivopts.o, tree-affine.o, tree-ssa-loop-im.o,
	tree-ssa-math-opts.o, tree-ssa-alias.o, tree-ssa-reassoc.o,
	gimplify.o, tree-browser.o, tree-chrec.o, tree-scalar-evolution.o,
	tree-data-ref.o, sese.o, graphite-poly.o, tree-vect-loop.o,
	tree-vect-loop-manip.o, tree-vect-patterns.o, tree-vect-slp.o,
	tree-vect-stmts.o, tree-vect-data-refs.o, tree-vectorizer.o,
	tree-parloops.o, tree-stdarg.o, tree-object-size.o,
	gimple-pretty-print.o, tree-pretty-print.o, diagnostic.o,
	toplev.o, print-rtl.o, except.o, dwarf2out.o, cgraphunit.o,
	ipa-prop.o, ipa-cp.o, ipa-inline.o, ipa-pure-const.o,
	ipa-type-escape.o, ipa-struct-reorg.o, tree-ssa-dce.o,
	tree-call-cdce.o, tree-ssa-ccp.o, tree-sra.o,
	tree-switch-conversion.o, var-tracking.o, value-prof.o,
	cfgexpand.o, pretty-print.o): Update dependencies.

cp:
	* error.c: Include tree-diagnostic.h and tree-pretty-print.h.
	(cp_print_error_function): Use diagnostic_abstract_origin macro.
	(cp_printer): Handle %K here using percent_K_format.
	* cxx-pretty-print.c: Include tree-pretty-print.h.
	* Make-lang.in (cp/error.o, cp/cxx-pretty-print.o): Update
	dependencies.

From-SVN: r159685
2010-05-21 23:34:26 +01:00
Joseph Myers 676dd4d4df diagnostic.c (FLOAT, FFS): Don't undefine.
* diagnostic.c (FLOAT, FFS): Don't undefine.
	* passes.c, pretty-print.c, rtl-error.c, toplev.c: Likewise.
	* cse.c, regmove.c: Remove comments about stdio.h and rtl.h
	include ordering.

From-SVN: r159602
2010-05-19 22:32:19 +01:00
Manuel López-Ibáñez 289fcbbd6e re PR other/42966 (add some indication that a warning has been converted to an error)
2010-04-14  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR 42966
	* diagnostics.c (diagnostic_report_diagnostic): Mark specially
	warnings converted to errors.
	
testsuite/	
	* gcc.dg/cpp/warn-undef-2.c: Update.
	* gcc.dg/cpp/warn-traditional-2.c: Update.
	* gcc.dg/cpp/warn-comments-2.c: Update.
	* gcc.dg/cpp/warn-variadic-2.c: Update.
	* gcc.dg/cpp/warn-long-long-2.c: Update.
	* gcc.dg/cpp/warn-deprecated-2.c: Update.
	* gcc.dg/cpp/warn-multichar-2.c: Update.
	* gcc.dg/cpp/warn-normalized-3.c: Update.
	* gcc.dg/cpp/warn-cxx-compat-2.c: Update.
	* gcc.dg/cpp/warn-trigraphs-3.c: Update.
	* gcc.dg/cpp/warn-unused-macros-2.c: Update.
	* gcc.dg/cpp/warn-trigraphs-4.c: Update.
	* gcc.dg/cpp/warn-redefined-2.c: Update.
	* gfortran.dg/warning-directive-2.F90: Update.
	* c-c++-common/cpp/warning-directive-2.c: Update.

From-SVN: r158349
2010-04-14 16:08:23 +00:00
Manuel López-Ibáñez d0b8780d9f re PR other/42965 (no "warnings being treated as errors" for individual -Werror=x options)
2010-04-09  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR 42965
	* diagnostic.c (diagnostic_initialize): Initialize
	some_warnings_are_errors.
	(diagnostic_finish): New.
	(diagnostic_action_after_output): Call it before exiting.
	(diagnostic_report_diagnostic): Do not print message here. Set
	some_warnings_are_errors.
	* diagnostic.h (diagnostic_context): Delete
	issue_warnings_are_errors_message. Add some_warnings_are_errors.
	(diagnostic_finish): Declare.
	* toplev.c (toplev_main): Call it before exit.
testsuite/
	* gcc.dg/Werror-6.c: Adjust.
	* gcc.dg/Werror-implicit-function-declaration.c: Likewise.
	* gcc.dg/Werror-4.c: Likewise.
	* gcc.dg/Wdeclaration-after-statement-3.c: Likewise.
	* gcc.dg/Wswitch-enum-error.c: Likewise.
	* gcc.dg/Wpointer-arith.c: Likewise.
	* gcc.dg/Wfatal.c: Likewise.
	* gcc.dg/Wswitch-error.c: Likewise.
	* g++.dg/warn/unused-result1-Werror.c: Likewise.
	* gcc.dg/Werror-9.c: Delete. Duplicate of Werror-4.c.
	* gcc.dg/cpp/warn-undef-2.c: Likewise.
	* gcc.dg/cpp/warn-traditional-2.c: Likewise.
	* gcc.dg/cpp/warn-comments-2.c: Likewise.
	* gcc.dg/cpp/warn-variadic-2.c: Likewise.
	* gcc.dg/cpp/warning-directive-2.c: Likewise.
	* gcc.dg/cpp/warn-long-long-2.c: Likewise.
	* gcc.dg/cpp/warn-deprecated-2.c: Likewise.
	* gcc.dg/cpp/warn-multichar-2.c: Likewise.
	* gcc.dg/cpp/warn-normalized-3.c: Likewise.
	* gcc.dg/cpp/warn-cxx-compat-2.c: Likewise.
	* gcc.dg/cpp/warn-trigraphs-3.c: Likewise.
	* gcc.dg/cpp/warn-unused-macros-2.c: Likewise.
	* gcc.dg/cpp/warn-trigraphs-4.c: Likewise.
	* gcc.dg/cpp/warn-redefined-2.c: Likewise.
	* g++.dg/cpp/warning-directive-2.C: Likewise.
	* gfortran.dg/warning-directive-2.F90: Likewise.

From-SVN: r158168
2010-04-09 15:45:52 +00:00
Steven Bosscher c75c517d53 Make-lang.in, [...]: Update copyright years.
* ada/gcc-interface/Make-lang.in, alias.c, attribs.c, auto-inc-dec.c, 
	basic-block.h, bb-reorder.c, calls.c, c-common.c, cgraph.h,
	collect2.h, config/alpha/alpha.c, config/alpha/alpha.md,
	config/alpha/predicates.md, config/arm/arm.md,
	config/arm/lib1funcs.asm, config/arm/neon-schedgen.ml,
	config/avr/avr.c, config/avr/avr.md, config/bfin/bfin.c,
	config/darwin9.h, config/darwin.c, config/darwin.h,
	config/h8300/h8300.c, config/i386/cpuid.h, config/i386/cygming.h,
	config/i386/cygwin.h, config/i386/mingw32.h, config/i386/msformat-c.c,
	config/i386/sol2-10.h, config/i386/xopintrin.h, config/ia64/ia64.c,
	config/ia64/ia64.md, config/ia64/sync.md, config/mep/mep.c,
	config/mips/mips.md, config/mn10300/mn10300.c,
	config/mn10300/mn10300.h, config/pa/pa.c, config/pa/pa.md,
	config/rs6000/aix.h, config/rs6000/dfp.md,
	config/rs6000/rs6000-builtin.def, config/rs6000/rs6000-c.c,
	config/rs6000/vector.md, config/rtems.h, config/rx/rx.md,
	config/s390/s390.md, config/sol2-c.c, config/sparc/sol2-bi.h,
	config/sparc/sol2-gas.h, config/sparc/sparc.h, config/sparc/sparc.md,
	config/sparc/sparc-protos.h, config/spu/spu.c, config/spu/spu-c.c,
	config/t-darwin, convert.c, c.opt, c-opts.c, cp/Make-lang.in,
	c-pretty-print.c, c-typeck.c, df-core.c, df-scan.c, diagnostic.c,
	diagnostic.h, doc/cppopts.texi, doc/cpp.texi, doc/extend.texi,
	doc/gimple.texi, doc/languages.texi, doc/plugins.texi, doc/rtl.texi,
	doc/standards.texi, doc/tree-ssa.texi, doc/trouble.texi, dominance.c,
	fold-const.c, fortran/Make-lang.in, fwprop.c, gcc-plugin.h,
	gensupport.c, gimple.h, gimple-iterator.c, graphite.c,
	graphite-clast-to-gimple.c, graphite-clast-to-gimple.h,
	graphite-dependences.c, graphite-poly.c, graphite-poly.h,
	graphite-ppl.c, graphite-ppl.h, graphite-scop-detection.c,
	graphite-sese-to-poly.c, graphite-sese-to-poly.h, ifcvt.c, intl.c,
	intl.h, ipa.c, ipa-cp.c, ipa-inline.c, ipa-prop.c, ipa-prop.h,
	ipa-pure-const.c, ipa-reference.c, ipa-type-escape.c, ira-color.c,
	ira-conflicts.c, ira-lives.c, java/Make-lang.in, lambda-code.c,
	loop-invariant.c, lto/Make-lang.in, lto-streamer.h, lto-streamer-in.c,
	objc/Make-lang.in, objcp/Make-lang.in, omp-low.c, optc-gen.awk,
	opt-functions.awk, opth-gen.awk, params.def, passes.c,
	postreload-gcse.c, print-tree.c, recog.c, regrename.c, reload.h,
	rtl.def, sched-int.h, sched-rgn.c, sel-sched-dump.c, sese.c, sese.h,
	store-motion.c, stor-layout.c, tree-cfgcleanup.c, tree-chrec.c,
	tree-complex.c, tree-data-ref.c, tree.def, tree-eh.c, tree-flow.h,
	tree-flow-inline.h, tree.h, tree-loop-distribution.c, tree-outof-ssa.c,
	tree-parloops.c, tree-pass.h, tree-predcom.c, tree-profile.c,
	tree-scalar-evolution.c, tree-ssa-address.c, tree-ssa-alias.c,
	tree-ssa-coalesce.c, tree-ssa-copy.c, tree-ssa-dce.c, tree-ssa-dom.c,
	tree-ssa-dse.c, tree-ssa-loop-im.c, tree-ssa-loop-ivcanon.c,
	tree-ssa-loop-manip.c, tree-ssa-math-opts.c, tree-ssa-operands.c,
	tree-ssa-pre.c, tree-ssa-sccvn.c, tree-ssa-structalias.c,
	tree-ssa-uncprop.c, tree-tailcall.c, tree-vect-data-refs.c,
	tree-vect-loop.c, tree-vectorizer.h, tree-vect-slp.c, tree-vrp.c,
	unwind-dw2-fde-darwin.c, varpool.c: Update copyright years.

From-SVN: r157950
2010-04-02 19:54:46 +00:00
Shujing Zhao 894e2652e1 toplev.h (inform_n, error_n): Declare.
gcc/
2010-03-01  Marco Poletti  <poletti.marco@gmail.com> 

        * toplev.h (inform_n, error_n): Declare.
        * diagnostic.c (inform_n, error_n): New function.

gcc/cp/
2010-03-01  Marco Poletti  <poletti.marco@gmail.com>

        * pt.c (redeclare_class_template): Use error_n and inform_n.

gcc/po
2010-03-01  Shujing Zhao  <pearly.zhao@oracle.com>

        * exgettext: Handle the functions that end with _n.

From-SVN: r157134
2010-03-01 09:56:41 +00:00
Manuel López-Ibáñez 0e94b75085 diagnostic.c (diagnostic_initialize): Update.
2010-02-26  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	* diagnostic.c (diagnostic_initialize): Update.
	(diagnostic_report_diagnostic): Test inhibit_notes_p for
	informative notes.
	* diagnostic.h (diagnostic_context): New bool inhibit_notes_p.
	(diagnostic_inhibit_notes): New.
	* toplev.c (process_options): inhibit notes with -fcompare-debug.

From-SVN: r157100
2010-02-26 22:06:56 +00:00