summaryrefslogtreecommitdiff
path: root/gcc/diagnostic-color.c
AgeCommit message (Collapse)Author
2020-02-15PR 87488: Add --with-diagnostics-urls configuration optionBernd Edlinger
2020-02-15 David Malcolm <dmalcolm@redhat.com> Bernd Edlinger <bernd.edlinger@hotmail.de> PR 87488 PR other/93168 * config.in (DIAGNOSTICS_URLS_DEFAULT): New define. * configure.ac (--with-diagnostics-urls): New configuration option, based on --with-diagnostics-color. (DIAGNOSTICS_URLS_DEFAULT): New define. * config.h: Regenerate. * configure: Regenerate. * diagnostic.c (diagnostic_urls_init): Handle -1 for DIAGNOSTICS_URLS_DEFAULT from configure-time --with-diagnostics-urls=auto-if-env by querying for a GCC_URLS and TERM_URLS environment variable. * diagnostic-url.h (diagnostic_url_format): New enum type. (diagnostic_urls_enabled_p): rename to... (determine_url_format): ... this, and change return type. * diagnostic-color.c (parse_env_vars_for_urls): New helper function. (auto_enable_urls): Disable URLs on xfce4-terminal, gnome-terminal, the linux console, and mingw. (diagnostic_urls_enabled_p): rename to... (determine_url_format): ... this, and adjust. * pretty-print.h (pretty_printer::show_urls): rename to... (pretty_printer::url_format): ... this, and change to enum. * pretty-print.c (pretty_printer::pretty_printer, pp_begin_url, pp_end_url, test_urls): Adjust. * doc/install.texi (--with-diagnostics-urls): Document the new configuration option. (--with-diagnostics-color): Document the existing interaction with GCC_COLORS better. * doc/invoke.texi (-fdiagnostics-urls): Add GCC_URLS and TERM_URLS vindex reference. Update description of defaults based on the above. (-fdiagnostics-color): Update description of how -fdiagnostics-color interacts with GCC_COLORS.
2020-01-10Add diagnostic pathsDavid Malcolm
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-01Update copyright years.Jakub Jelinek
From-SVN: r279813
2019-10-10pretty-print: support URL escape sequences (PR 87488)David Malcolm
https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda describes an emerging standard for embedding URLs in escape sequences for marking up text output. This is supported e.g. by recent releases of GNOME Terminal. This patch adds support to our pretty-printing framework for emitting URLs. A followup patch uses this to add URLs to the pertinent documentation for the output of -fdiagnostics-show-option. gcc/ChangeLog: PR 87488 * common.opt (fdiagnostics-urls=): New option. (diagnostic-url.h): Add SourceInclude. (diagnostic_url_rule): New enum. * diagnostic-color.c: Include "diagnostic-url.h". (diagnostic_urls_enabled_p): New function. * diagnostic-url.h: New file. * diagnostic.c: Include "diagnostic-url.h". (diagnostic_urls_init): New function. * diagnostic.h (diagnostic_urls_init): New decl. * doc/invoke.texi (Diagnostic Message Formatting Options): Add -fdiagnostics-urls to the list. (-fdiagnostics-urls): New option. * gcc.c (driver_handle_option): Handle OPT_fdiagnostics_urls_. (driver::global_initializations): Call diagnostic_urls_init. * opts-global.c (init_options_once): Likewise. * opts.c (common_handle_option): Handle OPT_fdiagnostics_urls_. * pretty-print.c (pretty_printer::pretty_printer): Initialize show_urls. (pp_begin_url): New function. (pp_end_url): New function. (selftest::test_urls): New selftest. (selftest::pretty_print_c_tests): Call it. * pretty-print.h (pretty_printer::show_urls): New field. (pp_begin_url): New decl. (pp_end_url): New decl. gcc/testsuite/ChangeLog: PR 87488 * lib/prune.exp (TEST_ALWAYS_FLAGS): Add -fdiagnostics-urls=never. From-SVN: r276841
2019-01-01Update copyright years.Jakub Jelinek
From-SVN: r267494
2018-01-03Update copyright years.Jakub Jelinek
From-SVN: r256169
2017-10-31GCOV: introduce usage of terminal colors.Martin Liska
2017-10-31 Martin Liska <mliska@suse.cz> * color-macros.h: New file. * diagnostic-color.c: Factor out color related to macros to color-macros.h. * doc/gcov.texi: Document -k option. * gcov.c (INCLUDE_STRING): Include string.h. (print_usage): Add -k option. (process_args): Parse it. (pad_count_string): New function. (output_line_beginning): Likewise. (DEFAULT_LINE_START): New macro. (output_lines): Support color output. From-SVN: r254258
2017-10-11pretty-print.c [_WIN32] (colorize_init): Remove.Liu Hao
2017-10-11 Liu Hao <lh_mouse@126.com> * pretty-print.c [_WIN32] (colorize_init): Remove. Use the generic version below instead. (should_colorize): Recognize Windows consoles as terminals for MinGW targets. * pretty-print.c [__MINGW32__] (write_all): New function. [__MINGW32__] (find_esc_head): Likewise. [__MINGW32__] (find_esc_terminator): Likewise. [__MINGW32__] (eat_esc_sequence): Likewise. [__MINGW32__] (mingw_ansi_fputs): New function that handles ANSI escape codes. (pp_write_text_to_stream): Use mingw_ansi_fputs instead of fputs for MinGW targets. From-SVN: r253645
2017-05-30C++ template type diff printingDavid Malcolm
gcc/ChangeLog: * diagnostic-color.c (color_dict): Add "type-diff". (parse_gcc_colors): Update comment. * doc/invoke.texi (Diagnostic Message Formatting Options): Add -fdiagnostics-show-template-tree and -fno-elide-type. (GCC_COLORS): Add type-diff to example. (type-diff=): New. (-fdiagnostics-show-template-tree): New. (-fno-elide-type): New. * pretty-print.c (pp_format): Pass quote and formatters[argno] to the pp_format_decoder callback. Call any m_format_postprocessor's "handle" method. (pretty_printer::pretty_printer): Initialize m_format_postprocessor. (pretty_printer::~pretty_printer): Delete any m_format_postprocessor. * pretty-print.h (printer_fn): Add bool and const char ** parameters. (class format_postprocessor): New class. (struct pretty_printer::format_decoder): Document the new parameters. (struct pretty_printer::m_format_postprocessor): New field. * tree-diagnostic.c (default_tree_printer): Update for new bool and const char ** params. * tree-diagnostic.h (default_tree_printer): Likewise. gcc/c/ChangeLog: * c-objc-common.c (c_tree_printer): Gain bool and const char ** parameters. gcc/c-family/ChangeLog: * c-format.c (gcc_cxxdiag_char_table): Add 'H' and 'I' to format_chars. * c.opt (fdiagnostics-show-template-tree): New option. (felide-type): New option. gcc/cp/ChangeLog: * call.c (perform_implicit_conversion_flags): Convert "from %qT to %qT" to "from %qH to %qI" in diagnostic. (print_conversion_rejection): Replace pairs of %qT with %qH and %qI in various places. (build_user_type_conversion_1): Likewise. (build_integral_nontype_arg_conv): Likewise. (build_conditional_expr_1): Likewise. (convert_like_real): Likewise. (convert_arg_to_ellipsis): Likewise. (joust): Likewise. (initialize_reference): Likewise. * cvt.c (cp_convert_to_pointer): Likewise. (cp_convert_to_pointer): Likewise. (convert_to_reference): Likewise. (ocp_convert): Likewise. * error.c (cp_printer): Gain bool and const char ** parameters. (struct deferred_printed_type): New struct. (class cxx_format_postprocessor): New class. (cxx_initialize_diagnostics): Wire up a cxx_format_postprocessor to pp->m_format_postprocessor. (comparable_template_types_p): New function. (newline_and_indent): New function. (arg_to_string): New function. (print_nonequal_arg): New function. (print_template_differences): New function. (type_to_string_with_compare): New function. (print_template_tree_comparison): New function. (append_formatted_chunk): New function. (add_quotes): New function. (cxx_format_postprocessor::handle): New function. (defer_phase_2_of_type_diff): New function. (cp_printer): Add "quoted" and "buffer_ptr" params. Implement %H and %I. * typeck.c (cp_build_binary_op): Replace pairs of %qT with %qH and %qI in various places. (convert_member_func_to_ptr): Likewise. (build_reinterpret_cast_1): Likewise. (convert_for_assignment): Likewise. * typeck2.c (check_narrowing): Likewise. gcc/fortran/ChangeLog: * error.c (gfc_format_decoder): Update for new bool and const char ** params. gcc/testsuite/ChangeLog: * g++.dg/plugin/plugin.exp (plugin_test_list): Add... * g++.dg/plugin/show-template-tree-color-no-elide-type.C: New test case. * g++.dg/plugin/show-template-tree-color.C: New test case. * g++.dg/plugin/show_template_tree_color_plugin.c: New plugin. * g++.dg/template/show-template-tree-2.C: New test case. * g++.dg/template/show-template-tree-3.C: New test case. * g++.dg/template/show-template-tree-4.C: New test case. * g++.dg/template/show-template-tree-no-elide-type.C: New test case. * g++.dg/template/show-template-tree.C: New test case. From-SVN: r248698
2017-01-01Update copyright years.Jakub Jelinek
From-SVN: r243994
2016-09-02Introduce class edit_contextDavid Malcolm
gcc/ChangeLog: * Makefile.in (OBJS-libcommon): Add edit-context.o. * diagnostic-color.c (color_dict): Add "diff-filename", "diff-hunk", "diff-delete", and "diff-insert". (parse_gcc_colors): Update default value of GCC_COLORS in comment to reflect above changes. * doc/invoke.texi (-fdiagnostics-color): Update description of default GCC_COLORS, and of the supported capabilities. * edit-context.c: New file. * edit-context.h: New file. * input.c (struct fcache): Add field "missing_trailing_newline". (diagnostics_file_cache_forcibly_evict_file): Initialize it to true. (add_file_to_cache_tab): Likewise. (fcache::fcache): Likewise. (get_next_line): Update c->missing_trailing_newline. (location_missing_trailing_newline): New function. * input.h (location_missing_trailing_newline): New decl. * selftest-run-tests.c (selftest::run_tests): Call edit_context_c_tests. * selftest.h (edit_context_c_tests): New decl. libcpp/ChangeLog: * include/line-map.h (rich_location::seen_impossible_fixit_p): New accessor. From-SVN: r239963
2016-08-26Tweak to colors of fix-it hintsDavid Malcolm
Previous, fix-it hints were printed using the color of the severity of the diagnostic (magenta for warnings, red for errors, cyan for notes). This patch updates fix-it hints so that replacement text is printed in green, to better distinguish the suggested improvement from the current code. For example: spellcheck-fields.cc:52:13: error: 'struct s' has no member named 'colour'; did you mean 'color'? return ptr->colour; <<< RED ^~~~~~ <<< RED color <<< GREEN It makes sense for the underlinings that indicate deletions to be printed in red, so the patch changes that also. For example: diagnostic-test-show-locus-color.c:179:9: warning: example of a removal hint int a;; <<< MAGENTA ^ <<< MAGENTA - <<< RED gcc/ChangeLog: * diagnostic-color.c (color_dict): Add "fixit-insert" and "fixit-delete". (parse_gcc_colors): Update description of default GCC_COLORS. * diagnostic-show-locus.c (colorizer::set_fixit_hint): Delete. (colorizer::set_fixit_insert): New method. (colorizer::set_fixit_delete): New method. (colorizer::get_color_by_name): New method. (colorizer::STATE_FIXIT_INSERT): New constant. (colorizer::STATE_FIXIT_DELETE): New constant. (class colorizer): Drop "_cs" suffix from fields. Delete "_ce" fields in favor of new field "m_stop_color". Add fields "m_fixit_insert" and "m_fixit_delete". (colorizer::colorizer): Update for above changes. Replace colorize_start calls with calls to get_color_by_name. (colorizer::begin_state): Handle STATE_FIXIT_INSERT and STATE_FIXIT_DELETE. Update for field renamings. (colorizer::finish_state): Simplify by using m_stop_color, rather than multiple identical "*_ce" fields. (colorizer::get_color_by_name): New method. (layout::print_any_fixits): Print insertions and replacements using the "fixit-insert" color, and deletions using the "fixit-delete" color. * doc/invoke.texi (-fdiagnostics-color): Update description of default GCC_COLORS, and of the supported capabilities. gcc/testsuite/ChangeLog: * gcc.dg/plugin/diagnostic-test-show-locus-color.c (test_fixit_insert): Update expected output. (test_fixit_remove): Likewise. (test_fixit_replace): Likewise. From-SVN: r239787
2016-01-04Update copyright years.Jakub Jelinek
From-SVN: r232055
2015-11-06Reimplement diagnostic_show_locus, introducing rich_location classesDavid Malcolm
gcc/ChangeLog: * diagnostic-color.c (color_dict): Eliminate "caret"; add "range1" and "range2". (parse_gcc_colors): Update comment to describe default GCC_COLORS. * diagnostic-core.h (warning_at_rich_loc): New declaration. (error_at_rich_loc): New declaration. (permerror_at_rich_loc): New declaration. (inform_at_rich_loc): New declaration. * diagnostic-show-locus.c (adjust_line): Delete. (struct point_state): New struct. (class colorizer): New class. (class layout_point): New class. (class layout_range): New class. (struct line_bounds): New. (class layout): New class. (colorizer::colorizer): New ctor. (colorizer::~colorizer): New dtor. (layout::layout): New ctor. (layout::print_source_line): New method. (layout::print_annotation_line): New method. (layout::get_state_at_point): New method. (layout::get_x_bound_for_row): New method. (diagnostic_show_locus): Reimplement in terms of class layout. (diagnostic_print_caret_line): Delete. * diagnostic.c (diagnostic_initialize): Replace MAX_LOCATIONS_PER_MESSAGE with rich_location::MAX_RANGES. (diagnostic_set_info_translated): Convert param from location_t to rich_location *. Eliminate calls to set_location on the message in favor of storing the rich_location ptr there. (diagnostic_set_info): Convert param from location_t to rich_location *. (diagnostic_build_prefix): Break out array into... (diagnostic_kind_color): New variable. (diagnostic_get_color_for_kind): New function. (diagnostic_report_diagnostic): Colorize the option_text using the color for the severity. (diagnostic_append_note): Update for change in signature of diagnostic_set_info. (diagnostic_append_note_at_rich_loc): New function. (emit_diagnostic): Update for change in signature of diagnostic_set_info. (inform): Likewise. (inform_at_rich_loc): New function. (inform_n): Update for change in signature of diagnostic_set_info. (warning): Likewise. (warning_at): Likewise. (warning_at_rich_loc): New function. (warning_n): Update for change in signature of diagnostic_set_info. (pedwarn): Likewise. (permerror): Likewise. (permerror_at_rich_loc): New function. (error): Update for change in signature of diagnostic_set_info. (error_n): Likewise. (error_at): Likewise. (error_at_rich_loc): New function. (sorry): Update for change in signature of diagnostic_set_info. (fatal_error): Likewise. (internal_error): Likewise. (internal_error_no_backtrace): Likewise. (source_range::debug): New function. * diagnostic.h (struct diagnostic_info): Eliminate field "override_column". Add field "richloc". (struct diagnostic_context): Add field "colorize_source_p". (diagnostic_override_column): Delete. (diagnostic_set_info): Convert param from location_t to rich_location *. (diagnostic_set_info_translated): Likewise. (diagnostic_append_note_at_rich_loc): New function. (diagnostic_num_locations): New function. (diagnostic_expand_location): Get the location from the rich_location. (diagnostic_print_caret_line): Delete. (diagnostic_get_color_for_kind): New declaration. * genmatch.c (linemap_client_expand_location_to_spelling_point): New. (error_cb): Update for change in signature of "error" callback. (fatal_at): Likewise. (warning_at): Likewise. * input.c (linemap_client_expand_location_to_spelling_point): New. * pretty-print.c (text_info::set_range): New method. (text_info::get_location): New method. * pretty-print.h (MAX_LOCATIONS_PER_MESSAGE): Eliminate this macro. (struct text_info): Eliminate "locations" array in favor of "m_richloc", a rich_location *. (textinfo::set_location): Add a "caret_p" param, and reimplement in terms of a call to set_range. (textinfo::get_location): Eliminate inline implementation in favor of an out-of-line reimplementation. (textinfo::set_range): New method. * rtl-error.c (diagnostic_for_asm): Update for change in signature of diagnostic_set_info. * tree-diagnostic.c (default_tree_printer): Update for new "caret_p" param for textinfo::set_location. * tree-pretty-print.c (percent_K_format): Likewise. gcc/c-family/ChangeLog: * c-common.c (c_cpp_error): Convert parameter from location_t to rich_location *. Eliminate the "column_override" parameter and the call to diagnostic_override_column. Update the "done_lexing" clause to set range 0 on the rich_location, rather than overwriting a location_t. * c-common.h (c_cpp_error): Convert parameter from location_t to rich_location *. Eliminate the "column_override" parameter. gcc/c/ChangeLog: * c-decl.c (warn_defaults_to): Update for change in signature of diagnostic_set_info. * c-errors.c (pedwarn_c99): Likewise. (pedwarn_c90): Likewise. * c-objc-common.c (c_tree_printer): Update for new "caret_p" param for textinfo::set_location. gcc/cp/ChangeLog: * error.c (cp_printer): Update for new "caret_p" param for textinfo::set_location. (pedwarn_cxx98): Update for change in signature of diagnostic_set_info. gcc/fortran/ChangeLog: * cpp.c (cb_cpp_error): Convert parameter from location_t to rich_location *. Eliminate the "column_override" parameter. * error.c (gfc_warning): Update for change in signature of diagnostic_set_info. (gfc_format_decoder): Update handling of %C/%L for changes to struct text_info. (gfc_diagnostic_starter): Use richloc when determining whether to print one locus or two. When handling a location that will involve a call to diagnostic_show_locus, only attempt to print the locus for the primary location, and don't call into diagnostic_print_caret_line. (gfc_warning_now_at): Update for change in signature of diagnostic_set_info. (gfc_warning_now): Likewise. (gfc_error_now): Likewise. (gfc_fatal_error): Likewise. (gfc_error): Likewise. (gfc_internal_error): Likewise. gcc/testsuite/ChangeLog: * gcc.dg/plugin/diagnostic-test-show-locus-bw.c: New file. * gcc.dg/plugin/diagnostic-test-show-locus-color.c: New file. * gcc.dg/plugin/diagnostic_plugin_test_show_locus.c: New file. * gcc.dg/plugin/plugin.exp (plugin_test_list): Add the above. * lib/gcc-dg.exp: Load multiline.exp. libcpp/ChangeLog: * errors.c (cpp_diagnostic): Update for change in signature of "error" callback. (cpp_diagnostic_with_line): Likewise, calling override_column on the rich_location. * include/cpplib.h (struct cpp_callbacks): Within "error" callback, convert param from source_location to rich_location *, and drop column_override param. * include/line-map.h (struct source_range): New struct. (struct location_range): New struct. (class rich_location): New class. (linemap_client_expand_location_to_spelling_point): New declaration. * line-map.c (rich_location::rich_location): New ctors. (rich_location::lazily_expand_location): New method. (rich_location::override_column): New method. (rich_location::add_range): New methods. (rich_location::set_range): New method. From-SVN: r229884
2015-01-05Update copyright years.Jakub Jelinek
From-SVN: r219188
2014-01-02Update copyright years in gcc/Richard Sandiford
From-SVN: r206289
2014-01-02arc-common.c, [...]: Use the standard form for the copyright notice.Richard Sandiford
gcc/ * common/config/arc/arc-common.c, config/arc/arc-modes.def, config/arc/arc-protos.h, config/arc/arc.c, config/arc/arc.h, config/arc/arc.md, config/arc/arc.opt, config/arm/arm_neon_builtins.def, config/arm/crypto.def, config/i386/avx512cdintrin.h, config/i386/avx512erintrin.h, config/i386/avx512fintrin.h, config/i386/avx512pfintrin.h, config/i386/btver2.md, config/i386/shaintrin.h, config/i386/slm.md, config/linux-protos.h, config/linux.c, config/winnt-c.c, diagnostic-color.c, diagnostic-color.h, gimple-ssa-isolate-paths.c, vtable-verify.c, vtable-verify.h: Use the standard form for the copyright notice. gcc/c-family/ * array-notation-common.c, c-cilkplus.c: Use the standard form for the copyright notice. gcc/c/ * c-array-notation.c: Use the standard form for the copyright notice. gcc/cp/ * cp-array-notation.c, cp-cilkplus.c, vtable-class-hierarchy.c: Use the standard form for the copyright notice. gcc/testsuite/ * gcc.target/arc/arc.exp: Use the standard form for the copyright notice. libgcc/ * config/arc/asm.h, config/arc/crtg.S, config/arc/crtgend.S, config/arc/crti.S, config/arc/crtn.S, config/arc/divtab-arc700.c, config/arc/dp-hack.h, config/arc/fp-hack.h, config/arc/ieee-754/adddf3.S, config/arc/ieee-754/addsf3.S, config/arc/ieee-754/arc600-dsp/divdf3.S, config/arc/ieee-754/arc600-dsp/divsf3.S, config/arc/ieee-754/arc600-dsp/muldf3.S, config/arc/ieee-754/arc600-dsp/mulsf3.S, config/arc/ieee-754/arc600-mul64/divdf3.S, config/arc/ieee-754/arc600-mul64/divsf3.S, config/arc/ieee-754/arc600-mul64/muldf3.S, config/arc/ieee-754/arc600-mul64/mulsf3.S, config/arc/ieee-754/arc600/divsf3.S, config/arc/ieee-754/arc600/mulsf3.S, config/arc/ieee-754/divdf3.S, config/arc/ieee-754/divsf3-stdmul.S, config/arc/ieee-754/divsf3.S, config/arc/ieee-754/divtab-arc-df.c, config/arc/ieee-754/divtab-arc-sf.c, config/arc/ieee-754/eqdf2.S, config/arc/ieee-754/eqsf2.S, config/arc/ieee-754/extendsfdf2.S, config/arc/ieee-754/fixdfsi.S, config/arc/ieee-754/fixsfsi.S, config/arc/ieee-754/fixunsdfsi.S, config/arc/ieee-754/floatsidf.S, config/arc/ieee-754/floatsisf.S, config/arc/ieee-754/floatunsidf.S, config/arc/ieee-754/gedf2.S, config/arc/ieee-754/gesf2.S, config/arc/ieee-754/gtdf2.S, config/arc/ieee-754/gtsf2.S, config/arc/ieee-754/muldf3.S, config/arc/ieee-754/mulsf3.S, config/arc/ieee-754/orddf2.S, config/arc/ieee-754/ordsf2.S, config/arc/ieee-754/truncdfsf2.S, config/arc/ieee-754/uneqdf2.S, config/arc/ieee-754/uneqsf2.S, config/arc/initfini.c, config/arc/lib1funcs.S, config/arc/t-arc, config/arc/t-arc-newlib, config/cris/umulsidi3.S, config/msp430/cmpsi2.S, config/msp430/epilogue.S, config/msp430/lib2bitcountHI.c, config/msp430/lib2divHI.c, config/msp430/lib2divQI.c, config/msp430/lib2divSI.c, config/msp430/lib2mul.c, config/msp430/msp430-divmod.h, config/msp430/msp430-mul.h, config/msp430/slli.S, config/msp430/srai.S, config/msp430/srli.S, config/rl78/divmodhi.S, config/rl78/divmodqi.S, config/rl78/divmodsi.S, config/rl78/signbit.S, vtv_end.c, vtv_end_preinit.c, vtv_start.c, vtv_start_preinit.c: Use the standard form for the copyright notice. libgomp/ * hashtab.h: Use the standard form for the copyright notice. libstdc++-v3/ * testsuite/18_support/new_handler.cc, testsuite/18_support/terminate_handler.cc, testsuite/18_support/unexpected_handler.cc: Use the standard form for the copyright notice. From-SVN: r206288
2013-04-26Makefile.in (toplev.o): Depend on diagnostic-color.h.Jakub Jelinek
* Makefile.in (toplev.o): Depend on diagnostic-color.h. * diagnostic-color.c (should_colorize): Remove _WIN32 version. (colorize_init): Add argument to _WIN32 version. * toplev.c: Include diagnostic-color.h. (process_options): Default to -fdiagnostics-color=auto if GCC_COLORS env var is in the environment. * common.opt (fdiagnostics-color=): Add Var and Init. * doc/invoke.texi (-fdiagnostics-color=): Document that if GCC_COLORS env var is in the environment, the default is auto rather than never. * lib/prune.exp: Add -fdiagnostics-color=never to TEST_ALWAYS_FLAGS. * lib/c-compat.exp (compat-use-alt-compiler, compat_setup_dfp): Handle -fdiagnostics-color=never option similarly to -fno-diagnostics-show-caret option. From-SVN: r198332
2013-04-12opts.c: Include diagnostic-color.h.Jakub Jelinek
* 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: r197842