aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/error.cc
AgeCommit message (Collapse)AuthorFilesLines
2 daysdiagnostics: update signature of some callbacksDavid Malcolm1-2/+2
No functional change intended. gcc/cp/ChangeLog: * error.cc (cp_adjust_diagnostic_info): Convert "context" arg from ptr to const &. gcc/ChangeLog: * diagnostics/context.cc (context::get_any_inlining_info): Convert "context" arg of m_set_locations_cb from ptr to const &. (context::report_diagnostic): Convert "context" arg of m_adjust_diagnostic_info from ptr to const &. * diagnostics/context.h (context::set_locations_callback_t): Likewise. (context::set_adjust_diagnostic_info_callback): Likewise. (context::m_adjust_diagnostic_info): Likewise. * tree-diagnostic.cc (set_inlining_locations): Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-07-25diagnostics: eliminate ::diagnostic_info typedefDavid Malcolm1-7/+7
No functional change intended. gcc/c-family/ChangeLog: * c-common.cc: Update usage of "diagnostic_info" to explicitly refer to "diagnostics::diagnostic_info". * c-opts.cc: Likewise. gcc/c/ChangeLog: * c-errors.cc: Update usage of "diagnostic_info" to explicitly refer to "diagnostics::diagnostic_info". gcc/cp/ChangeLog: * constexpr.cc: Update usage of "diagnostic_info" to explicitly refer to "diagnostics::diagnostic_info". * cp-tree.h: Likewise. * error.cc: Likewise. * module.cc: Likewise. gcc/d/ChangeLog: * d-diagnostic.cc: Likewise. gcc/ChangeLog: * diagnostic.h: Eliminate "diagnostic_info" typedef. * diagnostics/context.cc: Update usage of "diagnostic_info" to explicitly refer to "diagnostics::diagnostic_info". * langhooks.cc: Likewise. * libgdiagnostics.cc: Likewise. * rtl-error.cc: Likewise. * substring-locations.cc: Likewise. * toplev.cc: Likewise. * tree-diagnostic.cc: Likewise. * tree-diagnostic.h: Likewise. gcc/fortran/ChangeLog: * cpp.cc: Update usage of "diagnostic_info" to explicitly refer to "diagnostics::diagnostic_info". * error.cc: Likewise. gcc/jit/ChangeLog: * dummy-frontend.cc: Update usage of "diagnostic_info" to explicitly refer to "diagnostics::diagnostic_info". gcc/m2/ChangeLog: * gm2-gcc/m2linemap.cc: Update usage of "diagnostic_info" to explicitly refer to "diagnostics::diagnostic_info". * gm2-gcc/rtegraph.cc: Likewise. gcc/rust/ChangeLog: * resolve/rust-ice-finalizer.cc: Update usage of "diagnostic_info" to explicitly refer to "diagnostics::diagnostic_info". * resolve/rust-ice-finalizer.h: Likewise. gcc/testsuite/ChangeLog: * g++.dg/plugin/show_template_tree_color_plugin.cc: Update usage of "diagnostic_info" to explicitly refer to "diagnostics::diagnostic_info". * gcc.dg/plugin/diagnostic_group_plugin.cc: Likewise. * gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Likewise. * gcc.dg/plugin/location_overflow_plugin.cc: Likewise. libcc1/ChangeLog: * context.cc: Update usage of "diagnostic_info" to explicitly refer to "diagnostics::diagnostic_info". Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-07-25diagnostics: convert diagnostic_t to enum class diagnostics::kindDavid Malcolm1-5/+7
No functional change intended. gcc/ChangeLog: * Makefile.in: Replace diagnostic.def with diagnostics/kinds.def. * config/aarch64/aarch64.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * config/i386/i386-options.cc: Likewise. * config/s390/s390.cc: Likewise. * diagnostic-core.h: Replace typedef diagnostic_t with enum class diagnostics::kind in diagnostics/kinds.h and include it. * diagnostic-global-context.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * diagnostic.cc: Likewise. * diagnostic.h: Likewise. * diagnostics/buffering.cc: Likewise. * diagnostics/buffering.h: Likewise. * diagnostics/context.h: Likewise. * diagnostics/diagnostic-info.h: Likewise. * diagnostics/html-sink.cc: Likewise. * diagnostic.def: Move to... * diagnostics/kinds.def: ...here and update for diagnostic_t becoming enum class diagnostics::kind. * diagnostics/kinds.h: New file, based on material in diagnostic-core.h. * diagnostics/lazy-paths.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * diagnostics/option-classifier.cc: Likewise. * diagnostics/option-classifier.h: Likewise. * diagnostics/output-spec.h: Likewise. * diagnostics/paths-output.cc: Likewise. * diagnostics/sarif-sink.cc: Likewise. * diagnostics/selftest-context.cc: Likewise. * diagnostics/selftest-context.h: Likewise. * diagnostics/sink.h: Likewise. * diagnostics/source-printing.cc: Likewise. * diagnostics/text-sink.cc: Likewise. * diagnostics/text-sink.h: Likewise. * gcc.cc: Likewise. * libgdiagnostics.cc: Likewise. * lto-wrapper.cc: Likewise. * opts-common.cc: Likewise. * opts-diagnostic.h: Likewise. * opts.cc: Likewise. * rtl-error.cc: Likewise. * substring-locations.cc: Likewise. * toplev.cc: Likewise. gcc/ada/ChangeLog: * gcc-interface/trans.cc: Update for diagnostic_t becoming enum class diagnostics::kind. gcc/analyzer/ChangeLog: * pending-diagnostic.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * program-point.cc: Likewise. gcc/c-family/ChangeLog: * c-common.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * c-format.cc: Likewise. * c-lex.cc: Likewise. * c-opts.cc: Likewise. * c-pragma.cc: Likewise. * c-warn.cc: Likewise. gcc/c/ChangeLog: * c-errors.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * c-parser.cc: Likewise. * c-typeck.cc: Likewise. gcc/cobol/ChangeLog: * util.cc: Update for diagnostic_t becoming enum class diagnostics::kind. gcc/cp/ChangeLog: * call.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * constexpr.cc: Likewise. * cp-tree.h: Likewise. * decl.cc: Likewise. * error.cc: Likewise. * init.cc: Likewise. * method.cc: Likewise. * module.cc: Likewise. * parser.cc: Likewise. * pt.cc: Likewise. * semantics.cc: Likewise. * typeck.cc: Likewise. * typeck2.cc: Likewise. gcc/d/ChangeLog: * d-diagnostic.cc: Update for diagnostic_t becoming enum class diagnostics::kind. gcc/fortran/ChangeLog: * cpp.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * error.cc: Likewise. * options.cc: Likewise. gcc/jit/ChangeLog: * dummy-frontend.cc: Update for diagnostic_t becoming enum class diagnostics::kind. gcc/m2/ChangeLog: * gm2-gcc/m2linemap.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * gm2-gcc/rtegraph.cc: Likewise. gcc/rust/ChangeLog: * backend/rust-tree.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * backend/rust-tree.h: Likewise. * resolve/rust-ast-resolve-expr.cc: Likewise. * resolve/rust-ice-finalizer.cc: Likewise. * resolve/rust-ice-finalizer.h: Likewise. * resolve/rust-late-name-resolver-2.0.cc: Likewise. gcc/testsuite/ChangeLog: * gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Update for diagnostic_t becoming enum class diagnostics::kind. * gcc.dg/plugin/expensive_selftests_plugin.cc: Likewise. * gcc.dg/plugin/location_overflow_plugin.cc: Likewise. * lib/gcc-dg.exp: Likewise. libcpp/ChangeLog: * internal.h: Update comment for diagnostic_t becoming enum class diagnostics::kind. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-07-25diagnostics: rename diagnostic_option_id to diagnostics::option_id and move ↵David Malcolm1-1/+1
to its own header No functional change intended. gcc/c-family/ChangeLog: * c-common.cc: Update for renaming of diagnostic_option_id to diagnostics::option_id. * c-common.h: Likewise. * c-cppbuiltin.cc: Likewise. * known-headers.cc: Likewise. * known-headers.h: Likewise. gcc/c/ChangeLog: * c-decl.cc: Update for renaming of diagnostic_option_id to diagnostics::option_id. * c-errors.cc: Likewise. * c-tree.h: Likewise. gcc/cobol/ChangeLog: * util.cc: Update for renaming of diagnostic_option_id to diagnostics::option_id. gcc/cp/ChangeLog: * cp-tree.h: Update for renaming of diagnostic_option_id to diagnostics::option_id. * decl.cc: Likewise. * error.cc: Likewise. * name-lookup.cc: Likewise. gcc/ChangeLog: * diagnostic-core.h: Include "diagnostics/option-id.h". (struct diagnostic_option_id): Move there, renaming to diagnostics::option_id. * diagnostic-global-context.cc: Update for renaming of diagnostic_option_id to diagnostics::option_id. * diagnostic.cc: Likewise. * diagnostic.h: Likewise. * diagnostics/context.h: Likewise. * diagnostics/diagnostic-info.h: Likewise. * diagnostics/lazy-paths.cc: Likewise. * diagnostics/option-classifier.cc: Likewise. * diagnostics/option-classifier.h: Likewise. * diagnostics/option-id.h: New file, taken from material in diagnostic-core.h. * diagnostics/selftest-context.cc: Update for renaming of diagnostic_option_id to diagnostics::option_id. * diagnostics/selftest-context.h: Likewise. * ipa-pure-const.cc: Likewise. * lto-wrapper.cc: Likewise. * opts-common.cc: Likewise. * opts-diagnostic.h: Likewise. * opts.cc: Likewise. * substring-locations.cc: Likewise. * substring-locations.h: Likewise. gcc/fortran/ChangeLog: * cpp.cc: Update for renaming of diagnostic_option_id to diagnostics::option_id. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-07-25diagnostics: move gcc/diagnostic-color.{h,cc} to gcc/diagnostics/color.{h,cc}David Malcolm1-1/+1
No functional change intended. gcc/ChangeLog: * Makefile.in (OBJS-libcommon): Replace diagnostic-color.o with diagnostics/color.o. (PLUGIN_HEADERS): Remove diagnostic-color.h in favor of glob. * common.opt: Update for move of diagnostic-color.h to diagnostics/color.h. * diagnostic.cc: Likewise. * diagnostic-color.cc: Move to... * diagnostics/color.cc: ...here. * diagnostic-color.h: Move to... * diagnostics/color.h: ...here. * diagnostics/edit-context.cc: Update for move of diagnostic-color.h to diagnostics/color.h. * diagnostics/output-spec.cc: Likewise. * diagnostics/paths-output.cc: Likewise. * diagnostics/source-printing.cc: Likewise. * diagnostics/text-sink.cc: Likewise. * libgdiagnostics.cc: Likewise. * opts.cc: Likewise. * pretty-print-markup.h: Likewise. * pretty-print.cc: Likewise. * selftest-run-tests.cc: Likewise. * selftest.h: Likewise. * text-art/style.cc: Likewise. gcc/cp/ChangeLog: * error.cc: Update for move of diagnostic-color.h to diagnostics/color.h. gcc/fortran/ChangeLog: * error.cc: Update for move of diagnostic-color.h to diagnostics/color.h. gcc/m2/ChangeLog: * gm2-gcc/m2color.cc: Update for move of diagnostic-color.h to diagnostics/color.h. gcc/testsuite/ChangeLog: * gcc.dg/plugin/analyzer_cpython_plugin.cc: Update for move of diagnostic-color.h to diagnostics/color.h. * gcc.dg/plugin/analyzer_kernel_plugin.cc: Likewise. * gcc.dg/plugin/analyzer_known_fns_plugin.cc: Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-07-25diagnostics: move diagnostic_context to diagnostics::context in its own headerDavid Malcolm1-5/+5
No functional change intended. gcc/ada/ChangeLog: * gcc-interface/misc.cc: Update for diagnostic_context becoming diagnostics::context. gcc/analyzer/ChangeLog: * program-point.cc: : Update for diagnostic_context becoming diagnostics::context, and for diagnostic_source_print_policy becoming diagnostics::source_print_policy. gcc/c-family/ChangeLog: * c-common.h: Update for diagnostic_context becoming diagnostics::context. * c-opts.cc: Likewise. gcc/c/ChangeLog: * c-objc-common.cc: Update for diagnostic_context becoming diagnostics::context. * c-tree.h: Likewise. gcc/ChangeLog: * coretypes.h: Update for diagnostic_context becoming diagnostics::context. * diagnostic-global-context.cc: Likewise. * diagnostic.cc: Likewise. Also for diagnostic_option_classifier becoming diagnostics::option_classifier. * diagnostic.h (diagnostic_text_starter_fn): Rename to... (diagnostics::text_starter_fn): ...this, and move to diagnostics/context.h. (get_printer): Rename to... (diagnostics::get_printer): ...this, and move to diagnostics/context.h. (class diagnostic_option_manager): Rename to... (class diagnostics::option_manager): ...this, and move to diagnostics/context.h. (class diagnostic_option_classifier): Rename to... (class diagnostics::option_classifier): ...this, and move to diagnostics/context.h. (struct diagnostic_source_printing_options): Rename to... (struct diagnostics::source_printing_options): ...this, and move to diagnostics/context.h. (class diagnostic_column_policy): Rename to... (class diagnostics::column_policy): ...this, and move to diagnostics/context.h. (class diagnostic_location_print_policy): Rename to... (class diagnostics::location_print_policy): ...this, and move to diagnostics/context.h. (class html_label_writer): Rename to... (class diagnostics::html_label_writer): ...this, and move to diagnostics/context.h. (class diagnostic_source_print_policy): Rename to... (class diagnostics::source_print_policy): ...this, and move to diagnostics/context.h. (struct diagnostic_counters): Rename to... (struct diagnostics::counters): ...this, and move to diagnostics/context.h. (class diagnostic_context): Rename to... (class diagnostics::context): ...this, and move to diagnostics/context.h. (diagnostic_text_starter): Rename to... (diagnostics::text_starter): ...this, and move to diagnostics/context.h. (diagnostic_start_span): Rename to... (diagnostics::start_span): ...this, and move to diagnostics/context.h. (diagnostic_text_finalizer): Rename to... (diagnostics::text_finalizer): ...this, and move to diagnostics/context.h. Include "diagnostics/context.h". * diagnostics/buffering.h: Update for diagnostic_context becoming diagnostics::context; similarly for diagnostic_counters. * diagnostics/client-data-hooks.h: Likewise. * diagnostics/context.h: New file, taken from material in diagnostic.h. * diagnostics/html-sink.cc: : Update for diagnostic_context becoming diagnostics::context. * diagnostics/html-sink.h: Likewise. * diagnostics/lazy-paths.cc: Likewise for diagnostic_option_manager. * diagnostics/output-file.h: Likewise for diagnostic_context. * diagnostics/output-spec.cc: Likewise. * diagnostics/output-spec.h: Likewise. * diagnostics/paths-output.cc: Likewise. * diagnostics/sarif-sink.cc: Likewise. * diagnostics/sarif-sink.h: Likewise. * diagnostics/sink.h: Likewise. * diagnostics/source-printing.cc: Likewise. * diagnostics/text-sink.cc: Likewise. * diagnostics/text-sink.h: Likewise. * gcc-rich-location.h: Likewise. * gcc.cc: Likewise. * gdbinit.in: Likewise. * langhooks-def.h: Likewise. * langhooks.cc: Likewise. * langhooks.h: Likewise. * libgdiagnostics.cc: Likewise. * optc-gen.awk: Likewise. * opth-gen.awk: Likewise. * opts-common.cc: Likewise. * opts-diagnostic.cc: Likewise. * opts-diagnostic.h: Likewise. * opts-global.cc: Likewise. * opts.cc: Likewise. * opts.h: Likewise. * selftest-diagnostic.cc: Likewise. * selftest-diagnostic.h: Likewise. * toplev.cc: Likewise. * tree-diagnostic-client-data-hooks.cc: Likewise. * tree-diagnostic.cc: Likewise. * tree-diagnostic.h: Likewise. gcc/cp/ChangeLog: * cp-tree.h: Update for diagnostic_context becoming diagnostics::context. * error.cc: Likewise. * module.cc: Likewise. gcc/fortran/ChangeLog: * error.cc: Update for diagnostic_context becoming diagnostics::context. gcc/jit/ChangeLog: * dummy-frontend.cc: Update for diagnostic_context becoming diagnostics::context. * jit-playback.h: Likewise. gcc/rust/ChangeLog: * resolve/rust-ast-resolve-expr.cc: Update for diagnostic_text_finalizer becoming diagnostics::text_finalizer. * resolve/rust-late-name-resolver-2.0.cc: Likewise. gcc/testsuite/ChangeLog: * g++.dg/plugin/show_template_tree_color_plugin.cc: Update for moves to namespace diagnostics. * gcc.dg/plugin/diagnostic_group_plugin.cc: Likewise. * gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Likewise. * gcc.dg/plugin/location_overflow_plugin.cc: Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-07-25diagnostics: add m_ prefix to fields of diagnostic_infoDavid Malcolm1-5/+5
No functional change intended. gcc/c-family/ChangeLog: * c-opts.cc (c_diagnostic_text_finalizer): Add "m_" prefix to fields of diagnostic_info. gcc/c/ChangeLog: * c-errors.cc: Update to add "m_" prefix to fields of diagnostic_info throughout. gcc/cp/ChangeLog: * constexpr.cc: Update to add "m_" prefix to fields of diagnostic_info throughout. * error.cc: Likewise. gcc/d/ChangeLog: * d-diagnostic.cc (d_diagnostic_report_diagnostic): Update to add "m_" prefix to fields of diagnostic_info throughout. gcc/ChangeLog: * diagnostic.cc: Update to add "m_" prefix to fields of diagnostic_info throughout. * diagnostic.h: Likewise. * diagnostics/html-sink.cc: Likewise. * diagnostics/sarif-sink.cc: Likewise. * diagnostics/text-sink.cc: Likewise. * libgdiagnostics.cc: Likewise. * substring-locations.cc: Likewise. * tree-diagnostic.cc: Likewise. gcc/fortran/ChangeLog: * error.cc: Update to add "m_" prefix to fields of diagnostic_info throughout. gcc/testsuite/ChangeLog: * gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Update to add "m_" prefix to fields of diagnostic_info throughout. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-07-25diagnostics: move/rename output formats to diagnostics as "sinks"David Malcolm1-26/+26
Within gcc/ move diagnostic-buffer.h to diagnostics/buffering.h move diagnostic-format-html.cc to diagnostics/html-sink.cc move diagnostic-format-html.h to diagnostics/html-sink.h move diagnostic-format-sarif.cc to diagnostics/sarif-sink.cc move diagnostic-format-sarif.h to diagnostics/sarif-sink.h move diagnostic-format.h to diagnostics/sink.h move diagnostic-format-text.cc to diagnostics/text-sink.cc move diagnostic-format-text.h to diagnostics/text-sink.h renaming various types including: Old name: New name: diagnostic_output_format diagnostics::sink diagnostic_buffer diagnostics::buffer diagnostic_per_format_buffer diagnostics::per_sink_buffer diagnostic_text_output_format diagnostics::text_sink sarif_output_format diagnostics::sarif_sink diagnostic_sarif_format_buffer diagnostics::sarif_sink_buffer html_output_format diagnostics::html_sink diagnostic_html_format_buffer diagnostics::html_sink_buffer No functional change intended. gcc/ChangeLog: * Makefile.in (OBJS): Replace diagnostic-format-html.o with diagnostics/html-sink.o, diagnostic-format-sarif.o with diagnostics/sarif-sink.o, and diagnostic-format-text.o with diagnostics/text-sink.o. * coretypes.h (class diagnostic_text_output_format): Replace with... (class diagnostics::text_sink): ...this. * diagnostic-global-context.cc: Update for move of diagnostics output formats into namespace "diagnostics", as "sinks". * diagnostic-macro-unwinding.cc: Likewise. * diagnostic-macro-unwinding.h: Likewise. * diagnostic-show-locus.cc: Likewise. * diagnostic.cc: Likewise. * diagnostic.h: Likewise. * diagnostic-buffer.h: Rename to... * diagnostics/buffering.h: ...this, updating for above changes. * diagnostics/client-data-hooks.h: Likewise. * diagnostics/digraphs.cc: Likewise. * diagnostic-format-html.cc: Rename to... * diagnostics/html-sink.cc: ...this, updating for above changes. * diagnostic-format-html.h: Rename to... * diagnostics/html-sink.h: ...this, updating for above changes. * diagnostics/lazy-paths.cc: Likewise. * diagnostics/metadata.h: Likewise. * diagnostics/output-spec.cc: Likewise. * diagnostics/output-spec.h: Likewise. * diagnostics/paths-output.cc: Likewise. * diagnostics/paths.h: Likewise. * diagnostic-format-sarif.cc: Rename to... * diagnostics/sarif-sink.cc: ...this, updating for above changes. * diagnostic-format-sarif.h: Rename to... * diagnostics/sarif-sink.h: ...this, updating for above changes. * diagnostic-format.h: Rename to... * diagnostics/sink.h: ...this, updating for above changes. * diagnostics/state-graphs-to-dot.cc: Likewise. * diagnostic-format-text.cc: Rename to... * diagnostics/text-sink.cc: ...this, updating for above changes. * diagnostic-format-text.h: Rename to... * diagnostics/text-sink.h: ...this, updating for above changes. * gcc.cc: Likewise. * langhooks-def.h: Likewise. * langhooks.cc: Likewise. * langhooks.h: Likewise. * libgdiagnostics.cc: Likewise. * opts-diagnostic.cc: Likewise. * opts.cc: Likewise. * selftest-diagnostic.cc: Likewise. * selftest-run-tests.cc: Likewise. * selftest.h: Likewise. * tree-diagnostic-client-data-hooks.cc: Likewise. * tree-diagnostic.cc: Likewise. gcc/analyzer/ChangeLog: * ana-state-to-diagnostic-state.cc: Update for move of diagnostics output formats into namespace "diagnostics" as "sinks". * bounds-checking.cc: Likewise. * call-details.cc: Likewise. * checker-event.cc: Likewise. * checker-event.h: Likewise. * diagnostic-manager.cc: Likewise. * diagnostic-manager.h: Likewise. * infinite-loop.cc: Likewise. * infinite-recursion.cc: Likewise. * pending-diagnostic.h: Likewise. * region-model.cc: Likewise. * sm-taint.cc: Likewise. gcc/c-family/ChangeLog: * c-opts.cc: Update for move of diagnostics output formats into namespace "diagnostics" as "sinks". gcc/cp/ChangeLog: * cp-tree.h: Update for move of diagnostics output formats into namespace "diagnostics" as "sinks". * error.cc: Likewise. gcc/fortran/ChangeLog: * error.cc: Update for move of diagnostics output formats into namespace "diagnostics" as "sinks". * gfortran.h: Likewise. gcc/jit/ChangeLog: * dummy-frontend.cc: Update for move of diagnostics output formats into namespace "diagnostics" as "sinks". gcc/rust/ChangeLog: * resolve/rust-ice-finalizer.cc: Update for move of diagnostics output formats into namespace "diagnostics" as "sinks". * resolve/rust-ice-finalizer.h: Likewise. gcc/testsuite/ChangeLog: * gcc.dg/plugin/diagnostic_group_plugin.cc: Update for move of diagnostics output formats into namespace "diagnostics" as "sinks". * gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Likewise. * gcc.dg/plugin/location_overflow_plugin.cc: Likewise. libcc1/ChangeLog: * context.cc: Update for move of diagnostics output formats into namespace "diagnostics" as "sinks". Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-07-25c++: Unwrap type traits defined in terms of builtins within diagnostics ↵Nathaniel Shead1-0/+14
[PR117294] Currently, concept failures of standard type traits just report 'expression X<T> evaluates to false'. However, many type traits are actually defined in terms of compiler builtins; we can do better here. For instance, 'is_constructible_v' could go on to explain why the type is not constructible, or 'is_invocable_v' could list potential candidates. Apart from concept diagnostics, this is also useful when using such traits in a 'static_assert' directly, so this patch also adjusts the diagnostics in that context. As a first step to supporting that we need to be able to map the standard type traits to the builtins that they use. Rather than adding another list that would need to be kept up-to-date whenever a builtin is added, this patch instead tries to detect any variable template defined directly in terms of a TRAIT_EXPR. This patch also adjusts 'diagnose_trait_expr' to provide more helpful diagnostics for these cases. Not all type traits have yet been updated, this patch just updates those that seem particularly valuable or straight-forward. The function also gets moved to cp/semantics.cc to be closer to 'trait_expr_value'. Various other parts of the compiler are also adjusted here to assist in making clear diagnostics, such as making more use of 'is_stub_object' to refer to a type directly rather than in terms of 'std::declval<T>()'. Additionally, since there are now more cases of nesting within a 'static_assert'ion I felt it was helpful for the experimental-nesting mode to nest here as well. PR c++/117294 PR c++/113854 gcc/cp/ChangeLog: * call.cc (implicit_conversion_error): Hide label when printing a stub object. (convert_like_internal): Likewise, and nest candidate diagnostics. * constexpr.cc (diagnose_failing_condition): Nest diagnostics, attempt to provide more helpful diagnostics for traits. * constraint.cc (satisfy_atom): Pass result before constant evaluation to diagnose_atomic_constraint. (diagnose_trait_expr): Adjust diagnostics for clarity and detail. (maybe_diagnose_standard_trait): New function. (diagnose_atomic_constraint): Attempt to provide more helpful diagnostics for more traits. * cp-tree.h (explain_not_noexcept): Declare new function. (is_trivially_xible): Add parameter. (is_nothrow_xible): Likewise. (is_xible): Likewise. (is_convertible): Likewise. (is_nothrow_convertible): Likewise. (diagnose_trait_expr): Declare new function. (maybe_diagnose_standard_trait): Declare new function. * error.cc (dump_type) <case TREE_VEC>: Handle trait types. * except.cc (explain_not_noexcept): New function. * method.cc (build_trait_object): Add complain parameter. (build_invoke): Propagate complain parameter. (assignable_expr): Add explain parameter to show diagnostics. (constructible_expr): Likewise. (destructible_expr): Likewise. (is_xible_helper): Replace trivial flag with explain flag, add diagnostics. (is_trivially_xible): New explain flag. (is_nothrow_xible): Likewise. (is_xible): Likewise. (is_convertible_helper): Add complain flag. (is_convertible): New explain flag. (is_nothrow_convertible): Likewise. * typeck.cc (cp_build_function_call_vec): Add handling for stub objects. (convert_arguments): Always return -1 on error. * typeck2.cc (cxx_readonly_error): Add handling for stub objects. libstdc++-v3/ChangeLog: * testsuite/20_util/any/misc/any_cast_neg.cc: Adjust diagnostics. * testsuite/20_util/expected/illformed_neg.cc: Likewise. * testsuite/20_util/optional/monadic/or_else_neg.cc: Likewise. * testsuite/23_containers/array/creation/3_neg.cc: Likewise. * testsuite/24_iterators/range_generators/lwg3900.cc: Likewise. * testsuite/29_atomics/atomic/requirements/types_neg.cc: Likewise. * testsuite/30_threads/stop_token/stop_callback/invocable_neg.cc: Likewise. * testsuite/30_threads/stop_token/stop_callback/destructible_neg.cc: Likewise. * testsuite/std/format/arguments/args_neg.cc: Likewise. * testsuite/std/format/string_neg.cc: Likewise. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-traits3.C: Adjust diagnostics. * g++.dg/cpp2a/concepts-traits4.C: New test. * g++.dg/diagnostic/static_assert5.C: New test. * g++.dg/ext/has_virtual_destructor2.C: New test. * g++.dg/ext/is_assignable2.C: New test. * g++.dg/ext/is_constructible9.C: New test. * g++.dg/ext/is_convertible7.C: New test. * g++.dg/ext/is_destructible3.C: New test. * g++.dg/ext/is_invocable6.C: New test. * g++.dg/ext/is_virtual_base_of_diagnostic2.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Patrick Palka <ppalka@redhat.com> Reviewed-by: Jason Merrill <jason@redhat.com>
2025-07-08c++: bogus error with union in qualified name [PR83469]Marek Polacek1-0/+1
While working on Reflection I noticed that we reject: union U { int i; }; constexpr auto r = ^^typename ::U; which is due to PR83469. Andrew P. posted a patch in 2021: https://gcc.gnu.org/pipermail/gcc-patches/2021-December/586344.html for which I had some comments but an updated patch never came. ~~ There are a few issues here with typenames and unions (and even struct keywords with unions). First in cp_parser_check_class_key, we need to allow typenames to name union types and union key to be able to use with typenames. The next issue is we need to record if we had a union key, right now we just record it was a struct/class/typename one which is wrong. ~~ This patch is an updated and cleaned up version; I've also addressed a missing bit in pt.cc. PR c++/83469 PR c++/93809 gcc/cp/ChangeLog: * cp-tree.h (UNION_TYPE_P): Define. (TYPENAME_IS_UNION_P): Define. * decl.cc (struct typename_info): Add union_p field. (struct typename_hasher::equal): Compare union_p field. (build_typename_type): Use ti.union_p for union_type. Set TYPENAME_IS_UNION_P. * error.cc (dump_type) <case TYPENAME_TYPE>: Handle TYPENAME_IS_UNION_P. * module.cc (trees_out::type_node): Likewise. * parser.cc (cp_parser_check_class_key): Allow typename key for union types and allow union keyword for typename types. * pt.cc (tsubst) <case TYPENAME_TYPE>: Don't conflate unions with class_type. For TYPENAME_IS_CLASS_P, check NON_UNION_CLASS_TYPE_P rather than CLASS_TYPE_P. Add TYPENAME_IS_UNION_P handling. gcc/testsuite/ChangeLog: * g++.dg/template/error45.C: Adjust dg-error. * g++.dg/warn/Wredundant-tags-3.C: Remove xfail. * g++.dg/parse/union1.C: New test. * g++.dg/parse/union2.C: New test. * g++.dg/parse/union3.C: New test. * g++.dg/parse/union4.C: New test. * g++.dg/parse/union5.C: New test. * g++.dg/parse/union6.C: New test. Co-authored-by: Andrew Pinski <quic_apinski@quicinc.com> Reviewed-by: Jason Merrill <jason@redhat.com>
2025-06-26diagnostics: make 5 more fields of diagnostic_context privateDavid Malcolm1-1/+1
No functional change intended. gcc/ada/ChangeLog: * gcc-interface/misc.cc (gnat_init): Use diagnostic_context::set_internal_error_callback. gcc/c-family/ChangeLog: * c-opts.cc (c_common_diagnostics_set_defaults): Use diagnostic_context::set_permissive_option. gcc/cp/ChangeLog: * error.cc (cxx_initialize_diagnostics): Use diagnostic_context::set_adjust_diagnostic_info_callback. gcc/ChangeLog: * diagnostic.h (diagnostic_context::set_permissive_option): New. (diagnostic_context::set_fatal_errors): New. (diagnostic_context::set_internal_error_callback): New. (diagnostic_context::set_adjust_diagnostic_info_callback): New. (diagnostic_context::inhibit_notes): New. (diagnostic_context::m_opt_permissive): Make private. (diagnostic_context::m_fatal_errors): Likewise. (diagnostic_context::m_internal_error): Likewise. (diagnostic_context::m_adjust_diagnostic_info): Likewise. (diagnostic_context::m_inhibit_notes_p): Likewise. (diagnostic_inhibit_notes): Delete. * opts.cc (common_handle_option): Use diagnostic_context::set_fatal_errors. * toplev.cc (internal_error_function): Use diagnostic_context::set_internal_error_callback. (general_init): Likewise. (process_options): Use diagnostic_context::inhibit_notes. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-06-02c++: Add co_await, co_yield and co_return to dump_expr.Iain Sandoe1-0/+21
These were omitted there as an oversight, most of the error handling for the coroutines code is specific rather than using generic %qE etc. gcc/cp/ChangeLog: * error.cc (dump_expr): Add co_await, co_yield and co_return. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2025-05-30OpenMP: C++ "declare mapper" supportJulian Brown1-0/+25
This patch adds support for OpenMP 5.0 "declare mapper" functionality for C++. I've merged it to og13 based on the last version posted upstream, with some minor changes due to the newly-added 'present' map modifier support. There's also a fix to splay-tree traversal in gimplify.cc:omp_instantiate_implicit_mappers, and this patch omits the rearrangement of gimplify.cc:gimplify_{scan,adjust}_omp_clauses that I separated out into its own patch and applied (to og13) already. gcc/c-family/ * c-common.h (c_omp_region_type): Add C_ORT_DECLARE_MAPPER and C_ORT_OMP_DECLARE_MAPPER codes. (omp_mapper_list): Add forward declaration. (c_omp_find_nested_mappers, c_omp_instantiate_mappers): Add prototypes. * c-omp.cc (c_omp_find_nested_mappers): New function. (remap_mapper_decl_info): New struct. (remap_mapper_decl_1, omp_instantiate_mapper, c_omp_instantiate_mappers): New functions. gcc/cp/ * constexpr.cc (reduced_constant_expression_p): Add OMP_DECLARE_MAPPER case. (cxx_eval_constant_expression, potential_constant_expression_1): Likewise. * cp-gimplify.cc (cxx_omp_finish_mapper_clauses): New function. * cp-objcp-common.h (LANG_HOOKS_OMP_FINISH_MAPPER_CLAUSES, LANG_HOOKS_OMP_MAPPER_LOOKUP, LANG_HOOKS_OMP_EXTRACT_MAPPER_DIRECTIVE, LANG_HOOKS_OMP_MAP_ARRAY_SECTION): Define langhooks. * cp-tree.h (lang_decl_base): Add omp_declare_mapper_p field. Recount spare bits comment. (DECL_OMP_DECLARE_MAPPER_P): New macro. (omp_mapper_id): Add prototype. (cp_check_omp_declare_mapper): Add prototype. (omp_instantiate_mappers): Add prototype. (cxx_omp_finish_mapper_clauses): Add prototype. (cxx_omp_mapper_lookup): Add prototype. (cxx_omp_extract_mapper_directive): Add prototype. (cxx_omp_map_array_section): Add prototype. * decl.cc (check_initializer): Add OpenMP declare mapper support. (cp_finish_decl): Set DECL_INITIAL for OpenMP declare mapper var decls as appropriate. * decl2.cc (mark_used): Instantiate OpenMP "declare mapper" magic var decls. * error.cc (dump_omp_declare_mapper): New function. (dump_simple_decl): Use above. * parser.cc (cp_parser_omp_clause_map): Add KIND parameter. Support "mapper" modifier. (cp_parser_omp_all_clauses): Add KIND argument to cp_parser_omp_clause_map call. (cp_parser_omp_target): Call omp_instantiate_mappers before finish_omp_clauses. (cp_parser_omp_declare_mapper): New function. (cp_parser_omp_declare): Add "declare mapper" support. * pt.cc (tsubst_decl): Adjust name of "declare mapper" magic var decls once we know their type. (tsubst_omp_clauses): Call omp_instantiate_mappers before finish_omp_clauses, for target regions. (tsubst_expr): Support OMP_DECLARE_MAPPER nodes. (instantiate_decl): Instantiate initialiser (i.e definition) for OpenMP declare mappers. * semantics.cc (gimplify.h): Include. (omp_mapper_id, omp_mapper_lookup, omp_extract_mapper_directive, cxx_omp_map_array_section, cp_check_omp_declare_mapper): New functions. (finish_omp_clauses): Delete GOMP_MAP_PUSH_MAPPER_NAME and GOMP_MAP_POP_MAPPER_NAME artificial clauses. (omp_target_walk_data): Add MAPPERS field. (finish_omp_target_clauses_r): Scan for uses of struct/union/class type variables. (finish_omp_target_clauses): Create artificial mapper binding clauses for used structs/unions/classes in offload region. gcc/fortran/ * parse.cc (tree.h, fold-const.h, tree-hash-traits.h): Add includes (for additions to omp-general.h). gcc/ * gimplify.cc (gimplify_omp_ctx): Add IMPLICIT_MAPPERS field. (new_omp_context): Initialise IMPLICIT_MAPPERS hash map. (delete_omp_context): Delete IMPLICIT_MAPPERS hash map. (instantiate_mapper_info): New structs. (remap_mapper_decl_1, omp_mapper_copy_decl, omp_instantiate_mapper, omp_instantiate_implicit_mappers): New functions. (gimplify_scan_omp_clauses): Handle MAPPER_BINDING clauses. (gimplify_adjust_omp_clauses): Instantiate implicit declared mappers. (gimplify_omp_declare_mapper): New function. (gimplify_expr): Call above function. * langhooks-def.h (lhd_omp_mapper_lookup, lhd_omp_extract_mapper_directive, lhd_omp_map_array_section): Add prototypes. (LANG_HOOKS_OMP_FINISH_MAPPER_CLAUSES, LANG_HOOKS_OMP_MAPPER_LOOKUP, LANG_HOOKS_OMP_EXTRACT_MAPPER_DIRECTIVE, LANG_HOOKS_OMP_MAP_ARRAY_SECTION): Define macros. (LANG_HOOK_DECLS): Add above macros. * langhooks.cc (lhd_omp_mapper_lookup, lhd_omp_extract_mapper_directive, lhd_omp_map_array_section): New dummy functions. * langhooks.h (lang_hooks_for_decls): Add OMP_FINISH_MAPPER_CLAUSES, OMP_MAPPER_LOOKUP, OMP_EXTRACT_MAPPER_DIRECTIVE, OMP_MAP_ARRAY_SECTION hooks. * omp-general.h (omp_name_type<T>): Add templatized struct, hash type traits (for omp_name_type<tree> specialization). (omp_mapper_list<T>): Add struct. * tree-core.h (omp_clause_code): Add OMP_CLAUSE__MAPPER_BINDING_. * tree-pretty-print.cc (dump_omp_clause): Support GOMP_MAP_UNSET, GOMP_MAP_PUSH_MAPPER_NAME, GOMP_MAP_POP_MAPPER_NAME artificial mapping clauses. Support OMP_CLAUSE__MAPPER_BINDING_ and OMP_DECLARE_MAPPER. * tree.cc (omp_clause_num_ops, omp_clause_code_name): Add OMP_CLAUSE__MAPPER_BINDING_. * tree.def (OMP_DECLARE_MAPPER): New tree code. * tree.h (OMP_DECLARE_MAPPER_ID, OMP_DECLARE_MAPPER_DECL, OMP_DECLARE_MAPPER_CLAUSES): New defines. (OMP_CLAUSE__MAPPER_BINDING__ID, OMP_CLAUSE__MAPPER_BINDING__DECL, OMP_CLAUSE__MAPPER_BINDING__MAPPER): New defines. include/ * gomp-constants.h (gomp_map_kind): Add GOMP_MAP_UNSET, GOMP_MAP_PUSH_MAPPER_NAME, GOMP_MAP_POP_MAPPER_NAME artificial mapping clause types. gcc/testsuite/ * c-c++-common/gomp/map-6.c: Update error scan output. * c-c++-common/gomp/declare-mapper-3.c: New test (only enabled for C++ for now). * c-c++-common/gomp/declare-mapper-4.c: Likewise. * c-c++-common/gomp/declare-mapper-5.c: Likewise. * c-c++-common/gomp/declare-mapper-6.c: Likewise. * c-c++-common/gomp/declare-mapper-7.c: Likewise. * c-c++-common/gomp/declare-mapper-8.c: Likewise. * c-c++-common/gomp/declare-mapper-9.c: Likewise. * c-c++-common/gomp/declare-mapper-10.c: Likewise. * c-c++-common/gomp/declare-mapper-12.c: Likewise. * g++.dg/gomp/declare-mapper-1.C: New test. * g++.dg/gomp/declare-mapper-2.C: New test. * g++.dg/gomp/declare-mapper-3.C: New test. libgomp/ * testsuite/libgomp.c++/declare-mapper-1.C: New test. * testsuite/libgomp.c++/declare-mapper-2.C: New test. * testsuite/libgomp.c++/declare-mapper-3.C: New test. * testsuite/libgomp.c++/declare-mapper-4.C: New test. * testsuite/libgomp.c++/declare-mapper-5.C: New test. * testsuite/libgomp.c++/declare-mapper-6.C: New test. * testsuite/libgomp.c++/declare-mapper-7.C: New test. * testsuite/libgomp.c++/declare-mapper-8.C: New test. * testsuite/libgomp.c-c++-common/declare-mapper-9.c: New test (only enabled for C++ for now). * testsuite/libgomp.c-c++-common/declare-mapper-10.c: Likewise. * testsuite/libgomp.c-c++-common/declare-mapper-11.c: Likewise. * testsuite/libgomp.c-c++-common/declare-mapper-12.c: Likewise. * testsuite/libgomp.c-c++-common/declare-mapper-13.c: Likewise. * testsuite/libgomp.c-c++-common/declare-mapper-14.c: Likewise. Co-authored-by: Tobias Burnus <tburnus@baylibre.com>
2025-05-29diagnostics: use unique_ptr for m_format_postprocessorDavid Malcolm1-5/+5
No functional change intended. gcc/cp/ChangeLog: * error.cc (cxx_format_postprocessor::clone): Update to use unique_ptr. (cxx_dump_pretty_printer::cxx_dump_pretty_printer): Likewise. (cxx_initialize_diagnostics): Likewise. gcc/ChangeLog: * pretty-print.cc (pretty_printer::pretty_printer): Use "nullptr" rather than "NULL". Remove explicit delete of m_format_postprocessor. * pretty-print.h (format_postprocessor::clone): Use unique_ptr. (pretty_printer::set_format_postprocessor): New. (pretty_printer::m_format_postprocessor): Use unique_ptr. (pp_format_postprocessor): Update for use of unique_ptr, removing reference from return type. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-05-26c++: add cxx_dump_pretty_printerJason Merrill1-0/+27
A class to simplify implementation of -fdump-lang-foo with support for pp_printf using %D and such. gcc/cp/ChangeLog: * cp-tree.h (class cxx_dump_pretty_printer): New. * error.cc (cxx_dump_pretty_printer): Ctor/dtor definitions.
2025-05-25c++: dump_template_bindings tweakJason Merrill1-6/+7
in r12-1100 we stopped printing template bindings like T = T. The check for this relied on TREE_CHAIN of a TEMPLATE_TYPE_PARM holding the declaration of that type-parameter. This should be written as TYPE_STUB_DECL. In addition, TYPE_STUB_DECL is only set on the TYPE_MAIN_VARIANT, so we need to check that as well. Which is also desirable because volatile T is visibly distinct from T. gcc/cp/ChangeLog: * error.cc (dump_template_bindings): Correct skipping of redundant bindings.
2025-04-28Eliminate make-unique.h and ::make_uniqueDavid Malcolm1-1/+0
C++11 does not provide a std::make_unique so in r13-3627-g00d7c8ff16e683 I added a make-unique.h declaring a ::make_unique. As of r15-4719-ga9ec1bc06bd3cc we can use C++14, so make-unique.h is no longer needed: we can use simply use std::make_unique instead. This patch removes make-unique.h and updates every place using it to use std::make_unique. No functional change intended. gcc/analyzer/ChangeLog: * access-diagram.cc: Replace uses of ::make_unique with std::make_unique. * analyzer.cc: Likewise. * bounds-checking.cc: Likewise. * call-details.cc: Likewise. * call-info.cc: Likewise. * call-string.cc: Likewise. * checker-path.cc: Likewise. * common.h: Drop include of "make-unique.h". * constraint-manager.cc: Replace uses of ::make_unique with std::make_unique. * diagnostic-manager.cc: Likewise. * engine.cc: Likewise. * infinite-loop.cc: Likewise. * infinite-recursion.cc: Likewise. * kf-analyzer.cc: Likewise. * kf-lang-cp.cc: Likewise. * kf.cc: Likewise. * pending-diagnostic.cc: Likewise. * program-point.cc: Likewise; drop #include. * program-state.cc: Likewise. * ranges.cc: Likewise. * region-model.cc: Likewise. * region.cc: Likewise; drop #include. * sm-fd.cc: Likewise. * sm-file.cc: Likewise. * sm-malloc.cc: Likewise. * sm-pattern-test.cc: Likewise. * sm-sensitive.cc: Likewise. * sm-signal.cc: Likewise. * sm-taint.cc: Likewise. * sm.cc: Likewise. * store.cc: Likewise. * supergraph.cc: Likewise. * svalue.cc: Likewise; drop #include. * varargs.cc: Likewise. gcc/c-family/ChangeLog: * c-pretty-print.cc: Drop include of "make-unique.h". Replace uses of ::make_unique with std::make_unique. gcc/c/ChangeLog: * c-decl.cc: Drop include of "make-unique.h". Replace uses of ::make_unique with std::make_unique. * c-objc-common.cc: Likewise. * c-parser.cc: Likewise. gcc/cp/ChangeLog: * cxx-pretty-print.cc: Drop include of "make-unique.h". Replace uses of ::make_unique with std::make_unique. * error.cc: Likewise. * name-lookup.cc: Likewise. * parser.cc: Likewise. gcc/ChangeLog: * diagnostic-format-json.cc: Drop include of "make-unique.h". Replace uses of ::make_unique with std::make_unique. * diagnostic-format-sarif.cc: Likewise. * diagnostic-format-text.cc: Likewise. * diagnostic.cc: Likewise. * dumpfile.cc: Likewise. * gcc-attribute-urlifier.cc: Likewise. * gcc-urlifier.cc: Likewise. * json-parsing.cc: Likewise. * json.cc: Likewise. * lazy-diagnostic-path.cc: Likewise. * libgdiagnostics.cc: Likewise. * libsarifreplay.cc: Likewise. * lto-wrapper.cc: Likewise. * make-unique.h: Delete. * opts-diagnostic.cc: Drop include of "make-unique.h". Replace uses of ::make_unique with std::make_unique. * pretty-print.cc: Likewise. * text-art/style.cc: Likewise. * text-art/styled-string.cc: Likewise. * text-art/table.cc: Likewise. * text-art/tree-widget.cc: Likewise. * text-art/widget.cc: Likewise. * timevar.cc: Likewise. * toplev.cc: Likewise. * tree-diagnostic-client-data-hooks.cc: Likewise. gcc/jit/ChangeLog: * dummy-frontend.cc: Drop include of "make-unique.h". Replace uses of ::make_unique with std::make_unique. gcc/testsuite/ChangeLog: * gcc.dg/plugin/analyzer_cpython_plugin.cc: Drop include of "make-unique.h". Replace uses of ::make_unique with std::make_unique. * gcc.dg/plugin/analyzer_gil_plugin.cc: Likewise. * gcc.dg/plugin/analyzer_kernel_plugin.cc: Likewise. * gcc.dg/plugin/analyzer_known_fns_plugin.cc: Likewise. * gcc.dg/plugin/diagnostic_group_plugin.cc: Likewise. * gcc.dg/plugin/diagnostic_plugin_xhtml_format.cc: Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-04-10c++: Use G_ instead of _ around cp/errors.cc gcc-internal-format strings ↵Jakub Jelinek1-30/+29
[PR119684] These pp_printf/pp_verbatim format strings should be gcc-internal-format, they use the pretty-print.cc format specifier handling rather than libc *printf, but pp_printf/pp_verbatim are intentionally not handled through exgettext because not everything done through them should be translated (e.g. its use for dump files shouldn't be). In addition, composing translatable messages from "in requirements " and later on "with " might make it harder to be translated. I've verified these strings (at least those which don't use format specifiers added post GCC 4.3 which gettext doesn't handle) are properly marked as gcc-internal-format in gcc.pot. The lack of that caused ICEs on German translation of the "%s%s%sIn instantiation of %q#D:\n" message because it contained too many %s. 2025-04-10 Jakub Jelinek <jakub@redhat.com> PR translation/119684 * error.cc (cp_print_error_function): Use G_ instead of _ for pp_printf arguments. (function_category): Use G_ instead of _. (print_instantiation_full_context): Use G_ instead of _ in pp_verbatim arguments. (print_location): Likewise. (print_instantiation_partial_context): Likewise. (maybe_print_constexpr_context): Likewise. (print_constrained_decl_info): Use G_() around pp_verbatim argument. (print_concept_check_info): Likewise. (print_constraint_context_head): Likewise. (print_requires_expression_info): Likewise. Merge separate pp_verbatim "in requirements " and "with " into one with conditional messages.
2025-03-27c++/modules: Fix tsubst of global module friend classes [PR118920]Nathaniel Shead1-1/+2
When doing tsubst_friend_class, we need to first check if any imported module has already created a (hidden) declaration for the class so that we don't end up with conflicting declarations. Currently we do this using DECL_MODULE_IMPORT_P, but this is not set in cases where the class is in the global module and matches an existing GM declaration we've seen (via an include, for example). This patch fixes this by checking DECL_MODULE_ENTITY_P instead, which is set on all entities that have been seen from a module import. We also use the 'for_mangle' version of get_originating_module so that we don't treat imported GM entities as attached to the module we imported them from. And rename that parameter to something more general. And dump_module_suffix is another place where we want to treat global module entities as not coming from a module. PR c++/118920 gcc/cp/ChangeLog: * name-lookup.cc (lookup_imported_hidden_friend): Check for module entity rather than just module import. * module.cc (get_originating_module): Rename for_mangle parm to global_m1. * error.cc (dump_module_suffix): Don't decorate global module decls. gcc/testsuite/ChangeLog: * g++.dg/modules/tpl-friend-17.h: New test. * g++.dg/modules/tpl-friend-17_a.C: New test. * g++.dg/modules/tpl-friend-17_b.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Co-authored-by: Jason Merrill <jason@redhat.com>
2025-02-04c++: Fix overeager Woverloaded-virtual with conversion operators [PR109918]Simon Martin1-1/+2
We currently emit an incorrect -Woverloaded-virtual warning upon the following test case === cut here === struct A { virtual operator int() { return 42; } virtual operator char() = 0; }; struct B : public A { operator char() { return 'A'; } }; === cut here === The problem is that when iterating over ovl_range (fns), warn_hidden gets confused by the conversion operator marker, concludes that seen_non_override is true and therefore emits a warning for all conversion operators in A that do not convert to char, even if -Woverloaded-virtual is 1 (e.g. with -Wall, the case reported). A second set of problems is highlighted when -Woverloaded-virtual is 2. First, with the same test case, since base_fndecls contains all conversion operators in A (except the one to char, that's been removed when iterating over ovl_range (fns)), we emit a spurious warning for the conversion operator to int, even though it's unrelated. Second, in case there are several conversion operators with different cv-qualifiers to the same type in A, we rightfully emit a warning, however the note uses the location of the conversion operator marker instead of the right one; location_of should go over conv_op_marker. This patch fixes all these by explicitly keeping track of (1) base methods that are overriden, as well as (2) base methods that are hidden but not overriden (and by what), and warning about methods that are in (2) but not (1). It also ignores non virtual base methods, per "definition" of -Woverloaded-virtual. Co-authored-by: Jason Merrill <jason@redhat.com> PR c++/117114 PR c++/109918 gcc/cp/ChangeLog: * class.cc (warn_hidden): Keep track of overloaded and of hidden base methods. * error.cc (location_of): Skip over conv_op_marker. gcc/testsuite/ChangeLog: * g++.dg/warn/Woverloaded-virt1.C: Check that no warning is emitted for non virtual base methods. * g++.dg/warn/Woverloaded-virt10.C: New test. * g++.dg/warn/Woverloaded-virt11.C: New test. * g++.dg/warn/Woverloaded-virt12.C: New test. * g++.dg/warn/Woverloaded-virt13.C: New test. * g++.dg/warn/Woverloaded-virt5.C: New test. * g++.dg/warn/Woverloaded-virt6.C: New test. * g++.dg/warn/Woverloaded-virt7.C: New test. * g++.dg/warn/Woverloaded-virt8.C: New test. * g++.dg/warn/Woverloaded-virt9.C: New test.
2025-01-21c++: Handle RAW_DATA_CST in add_list_candidates [PR118532]Jakub Jelinek1-1/+20
This is the second bug discovered today with the https://gcc.gnu.org/pipermail/gcc-patches/2025-January/673945.html hack but then turned into proper testcases where embed-2[23].C FAILed since introduction of optimized #embed support and the others when optimizing large C++ initializers using RAW_DATA_CST. The add_list_candidates problem is the same as with make_tree_vector_from_ctor, unfortunately it can't call that function because it can have those additional artificial arguments that need to be pushed earlier. When working on the patch, I've also noticed an error where we didn't know how to dump RAW_DATA_CST, so I've added support for that too. 2025-01-21 Jakub Jelinek <jakub@redhat.com> PR c++/118532 * call.cc (add_list_candidates): Handle RAW_DATA_CST among init_list elts. * error.cc (dump_expr_init_vec): Handle RAW_DATA_CST among v elts. * g++.dg/cpp/embed-22.C: New test. * g++.dg/cpp/embed-23.C: New test. * g++.dg/cpp0x/pr118532.C: New test. * g++.dg/cpp2a/explicit20.C: New test.
2025-01-09c++: improve some modules commentsJason Merrill1-1/+1
gcc/cp/ChangeLog: * error.cc (cxx_initialize_diagnostics): Improve comment. * module.cc (modules): Improve comment. (get_originating_module): Add function comment.
2025-01-08c++: print stub object as std::declvalJason Merrill1-0/+9
If the result of build_stub_object gets printed by %E it looks something like '(A&&)1', which seems confusing. Let's instead print it as 'std::declval<A>()' since that's how the library writes the same idea. gcc/cp/ChangeLog: * method.cc (is_stub_object): New. * cp-tree.h (is_stub_object): Declare. * error.cc (dump_expr): Use it. gcc/testsuite/ChangeLog: * g++.dg/gomp/declare-variant-3.C: Update diagnostic. * g++.dg/gomp/declare-variant-5.C: Likewise.
2025-01-02Update copyright years.Jakub Jelinek1-1/+1
2024-12-17c++: print NONTYPE_ARGUMENT_PACK [PR118073]Marek Polacek1-0/+15
This PR points out that we're not pretty-printing NONTYPE_ARGUMENT_PACK so the compiler emits the ugly: 'nontype_argument_pack' not supported by dump_expr<expression error>> Fixed thus. I've wrapped the elements of the pack in { } because that's what cxx_pretty_printer::expression does. PR c++/118073 gcc/cp/ChangeLog: * error.cc (dump_expr) <case NONTYPE_ARGUMENT_PACK>: New case. gcc/testsuite/ChangeLog: * g++.dg/diagnostic/arg-pack1.C: New test.
2024-12-16diagnostics: move libgdiagnostics dc from sinks into diagnostic_managerDavid Malcolm1-2/+6
libgdiagnostics was written before the fixes for PR other/116613 allowed a diagnostic_context to have multiple output sinks. Hence each libgdiagnostics sink had its own diagnostic_context with just one diagnostic_output_format. This wart is no longer necessary and makes it harder to move state into the manager/context; in particular for quoting source code from the .sarif file (PR sarif-replay/117943). Simplify, by making libgdiagnostics' implementation more similar to GCC's implementation, by moving the diagnostic_context from sink into diagnostic_manager. Doing so requires generalizing where the diagnostic_source_printing_options comes from in class diagnostic_text_output_format: for GCC we use the instance within the diagnostic_context, whereas for libgdiagnostics each diagnostic_text_sink has its own instance. No functional change intended. gcc/c-family/ChangeLog: PR sarif-replay/117943 * c-format.cc (selftest::test_type_mismatch_range_labels): Use dc.m_source_printing. * c-opts.cc (c_diagnostic_text_finalizer): Use source-printing options from text_output. gcc/cp/ChangeLog: PR sarif-replay/117943 * error.cc (auto_context_line::~auto_context_line): Use source-printing options from text_output. gcc/ChangeLog: PR sarif-replay/117943 * diagnostic-format-text.cc (diagnostic_text_output_format::append_note): Use source-printing options from text_output. (diagnostic_text_output_format::update_printer): Copy source-printing options from dc. (default_diagnostic_text_finalizer): Use source-printing options from text_output. * diagnostic-format-text.h (diagnostic_text_output_format::diagnostic_text_output_format): Add optional diagnostic_source_printing_options param, using the context's if null. (diagnostic_text_output_format::get_source_printing_options): New accessor. (diagnostic_text_output_format::m_source_printing): New field. * diagnostic-path.cc (event_range::print): Use source-printing options from text_output. (selftest::test_interprocedural_path_1): Use source-printing options from dc. * diagnostic-show-locus.cc (gcc_rich_location::add_location_if_nearby): Likewise. (diagnostic_context::maybe_show_locus): Add "opts" param and use in place of m_source_printing. Pass it to source_policy ctor. (diagnostic_source_print_policy::diagnostic_source_print_policy): Add overload taking a const diagnostic_source_printing_options &. * diagnostic.cc (diagnostic_context::initialize): Pass nullptr for source options when creating text sink, so that it uses the dc's options. (diagnostic_context::dump): Add an "output sinks:" heading and print "(none)" if there aren't any. (diagnostic_context::set_output_format): Split out code into... (diagnostic_context::remove_all_output_sinks): ...this new function. * diagnostic.h (diagnostic_source_print_policy::diagnostic_source_print_policy): Add overload taking a const diagnostic_source_printing_options &. (diagnostic_context::maybe_show_locus): Add "opts" param. (diagnostic_context::remove_all_output_sinks): New decl. (diagnostic_context::m_source_printing): New field. (diagnostic_show_locus): Add "opts" param and pass to maybe_show_locus. * libgdiagnostics.cc (sink::~sink): Delete. (sink::begin_group): Delete. (sink::end_group): Delete. (sink::emit): Delete. (sink::m_dc): Drop field. (diagnostic_text_sink::on_begin_text_diagnostic): Delete. (diagnostic_text_sink::get_source_printing_options): Use m_souece_printing. (diagnostic_text_sink::m_current_logical_loc): Drop field. (diagnostic_text_sink::m_inner_sink): New field. (diagnostic_text_sink::m_source_printing): New field. (diagnostic_manager::diagnostic_manager): Update for changes to fields. Initialize m_dc. (diagnostic_manager::~diagnostic_manager): Call diagnostic_finish. (diagnostic_manager::get_file_cache): Drop. (diagnostic_manager::get_dc): New accessor. (diagnostic_manager::begin_group): Reimplement. (diagnostic_manager::end_group): Reimplement. (diagnostic_manager::get_prev_diag_logical_loc): New accessor. (diagnostic_manager::m_dc): New field. (diagnostic_manager::m_file_cache): Drop field. (diagnostic_manager::m_edit_context): Convert to a std::unique_ptr so that object can be constructed after m_dc is initialized. (diagnostic_manager::m_prev_diag_logical_loc): New field. (diagnostic_text_sink::diagnostic_text_sink): Reimplement. (get_color_rule): Delete. (diagnostic_text_sink::set_colorize): Reimplement. (diagnostic_text_sink::text_starter): New. (sarif_sink::sarif_sink): Reimplement. (diagnostic_manager::write_patch): Update for change to m_edit_context. (diagnostic_manager::emit): Update now that each sink has a corresponding diagnostic_output_format object within m_dc. gcc/fortran/ChangeLog: PR sarif-replay/117943 * error.cc (gfc_diagnostic_text_starter): Use source-printing options from text_output. gcc/testsuite/ChangeLog: PR sarif-replay/117943 * gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc (custom_diagnostic_text_finalizer): Use source-printing options from text_output. * gcc.dg/plugin/diagnostic_plugin_xhtml_format.cc (xhtml_builder::make_element_for_diagnostic): Use source-printing options from diagnostic_context. * gcc.dg/plugin/expensive_selftests_plugin.cc (test_richloc): Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-12-06c++: use diagnostic nesting [PR116253]David Malcolm1-15/+84
This patch uses the nested diagnostics capabilities added in the earlier patch in the C++ frontend. With this, and enabling the non-standard text formatting via: -fdiagnostics-set-output=text:experimental-nesting=yes and using: -std=c++20 -fconcepts-diagnostics-depth=2 then the output for the example in SG15's P3358R0 ("SARIF for Structured Diagnostics") is: P3358R0.C: In function ‘int main()’: P3358R0.C:26:6: error: no matching function for call to ‘pet(lizard)’ 26 | pet(lizard{}); | ~~~^~~~~~~~~~ • note: candidate: ‘template<class auto:1> requires pettable<auto:1> void pet(auto:1)’ P3358R0.C:21:6: 21 | void pet(pettable auto t); | ^~~ • note: template argument deduction/substitution failed: • note: constraints not satisfied • P3358R0.C: In substitution of ‘template<class auto:1> requires pettable<auto:1> void pet(auto:1) [with auto:1 = lizard]’: • required from here P3358R0.C:26:6: 26 | pet(lizard{}); | ~~~^~~~~~~~~~ • required for the satisfaction of ‘pettable<auto:1>’ [with auto:1 = lizard] P3358R0.C:19:9: 19 | concept pettable = has_member_pet<T> or has_default_pet<T>; | ^~~~~~~~ • note: no operand of the disjunction is satisfied P3358R0.C:19:38: 19 | concept pettable = has_member_pet<T> or has_default_pet<T>; | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~ • note: the operand ‘has_member_pet<T>’ is unsatisfied because P3358R0.C:19:20: 19 | concept pettable = has_member_pet<T> or has_default_pet<T>; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ • required for the satisfaction of ‘has_member_pet<T>’ [with T = lizard] P3358R0.C:13:9: 13 | concept has_member_pet = requires(T t) { t.pet(); }; | ^~~~~~~~~~~~~~ • required for the satisfaction of ‘pettable<auto:1>’ [with auto:1 = lizard] P3358R0.C:19:9: 19 | concept pettable = has_member_pet<T> or has_default_pet<T>; | ^~~~~~~~ • in requirements with ‘T t’ [with T = lizard] P3358R0.C:13:26: 13 | concept has_member_pet = requires(T t) { t.pet(); }; | ^~~~~~~~~~~~~~~~~~~~~~~~~~ • note: the required expression ‘t.pet()’ is invalid, because P3358R0.C:13:47: 13 | concept has_member_pet = requires(T t) { t.pet(); }; | ~~~~~^~ • error: ‘struct lizard’ has no member named ‘pet’ P3358R0.C:13:44: 13 | concept has_member_pet = requires(T t) { t.pet(); }; | ~~^~~ • note: the operand ‘has_default_pet<T>’ is unsatisfied because P3358R0.C:19:41: 19 | concept pettable = has_member_pet<T> or has_default_pet<T>; | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ • required for the satisfaction of ‘has_default_pet<T>’ [with T = lizard] P3358R0.C:16:9: 16 | concept has_default_pet = T::is_pettable; | ^~~~~~~~~~~~~~~ • required for the satisfaction of ‘pettable<auto:1>’ [with auto:1 = lizard] P3358R0.C:19:9: 19 | concept pettable = has_member_pet<T> or has_default_pet<T>; | ^~~~~~~~ • error: ‘is_pettable’ is not a member of ‘lizard’ P3358R0.C:16:30: 16 | concept has_default_pet = T::is_pettable; | ^~~~~~~~~~~ • note: candidate: ‘void pet(dog)’ P3358R0.C:9:6: 9 | void pet(dog); | ^~~ • note: no known conversion for argument 1 from ‘lizard’ to ‘dog’ P3358R0.C:9:10: 9 | void pet(dog); | ^~~ • note: candidate: ‘void pet(cat)’ P3358R0.C:10:6: 10 | void pet(cat); | ^~~ • note: no known conversion for argument 1 from ‘lizard’ to ‘cat’ P3358R0.C:10:10: 10 | void pet(cat); | ^~~ showing the hierarchical structure of the messages; ideally there would be a UI here allowing the user to expand/collapse the messages to drill out into the detail they are interested in. The structure is also captured in SARIF output (via the "nestingLevel" property). gcc/cp/ChangeLog: PR other/116253 * call.cc (print_conversion_rejection): Remove leading space from diagnostic messages. (print_conversion_rejection): Likewise. (print_arity_information): Likewise. (print_z_candidate): Likewise. Add auto_diagnostic_nesting_level before calls to fn_type_unification and diagnose_constraints. (print_z_candidates): Add auto_diagnostic_nesting_level before looping over candidates. (conversion_null_warnings): Remove leading space from diagnostic messages. (maybe_inform_about_fndecl_for_bogus_argument_init): Likewise. * constraint.cc (tsubst_valid_expression_requirement): Add auto_diagnostic_nesting_level when showing why the expression is invalid. (satisfy_disjunction): Likewise when showing operans, and again when replaying each branch of the disjunction. (diagnose_constraints): Likewise when replaying satisfaction. * error.cc (cp_diagnostic_text_starter): Set prefix. (print_instantiation_full_context): Only show the file if we're not showing nesting or the user has opted in to showing location information in nested diagnostics. (class auto_context_line): New. (print_instantiation_partial_context_line): Replace calls to print_location and to diagnostic_show_locus with an auto_context_line. (print_instantiation_partial_context): Replace calls to print_location with an auto_context_line. (maybe_print_constexpr_context): Likewise. (print_constrained_decl_info): Likewise. (print_concept_check_info): Likewise. (print_constraint_context_head): Likewise. (print_requires_expression_info): Likewise. gcc/testsuite/ChangeLog: PR other/116253 * g++.dg/concepts/nested-diagnostics-1-truncated.C: New test. * g++.dg/concepts/nested-diagnostics-1.C: New test. * g++.dg/concepts/nested-diagnostics-2.C: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-12-06c++: consolidate location printing in error.cc [PR116253]David Malcolm1-47/+24
Consolidate the location-printing logic in cp/error.cc, as preliminary work towards supporting nested diagnostics (PR other/116253). gcc/cp/ChangeLog: PR other/116253 * error.cc (print_location): Move to earlier in the file. (print_instantiation_partial_context_line): Replace location-printing logic with a call to print_location. (print_instantiation_partial_context): Likewise, splitting up pp_verbatim calls. (maybe_print_constexpr_context): Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-12-04c++: Fix up erroneous template error recovery ICE [PR117826]Jakub Jelinek1-2/+2
The testcase in the PR (which can't be easily reduced and is way too large and has way too many errors) results in an ICE, because the erroneous_templates hash_map holds trees of erroneous templates across ggc_collect and some of the templates in there could be removed, so the later lookup can crash on comparison of already freed and reused trees. The following patch makes the hash_map GTY((cache)) marked. The cp-tree.h changes before the erroneous_template declaration are needed to make gengtype happy, it didn't like using directive nor using a template-id as a template parameter. It is marked cache because if a decl would be solely referenced from the erroneous_templates hash_map, then nothing would look it up. 2024-12-04 Jakub Jelinek <jakub@redhat.com> PR c++/117826 * cp-tree.h (struct decl_location_traits): New type. (erroneous_templates_t): Change using into typedef. (erroneous_templates): Add GTY((cache)). * error.cc (cp_adjust_diagnostic_info): Use hash_map_safe_get_or_insert<true> rather than hash_map_safe_get_or_insert<false> for erroneous_templates.
2024-12-02c++: some further concepts cleanupsPatrick Palka1-5/+0
This patch further cleans up the concepts code following the removal of Concepts TS support: * concept-ids are now the only kind of "concept check", so we can simplify some code accordingly. In particular resolve_concept_check seems like a no-op and can be removed. * In turn, deduce_constrained_parameter doesn't seem to do anything interesting. * In light of the above we might as well inline finish_type_constraints into its only caller. * Introduce and use a helper for obtaining the prototype parameter of a concept, i.e. its first template parameter. * placeholder_extract_concept_and_args is only ever called on a concept-id, so it's simpler to inline it into its callers. * There's no such thing as a template-template-parameter with a type-constraint, so we can remove such handling from the parser. This means is_constrained_parameter is currently equivalent to declares_constrained_type_template_parameter, so let's prefer to use the latter. * Remove WILDCARD_DECL and instead use the concept's prototype parameter as the dummy first argument of a type-constraint during template argument coercion. * Remove a redundant concept_definition_p overload. gcc/cp/ChangeLog: * constraint.cc (resolve_concept_check): Remove. (deduce_constrained_parameter): Remove. (finish_type_constraints): Inline into its only caller cp_parser_placeholder_type_specifier and remove. (build_concept_check_arguments): Coding style tweaks. (build_standard_check): Inline into its only caller ... (build_concept_check): ... here. (build_type_constraint): Use the prototype parameter as the first template argument. (finish_shorthand_constraint): Remove function concept handling. Use concept_prototype_parameter. (placeholder_extract_concept_and_args): Inline into its callers and remove. (equivalent_placeholder_constraints): Adjust after placeholder_extract_concept_and_args removal. (iterative_hash_placeholder_constraint): Likewise. * cp-objcp-common.cc (cp_common_init_ts): Remove WILDCARD_DECL handling. * cp-tree.def (WILDCARD_DECL): Remove. * cp-tree.h (WILDCARD_PACK_P): Remove. (type_uses_auto_or_concept): Remove declaration of nonexistent function. (append_type_to_template_for_access_check): Likewise. (finish_type_constraints): Remove declaration. (placeholder_extract_concept_and_args): Remove declaration. (deduce_constrained_parameter): Remove declaration. (resolve_constraint_check): Remove declaration. (valid_requirements_p): Remove declaration of nonexistent function. (finish_concept_name): Likewise. (concept_definition_p): Remove redundant overload. (concept_prototype_parameter): Define. * cxx-pretty-print.cc (pp_cxx_constrained_type_spec): Adjust after placeholder_extract_concept_and_args. * error.cc (dump_decl) <case WILDCARD_DECL>: Remove. (dump_expr) <case WILDCARD_DECL>: Likewise. * parser.cc (is_constrained_parameter): Inline into declares_constrained_type_template_parameter and remove. (cp_parser_check_constrained_type_parm): Declare static. (finish_constrained_template_template_parm): Remove. (cp_parser_constrained_template_template_parm): Remove. (finish_constrained_parameter): Remove dead code guarded by cp_parser_constrained_template_template_parm. (declares_constrained_type_template_parameter): Adjust after is_constrained_parameter removal. (declares_constrained_template_template_parameter): Remove. (cp_parser_placeholder_type_specifier): Adjust after finish_type_constraints removal. Check the prototype parameter earlier, before build_type_constraint. Use concept_prototype_parameter. (cp_parser_parameter_declaration): Remove dead code guarded by declares_constrained_template_template_parameter. * pt.cc (convert_wildcard_argument): Remove. (convert_template_argument): Remove WILDCARD_DECL handling. (coerce_template_parameter_pack): Likewise. (tsubst) <case TEMPLATE_TYPE_PARM>: Likewise. (type_dependent_expression_p): Likewise. (make_constrained_placeholder_type): Remove function concept handling. (placeholder_type_constraint_dependent_p): Remove WILDCARD_DECL handling. Reviewed-by: Jason Merrill <jason@redhat.com>
2024-11-28c++: Implement P2662R3, Pack Indexing [PR113798]Marek Polacek1-0/+16
This patch implements C++26 Pack Indexing, as described in <https://wg21.link/P2662R3>. The issue discussing how to mangle pack indexes has not been resolved yet <https://github.com/itanium-cxx-abi/cxx-abi/issues/175> and I've made no attempt to address it so far. Unlike v1, which used augmented TYPE/EXPR_PACK_EXPANSION codes, this version introduces two new codes: PACK_INDEX_EXPR and PACK_INDEX_TYPE. Both carry two operands: the pack expansion and the index. They are handled in tsubst_pack_index: substitute the index and the pack and then extract the element from the vector (if possible). To handle pack indexing in a decltype or with decltype(auto), there is also the new PACK_INDEX_PARENTHESIZED_P flag. With this feature, it's valid to write something like using U = tmpl<Ts...[Is]...>; where we first expand the template argument into Ts...[Is#0], Ts...[Is#1], ... and then substitute each individual pack index. PR c++/113798 gcc/cp/ChangeLog: * constexpr.cc (potential_constant_expression_1) <case PACK_INDEX_EXPR>: New case. * cp-objcp-common.cc (cp_common_init_ts): Mark PACK_INDEX_TYPE and PACK_INDEX_EXPR. * cp-tree.def (PACK_INDEX_TYPE): New. (PACK_INDEX_EXPR): New. * cp-tree.h (WILDCARD_TYPE_P): Also check PACK_INDEX_TYPE. (PACK_INDEX_CHECK): Define. (PACK_INDEX_P): Define. (PACK_INDEX_PACK): Define. (PACK_INDEX_INDEX): Define. (PACK_INDEX_PARENTHESIZED_P): Define. (make_pack_index): Declare. (pack_index_element): Declare. * cxx-pretty-print.cc (cxx_pretty_printer::expression) <case PACK_INDEX_EXPR>: New case. (cxx_pretty_printer::type_id) <case PACK_INDEX_TYPE>: New case. * error.cc (dump_type) <case PACK_INDEX_TYPE>: New case. (dump_type_prefix): Handle PACK_INDEX_TYPE. (dump_type_suffix): Likewise. (dump_expr) <case PACK_INDEX_EXPR>: New case. * mangle.cc (write_type) <case PACK_INDEX_TYPE>: New case. * module.cc (trees_out::type_node) <case PACK_INDEX_TYPE>: New case. (trees_in::tree_node) <case PACK_INDEX_TYPE>: New case. * parser.cc (cp_parser_next_tokens_are_pack_index_p): New. (cp_parser_pack_index): New. (cp_parser_primary_expression): Handle a C++26 pack-index-expression. (cp_parser_unqualified_id): Handle a C++26 pack-index-specifier. (cp_parser_nested_name_specifier_opt): See if a pack-index-specifier follows. (cp_parser_qualifying_entity): Handle a C++26 pack-index-specifier. (cp_parser_decltype_expr): Set id_expression_or_member_access_p for pack indexing. (cp_parser_mem_initializer_id): Handle a C++26 pack-index-specifier. (cp_parser_simple_type_specifier): Likewise. (cp_parser_base_specifier): Likewise. * pt.cc (iterative_hash_template_arg) <case PACK_INDEX_TYPE, PACK_INDEX_EXPR>: New case. (find_parameter_packs_r) <case PACK_INDEX_TYPE, PACK_INDEX_EXPR>: New case. (make_pack_index): New. (tsubst_pack_index): New. (tsubst): Avoid tsubst on PACK_INDEX_TYPE. <case TYPENAME_TYPE>: Add a call to error. <case PACK_INDEX_TYPE>: New case. (tsubst_expr) <case PACK_INDEX_EXPR>: New case. (dependent_type_p_r): Return true for PACK_INDEX_TYPE. (type_dependent_expression_p): Recurse on PACK_INDEX_PACK for PACK_INDEX_EXPR. * ptree.cc (cxx_print_type) <case PACK_INDEX_TYPE>: New case. * semantics.cc (finish_parenthesized_expr): Set PACK_INDEX_PARENTHESIZED_P for PACK_INDEX_EXPR. (finish_type_pack_element): Adjust error messages. (pack_index_element): New. * tree.cc (cp_tree_equal) <case PACK_INDEX_EXPR>: New case. (cp_walk_subtrees) <case PACK_INDEX_TYPE, PACK_INDEX_EXPR>: New case. * typeck.cc (structural_comptypes) <case PACK_INDEX_TYPE>: New case. libstdc++-v3/ChangeLog: * testsuite/20_util/tuple/element_access/get_neg.cc: Adjust dg-prune-output. gcc/testsuite/ChangeLog: * g++.dg/cpp26/pack-indexing1.C: New test. * g++.dg/cpp26/pack-indexing2.C: New test. * g++.dg/cpp26/pack-indexing3.C: New test. * g++.dg/cpp26/pack-indexing4.C: New test. * g++.dg/cpp26/pack-indexing5.C: New test. * g++.dg/cpp26/pack-indexing6.C: New test. * g++.dg/cpp26/pack-indexing7.C: New test. * g++.dg/cpp26/pack-indexing8.C: New test. * g++.dg/cpp26/pack-indexing9.C: New test. * g++.dg/cpp26/pack-indexing10.C: New test. * g++.dg/cpp26/pack-indexing11.C: New test. * g++.dg/modules/pack-index-1_a.C: New test. * g++.dg/modules/pack-index-1_b.C: New test.
2024-11-22build: Remove INCLUDE_MEMORY [PR117737]Andrew Pinski1-1/+0
Since diagnostic.h is included in over half of the sources, requiring to `#define INCLUDE_MEMORY` does not make sense. Instead lets unconditionally include memory in system.h. The majority of this patch is just removing `#define INCLUDE_MEMORY` from the sources which currently have it. This should also fix the mingw build issue but I have not tried it. Bootstrapped and tested on x86_64-linux-gnu. PR bootstrap/117737 gcc/ada/ChangeLog: * gcc-interface/misc.cc (INCLUDE_MEMORY): Remove. * gcc-interface/trans.cc (INCLUDE_MEMORY): Remove. * gcc-interface/utils.cc (INCLUDE_MEMORY): Remove. gcc/analyzer/ChangeLog: * access-diagram.cc (INCLUDE_MEMORY): Remove. * analysis-plan.cc (INCLUDE_MEMORY): Remove. * analyzer-language.cc (INCLUDE_MEMORY): Remove. * analyzer-logging.cc (INCLUDE_MEMORY): Remove. * analyzer-pass.cc (INCLUDE_MEMORY): Remove. * analyzer-selftests.cc (INCLUDE_MEMORY): Remove. * analyzer.cc (INCLUDE_MEMORY): Remove. * bar-chart.cc (INCLUDE_MEMORY): Remove. * bounds-checking.cc (INCLUDE_MEMORY): Remove. * call-details.cc (INCLUDE_MEMORY): Remove. * call-info.cc (INCLUDE_MEMORY): Remove. * call-string.cc (INCLUDE_MEMORY): Remove. * call-summary.cc (INCLUDE_MEMORY): Remove. * checker-event.cc (INCLUDE_MEMORY): Remove. * checker-path.cc (INCLUDE_MEMORY): Remove. * complexity.cc (INCLUDE_MEMORY): Remove. * constraint-manager.cc (INCLUDE_MEMORY): Remove. * diagnostic-manager.cc (INCLUDE_MEMORY): Remove. * engine.cc (INCLUDE_MEMORY): Remove. * feasible-graph.cc (INCLUDE_MEMORY): Remove. * infinite-loop.cc (INCLUDE_MEMORY): Remove. * infinite-recursion.cc (INCLUDE_MEMORY): Remove. * kf-analyzer.cc (INCLUDE_MEMORY): Remove. * kf-lang-cp.cc (INCLUDE_MEMORY): Remove. * kf.cc (INCLUDE_MEMORY): Remove. * known-function-manager.cc (INCLUDE_MEMORY): Remove. * pending-diagnostic.cc (INCLUDE_MEMORY): Remove. * program-point.cc (INCLUDE_MEMORY): Remove. * program-state.cc (INCLUDE_MEMORY): Remove. * ranges.cc (INCLUDE_MEMORY): Remove. * record-layout.cc (INCLUDE_MEMORY): Remove. * region-model-asm.cc (INCLUDE_MEMORY): Remove. * region-model-manager.cc (INCLUDE_MEMORY): Remove. * region-model-reachability.cc (INCLUDE_MEMORY): Remove. * region-model.cc (INCLUDE_MEMORY): Remove. * region.cc (INCLUDE_MEMORY): Remove. * sm-fd.cc (INCLUDE_MEMORY): Remove. * sm-file.cc (INCLUDE_MEMORY): Remove. * sm-malloc.cc (INCLUDE_MEMORY): Remove. * sm-pattern-test.cc (INCLUDE_MEMORY): Remove. * sm-sensitive.cc (INCLUDE_MEMORY): Remove. * sm-signal.cc (INCLUDE_MEMORY): Remove. * sm-taint.cc (INCLUDE_MEMORY): Remove. * sm.cc (INCLUDE_MEMORY): Remove. * state-purge.cc (INCLUDE_MEMORY): Remove. * store.cc (INCLUDE_MEMORY): Remove. * supergraph.cc (INCLUDE_MEMORY): Remove. * svalue.cc (INCLUDE_MEMORY): Remove. * symbol.cc (INCLUDE_MEMORY): Remove. * trimmed-graph.cc (INCLUDE_MEMORY): Remove. * varargs.cc (INCLUDE_MEMORY): Remove. gcc/ChangeLog: * asan.cc (INCLUDE_MEMORY): Remove. * attribs.cc (INCLUDE_MEMORY): Remove. * auto-profile.cc (INCLUDE_MEMORY): Remove. * calls.cc (INCLUDE_MEMORY): Remove. * cfganal.cc (INCLUDE_MEMORY): Remove. * cfgexpand.cc (INCLUDE_MEMORY): Remove. * cfghooks.cc (INCLUDE_MEMORY): Remove. * cfgloop.cc (INCLUDE_MEMORY): Remove. * cgraph.cc (INCLUDE_MEMORY): Remove. * cgraphclones.cc (INCLUDE_MEMORY): Remove. * cgraphunit.cc (INCLUDE_MEMORY): Remove. * collect-utils.cc (INCLUDE_MEMORY): Remove. * collect2.cc (INCLUDE_MEMORY): Remove. * common/config/aarch64/aarch64-common.cc (INCLUDE_MEMORY): Remove. * common/config/arm/arm-common.cc (INCLUDE_MEMORY): Remove. * common/config/avr/avr-common.cc (INCLUDE_MEMORY): Remove. * config/aarch64/aarch64-cc-fusion.cc (INCLUDE_MEMORY): Remove. * config/aarch64/aarch64-early-ra.cc (INCLUDE_MEMORY): Remove. * config/aarch64/aarch64-sve-builtins.cc (INCLUDE_MEMORY): Remove. * config/aarch64/aarch64.cc (INCLUDE_MEMORY): Remove. * config/arc/arc.cc (INCLUDE_MEMORY): Remove. * config/arm/aarch-common.cc (INCLUDE_MEMORY) Remove.: * config/arm/arm-mve-builtins.cc (INCLUDE_MEMORY): Remove. * config/arm/arm.cc (INCLUDE_MEMORY): Remove. * config/avr/avr-devices.cc (INCLUDE_MEMORY): Remove. * config/avr/driver-avr.cc (INCLUDE_MEMORY): Remove. * config/bpf/bpf.cc (INCLUDE_MEMORY): Remove. * config/bpf/btfext-out.cc (INCLUDE_MEMORY): Remove. * config/bpf/core-builtins.cc (INCLUDE_MEMORY): Remove. * config/darwin.cc (INCLUDE_MEMORY): Remove. * config/gcn/mkoffload.cc (INCLUDE_MEMORY): Remove. * config/i386/driver-i386.cc (INCLUDE_MEMORY): Remove. * config/i386/i386-builtins.cc (INCLUDE_MEMORY): Remove. * config/i386/i386-expand.cc (INCLUDE_MEMORY): Remove. * config/i386/i386-features.cc (INCLUDE_MEMORY): Remove. * config/i386/i386-options.cc (INCLUDE_MEMORY): Remove. * config/i386/i386.cc (INCLUDE_MEMORY): Remove. * config/loongarch/loongarch-builtins.cc (INCLUDE_MEMORY): Remove. * config/loongarch/loongarch.cc (INCLUDE_MEMORY): Remove. * config/mingw/winnt-cxx.cc (INCLUDE_MEMORY): Remove. * config/mingw/winnt.cc (INCLUDE_MEMORY): Remove. * config/mips/mips.cc (INCLUDE_MEMORY): Remove. * config/msp430/driver-msp430.cc (INCLUDE_MEMORY): Remove. * config/nvptx/mkoffload.cc (INCLUDE_MEMORY): Remove. * config/nvptx/nvptx.cc (INCLUDE_MEMORY): Remove. * config/riscv/riscv-avlprop.cc (INCLUDE_MEMORY): Remove. * config/riscv/riscv-target-attr.cc (INCLUDE_MEMORY): Remove. * config/riscv/riscv-vector-builtins.cc (INCLUDE_MEMORY): Remove. * config/riscv/riscv-vector-costs.cc (INCLUDE_MEMORY): Remove. * config/riscv/riscv-vsetvl.cc (INCLUDE_MEMORY): Remove. * config/riscv/riscv.cc (INCLUDE_MEMORY): Remove. * config/rs6000/driver-rs6000.cc (INCLUDE_MEMORY): Remove. * config/rs6000/host-darwin.cc (INCLUDE_MEMORY): Remove. * config/rs6000/rs6000-c.cc (INCLUDE_MEMORY): Remove. * config/rs6000/rs6000.cc (INCLUDE_MEMORY): Remove. * config/s390/s390-c.cc (INCLUDE_MEMORY): Remove. * config/s390/s390.cc (INCLUDE_MEMORY): Remove. * config/sol2-cxx.cc (INCLUDE_MEMORY): Remove. * config/vms/vms-c.cc (INCLUDE_MEMORY): Remove. * config/xtensa/xtensa-dynconfig.cc (INCLUDE_MEMORY): Remove. * coroutine-passes.cc (INCLUDE_MEMORY): Remove. * coverage.cc (INCLUDE_MEMORY): Remove. * data-streamer-in.cc (INCLUDE_MEMORY): Remove. * data-streamer-out.cc (INCLUDE_MEMORY): Remove. * data-streamer.cc (INCLUDE_MEMORY): Remove. * diagnostic-format-json.cc (INCLUDE_MEMORY): Remove. * diagnostic-format-sarif.cc (INCLUDE_MEMORY): Remove. * diagnostic-format-text.cc (INCLUDE_MEMORY): Remove. * diagnostic-global-context.cc (INCLUDE_MEMORY): Remove. * diagnostic-macro-unwinding.cc (INCLUDE_MEMORY): Remove. * diagnostic-path.cc (INCLUDE_MEMORY): Remove. * diagnostic-show-locus.cc (INCLUDE_MEMORY): Remove. * diagnostic-spec.cc (INCLUDE_MEMORY): Remove. * diagnostic.cc (INCLUDE_MEMORY): Remove. * diagnostic.h: Remove check for INCLUDE_MEMORY. * digraph.cc (INCLUDE_MEMORY): Remove. * dumpfile.cc (INCLUDE_MEMORY): Remove. * dwarf2out.cc (INCLUDE_MEMORY): Remove. * edit-context.cc (INCLUDE_MEMORY): Remove. * except.cc (INCLUDE_MEMORY): Remove. * expr.cc (INCLUDE_MEMORY): Remove. * file-prefix-map.cc (INCLUDE_MEMORY): Remove. * final.cc (INCLUDE_MEMORY): Remove. * fwprop.cc (INCLUDE_MEMORY): Remove. * gcc-plugin.h (INCLUDE_MEMORY): Remove. * gcc-rich-location.cc (INCLUDE_MEMORY): Remove. * gcc-urlifier.cc (INCLUDE_MEMORY): Remove. * gcc.cc (INCLUDE_MEMORY): Remove. * gcov-dump.cc (INCLUDE_MEMORY): Remove. * gcov-tool.cc (INCLUDE_MEMORY): Remove. * gcov.cc (INCLUDE_MEMORY): Remove. * gengtype.cc (open_base_files): Don't print `#define INCLUDE_MEMORY`. * genmatch.cc (INCLUDE_MEMORY): Remove. * gimple-fold.cc (INCLUDE_MEMORY): Remove. * gimple-harden-conditionals.cc (INCLUDE_MEMORY): Remove. * gimple-harden-control-flow.cc (INCLUDE_MEMORY): Remove. * gimple-if-to-switch.cc (INCLUDE_MEMORY): Remove. * gimple-loop-interchange.cc (INCLUDE_MEMORY): Remove. * gimple-loop-jam.cc (INCLUDE_MEMORY): Remove. * gimple-loop-versioning.cc (INCLUDE_MEMORY): Remove. * gimple-lower-bitint.cc (INCLUDE_MEMORY): Remove. * gimple-predicate-analysis.cc (INCLUDE_MEMORY): Remove. * gimple-pretty-print.cc (INCLUDE_MEMORY): Remove. * gimple-range-cache.cc (INCLUDE_MEMORY): Remove. * gimple-range-edge.cc (INCLUDE_MEMORY): Remove. * gimple-range-fold.cc (INCLUDE_MEMORY): Remove. * gimple-range-gori.cc (INCLUDE_MEMORY): Remove. * gimple-range-infer.cc (INCLUDE_MEMORY): Remove. * gimple-range-op.cc (INCLUDE_MEMORY): Remove. * gimple-range-path.cc (INCLUDE_MEMORY): Remove. * gimple-range-phi.cc (INCLUDE_MEMORY): Remove. * gimple-range-trace.cc (INCLUDE_MEMORY): Remove. * gimple-range.cc (INCLUDE_MEMORY): Remove. * gimple-ssa-backprop.cc (INCLUDE_MEMORY): Remove. * gimple-ssa-sprintf.cc (INCLUDE_MEMORY): Remove. * gimple-ssa-store-merging.cc (INCLUDE_MEMORY): Remove. * gimple-ssa-strength-reduction.cc (INCLUDE_MEMORY): Remove. * gimple-ssa-warn-access.cc (INCLUDE_MEMORY): Remove. * gimple-ssa-warn-alloca.cc (INCLUDE_MEMORY): Remove. * gimple-ssa-warn-restrict.cc (INCLUDE_MEMORY): Remove. * gimple-streamer-in.cc (INCLUDE_MEMORY): Remove. * gimple-streamer-out.cc (INCLUDE_MEMORY): Remove. * gimple.cc (INCLUDE_MEMORY): Remove. * gimplify.cc (INCLUDE_MEMORY): Remove. * graph.cc (INCLUDE_MEMORY): Remove. * graphite-dependences.cc (INCLUDE_MEMORY): Remove. * graphite-isl-ast-to-gimple.cc (INCLUDE_MEMORY): Remove. * graphite-optimize-isl.cc (INCLUDE_MEMORY): Remove. * graphite-poly.cc (INCLUDE_MEMORY): Remove. * graphite-scop-detection.cc (INCLUDE_MEMORY): Remove. * graphite-sese-to-poly.cc (INCLUDE_MEMORY): Remove. * graphite.cc (INCLUDE_MEMORY): Remove. * graphviz.cc (INCLUDE_MEMORY): Remove. * input.cc (INCLUDE_MEMORY): Remove. * ipa-cp.cc (INCLUDE_MEMORY): Remove. * ipa-devirt.cc (INCLUDE_MEMORY): Remove. * ipa-fnsummary.cc (INCLUDE_MEMORY): Remove. * ipa-free-lang-data.cc (INCLUDE_MEMORY): Remove. * ipa-icf-gimple.cc (INCLUDE_MEMORY): Remove. * ipa-icf.cc (INCLUDE_MEMORY): Remove. * ipa-inline-analysis.cc (INCLUDE_MEMORY): Remove. * ipa-inline.cc (INCLUDE_MEMORY): Remove. * ipa-modref-tree.cc (INCLUDE_MEMORY): Remove. * ipa-modref.cc (INCLUDE_MEMORY): Remove. * ipa-param-manipulation.cc (INCLUDE_MEMORY): Remove. * ipa-polymorphic-call.cc (INCLUDE_MEMORY): Remove. * ipa-predicate.cc (INCLUDE_MEMORY): Remove. * ipa-profile.cc (INCLUDE_MEMORY): Remove. * ipa-prop.cc (INCLUDE_MEMORY): Remove. * ipa-pure-const.cc (INCLUDE_MEMORY): Remove. * ipa-reference.cc (INCLUDE_MEMORY): Remove. * ipa-split.cc (INCLUDE_MEMORY): Remove. * ipa-sra.cc (INCLUDE_MEMORY): Remove. * ipa-strub.cc (INCLUDE_MEMORY): Remove. * ipa-utils.cc (INCLUDE_MEMORY): Remove. * json-parsing.cc (INCLUDE_MEMORY): Remove. * json.cc (INCLUDE_MEMORY): Remove. * json.h: Don't check INCLUDE_MEMORY. * langhooks.cc (INCLUDE_MEMORY): Remove. * late-combine.cc (INCLUDE_MEMORY): Remove. * lazy-diagnostic-path.cc (INCLUDE_MEMORY): Remove. * libdiagnostics.cc (INCLUDE_MEMORY): Remove. * libsarifreplay.cc (INCLUDE_MEMORY): Remove. * lto-cgraph.cc (INCLUDE_MEMORY): Remove. * lto-compress.cc (INCLUDE_MEMORY): Remove. * lto-opts.cc (INCLUDE_MEMORY): Remove. * lto-section-in.cc (INCLUDE_MEMORY): Remove. * lto-section-out.cc (INCLUDE_MEMORY): Remove. * lto-streamer-in.cc (INCLUDE_MEMORY): Remove. * lto-streamer-out.cc (INCLUDE_MEMORY): Remove. * lto-streamer.cc (INCLUDE_MEMORY): Remove. * lto-wrapper.cc (INCLUDE_MEMORY): Remove. * make-unique.h (GCC_MAKE_UNIQUE): Remove. * multiple_target.cc (INCLUDE_MEMORY): Remove. * omp-expand.cc (INCLUDE_MEMORY): Remove. * omp-general.cc (INCLUDE_MEMORY): Remove. * omp-low.cc (INCLUDE_MEMORY): Remove. * omp-oacc-neuter-broadcast.cc (INCLUDE_MEMORY): Remove. * omp-offload.cc (INCLUDE_MEMORY): Remove. * omp-simd-clone.cc (INCLUDE_MEMORY): Remove. * opt-problem.cc (INCLUDE_MEMORY): Remove. * optinfo-emit-json.cc (INCLUDE_MEMORY): Remove. * optinfo.cc (INCLUDE_MEMORY): Remove. * optinfo.h: Don't check INCLUDE_MEMORY. * opts-common.cc (INCLUDE_MEMORY): Remove. * opts-diagnostic.cc (INCLUDE_MEMORY): Remove. * opts-global.cc (INCLUDE_MEMORY): Remove. * opts.cc (INCLUDE_MEMORY): Remove. * pair-fusion.cc (INCLUDE_MEMORY): Remove. * passes.cc (INCLUDE_MEMORY): Remove. * pointer-query.cc (INCLUDE_MEMORY): Remove. * predict.cc (INCLUDE_MEMORY): Remove. * pretty-print.cc (INCLUDE_MEMORY): Remove. * pretty-print.h: Don't check INCLUDE_MEMORY. * print-rtl.cc (INCLUDE_MEMORY): Remove. * print-tree.cc (INCLUDE_MEMORY): Remove. * profile-count.cc (INCLUDE_MEMORY): Remove. * range-op-float.cc (INCLUDE_MEMORY): Remove. * range-op-ptr.cc (INCLUDE_MEMORY): Remove. * range-op.cc (INCLUDE_MEMORY): Remove. * range.cc (INCLUDE_MEMORY): Remove. * read-rtl-function.cc (INCLUDE_MEMORY): Remove. * rtl-error.cc (INCLUDE_MEMORY): Remove. * rtl-ssa/accesses.cc (INCLUDE_MEMORY): Remove. * rtl-ssa/blocks.cc (INCLUDE_MEMORY): Remove. * rtl-ssa/changes.cc (INCLUDE_MEMORY): Remove. * rtl-ssa/functions.cc (INCLUDE_MEMORY): Remove. * rtl-ssa/insns.cc (INCLUDE_MEMORY): Remove. * rtl-ssa/movement.cc (INCLUDE_MEMORY): Remove. * rtl-tests.cc (INCLUDE_MEMORY): Remove. * sanopt.cc (INCLUDE_MEMORY): Remove. * sched-rgn.cc (INCLUDE_MEMORY): Remove. * selftest-diagnostic-path.cc (INCLUDE_MEMORY): Remove. * selftest-diagnostic.cc (INCLUDE_MEMORY): Remove. * selftest-json.cc (INCLUDE_MEMORY): Remove. * sese.cc (INCLUDE_MEMORY): Remove. * simple-diagnostic-path.cc (INCLUDE_MEMORY): Remove. * splay-tree-utils.cc (INCLUDE_MEMORY): Remove. * sreal.cc (INCLUDE_MEMORY): Remove. * stmt.cc (INCLUDE_MEMORY): Remove. * substring-locations.cc (INCLUDE_MEMORY): Remove. * symtab-clones.cc (INCLUDE_MEMORY): Remove. * symtab-thunks.cc (INCLUDE_MEMORY): Remove. * symtab.cc (INCLUDE_MEMORY): Remove. * system.h: Include memory unconditionally for C++. Also remove support for INCLUDE_MEMORY. * targhooks.cc (INCLUDE_MEMORY): Remove. * text-art/box-drawing.cc (INCLUDE_MEMORY): Remove. * text-art/canvas.cc (INCLUDE_MEMORY): Remove. * text-art/ruler.cc (INCLUDE_MEMORY): Remove. * text-art/selftests.cc (INCLUDE_MEMORY): Remove. * text-art/style.cc (INCLUDE_MEMORY): Remove. * text-art/styled-string.cc (INCLUDE_MEMORY): Remove. * text-art/table.cc (INCLUDE_MEMORY): Remove. * text-art/theme.cc (INCLUDE_MEMORY): Remove. * text-art/tree-widget.cc (INCLUDE_MEMORY): Remove. * text-art/widget.cc (INCLUDE_MEMORY): Remove. * timevar.cc (INCLUDE_MEMORY): Remove. * toplev.cc (INCLUDE_MEMORY): Remove. * trans-mem.cc (INCLUDE_MEMORY): Remove. * tree-affine.cc (INCLUDE_MEMORY): Remove. * tree-assume.cc (INCLUDE_MEMORY): Remove. * tree-call-cdce.cc (INCLUDE_MEMORY): Remove. * tree-cfg.cc (INCLUDE_MEMORY): Remove. * tree-chrec.cc (INCLUDE_MEMORY): Remove. * tree-data-ref.cc (INCLUDE_MEMORY): Remove. * tree-dfa.cc (INCLUDE_MEMORY): Remove. * tree-diagnostic-client-data-hooks.cc (INCLUDE_MEMORY): Remove. * tree-diagnostic.cc (INCLUDE_MEMORY): Remove. * tree-dump.cc (INCLUDE_MEMORY): Remove. * tree-if-conv.cc (INCLUDE_MEMORY): Remove. * tree-inline.cc (INCLUDE_MEMORY): Remove. * tree-into-ssa.cc (INCLUDE_MEMORY): Remove. * tree-logical-location.cc (INCLUDE_MEMORY): Remove. * tree-loop-distribution.cc (INCLUDE_MEMORY): Remove. * tree-nested.cc (INCLUDE_MEMORY): Remove. * tree-nrv.cc (INCLUDE_MEMORY): Remove. * tree-object-size.cc (INCLUDE_MEMORY): Remove. * tree-outof-ssa.cc (INCLUDE_MEMORY): Remove. * tree-parloops.cc (INCLUDE_MEMORY): Remove. * tree-predcom.cc (INCLUDE_MEMORY): Remove. * tree-pretty-print.cc (INCLUDE_MEMORY): Remove. * tree-profile.cc (INCLUDE_MEMORY): Remove. * tree-scalar-evolution.cc (INCLUDE_MEMORY): Remove. * tree-sra.cc (INCLUDE_MEMORY): Remove. * tree-ssa-address.cc (INCLUDE_MEMORY): Remove. * tree-ssa-alias.cc (INCLUDE_MEMORY): Remove. * tree-ssa-ccp.cc (INCLUDE_MEMORY): Remove. * tree-ssa-coalesce.cc (INCLUDE_MEMORY): Remove. * tree-ssa-copy.cc (INCLUDE_MEMORY): Remove. * tree-ssa-dce.cc (INCLUDE_MEMORY): Remove. * tree-ssa-dom.cc (INCLUDE_MEMORY): Remove. * tree-ssa-dse.cc (INCLUDE_MEMORY): Remove. * tree-ssa-forwprop.cc (INCLUDE_MEMORY): Remove. * tree-ssa-ifcombine.cc (INCLUDE_MEMORY): Remove. * tree-ssa-live.cc (INCLUDE_MEMORY): Remove. * tree-ssa-loop-ch.cc (INCLUDE_MEMORY): Remove. * tree-ssa-loop-im.cc (INCLUDE_MEMORY): Remove. * tree-ssa-loop-ivcanon.cc (INCLUDE_MEMORY): Remove. * tree-ssa-loop-ivopts.cc (INCLUDE_MEMORY): Remove. * tree-ssa-loop-manip.cc (INCLUDE_MEMORY): Remove. * tree-ssa-loop-niter.cc (INCLUDE_MEMORY): Remove. * tree-ssa-loop-prefetch.cc (INCLUDE_MEMORY): Remove. * tree-ssa-loop-split.cc (INCLUDE_MEMORY): Remove. * tree-ssa-loop-unswitch.cc (INCLUDE_MEMORY): Remove. * tree-ssa-math-opts.cc (INCLUDE_MEMORY): Remove. * tree-ssa-operands.cc (INCLUDE_MEMORY): Remove. * tree-ssa-phiopt.cc (INCLUDE_MEMORY): Remove. * tree-ssa-phiprop.cc (INCLUDE_MEMORY): Remove. * tree-ssa-pre.cc (INCLUDE_MEMORY): Remove. * tree-ssa-propagate.cc (INCLUDE_MEMORY): Remove. * tree-ssa-reassoc.cc (INCLUDE_MEMORY): Remove. * tree-ssa-sccvn.cc (INCLUDE_MEMORY): Remove. * tree-ssa-scopedtables.cc (INCLUDE_MEMORY): Remove. * tree-ssa-sink.cc (INCLUDE_MEMORY): Remove. * tree-ssa-strlen.cc (INCLUDE_MEMORY): Remove. * tree-ssa-structalias.cc (INCLUDE_MEMORY): Remove. * tree-ssa-ter.cc (INCLUDE_MEMORY): Remove. * tree-ssa-threadbackward.cc (INCLUDE_MEMORY): Remove. * tree-ssa-threadupdate.cc (INCLUDE_MEMORY): Remove. * tree-ssa-uninit.cc (INCLUDE_MEMORY): Remove. * tree-ssa.cc (INCLUDE_MEMORY): Remove. * tree-ssanames.cc (INCLUDE_MEMORY): Remove. * tree-stdarg.cc (INCLUDE_MEMORY): Remove. * tree-streamer-in.cc (INCLUDE_MEMORY): Remove. * tree-streamer-out.cc (INCLUDE_MEMORY): Remove. * tree-streamer.cc (INCLUDE_MEMORY): Remove. * tree-switch-conversion.cc (INCLUDE_MEMORY): Remove. * tree-tailcall.cc (INCLUDE_MEMORY): Remove. * tree-vect-data-refs.cc (INCLUDE_MEMORY): Remove. * tree-vect-generic.cc (INCLUDE_MEMORY): Remove. * tree-vect-loop-manip.cc (INCLUDE_MEMORY): Remove. * tree-vect-loop.cc (INCLUDE_MEMORY): Remove. * tree-vect-patterns.cc (INCLUDE_MEMORY): Remove. * tree-vect-slp-patterns.cc (INCLUDE_MEMORY): Remove. * tree-vect-slp.cc (INCLUDE_MEMORY): Remove. * tree-vect-stmts.cc (INCLUDE_MEMORY): Remove. * tree-vectorizer.cc (INCLUDE_MEMORY): Remove. * tree-vrp.cc (INCLUDE_MEMORY): Remove. * tree.cc (INCLUDE_MEMORY): Remove. * ubsan.cc (INCLUDE_MEMORY): Remove. * value-pointer-equiv.cc (INCLUDE_MEMORY): Remove. * value-prof.cc (INCLUDE_MEMORY): Remove. * value-query.cc (INCLUDE_MEMORY): Remove. * value-range-pretty-print.cc (INCLUDE_MEMORY): Remove. * value-range-storage.cc (INCLUDE_MEMORY): Remove. * value-range.cc (INCLUDE_MEMORY): Remove. * value-relation.cc (INCLUDE_MEMORY): Remove. * var-tracking.cc (INCLUDE_MEMORY): Remove. * varpool.cc (INCLUDE_MEMORY): Remove. * vr-values.cc (INCLUDE_MEMORY): Remove. * wide-int-print.cc (INCLUDE_MEMORY): Remove. gcc/c-family/ChangeLog: * c-ada-spec.cc (INCLUDE_MEMORY): Remove. * c-attribs.cc (INCLUDE_MEMORY): Remove. * c-common.cc (INCLUDE_MEMORY): Remove. * c-format.cc (INCLUDE_MEMORY): Remove. * c-gimplify.cc (INCLUDE_MEMORY): Remove. * c-indentation.cc (INCLUDE_MEMORY): Remove. * c-opts.cc (INCLUDE_MEMORY): Remove. * c-pch.cc (INCLUDE_MEMORY): Remove. * c-pragma.cc (INCLUDE_MEMORY): Remove. * c-pretty-print.cc (INCLUDE_MEMORY): Remove. * c-type-mismatch.cc (INCLUDE_MEMORY): Remove. * c-warn.cc (INCLUDE_MEMORY): Remove. * known-headers.cc (INCLUDE_MEMORY): Remove. * name-hint.h: Remove check of INCLUDE_MEMORY. gcc/c/ChangeLog: * c-aux-info.cc (INCLUDE_MEMORY): Remove. * c-convert.cc (INCLUDE_MEMORY): Remove. * c-decl.cc (INCLUDE_MEMORY): Remove. * c-errors.cc (INCLUDE_MEMORY): Remove. * c-fold.cc (INCLUDE_MEMORY): Remove. * c-lang.cc (INCLUDE_MEMORY): Remove. * c-objc-common.cc (INCLUDE_MEMORY): Remove. * c-parser.cc (INCLUDE_MEMORY): Remove. * c-typeck.cc (INCLUDE_MEMORY): Remove. * gimple-parser.cc (INCLUDE_MEMORY): Remove. gcc/cp/ChangeLog: * call.cc (INCLUDE_MEMORY): Remove. * class.cc (INCLUDE_MEMORY): Remove. * constexpr.cc (INCLUDE_MEMORY): Remove. * constraint.cc (INCLUDE_MEMORY): Remove. * contracts.cc (INCLUDE_MEMORY): Remove. * coroutines.cc (INCLUDE_MEMORY): Remove. * cp-gimplify.cc (INCLUDE_MEMORY): Remove. * cp-lang.cc (INCLUDE_MEMORY): Remove. * cp-objcp-common.cc (INCLUDE_MEMORY): Remove. * cp-ubsan.cc (INCLUDE_MEMORY): Remove. * cvt.cc (INCLUDE_MEMORY): Remove. * cxx-pretty-print.cc (INCLUDE_MEMORY): Remove. * decl.cc (INCLUDE_MEMORY): Remove. * decl2.cc (INCLUDE_MEMORY): Remove. * dump.cc (INCLUDE_MEMORY): Remove. * error.cc (INCLUDE_MEMORY): Remove. * except.cc (INCLUDE_MEMORY): Remove. * expr.cc (INCLUDE_MEMORY): Remove. * friend.cc (INCLUDE_MEMORY): Remove. * init.cc (INCLUDE_MEMORY): Remove. * lambda.cc (INCLUDE_MEMORY): Remove. * lex.cc (INCLUDE_MEMORY): Remove. * logic.cc (INCLUDE_MEMORY): Remove. * mangle.cc (INCLUDE_MEMORY): Remove. * mapper-client.cc (INCLUDE_MEMORY): Remove. * mapper-resolver.cc (INCLUDE_MEMORY): Remove. * method.cc (INCLUDE_MEMORY): Remove. * module.cc (INCLUDE_MEMORY): Remove. * name-lookup.cc (INCLUDE_MEMORY): Remove. * optimize.cc (INCLUDE_MEMORY): Remove. * parser.cc (INCLUDE_MEMORY): Remove. * pt.cc (INCLUDE_MEMORY): Remove. * ptree.cc (INCLUDE_MEMORY): Remove. * rtti.cc (INCLUDE_MEMORY): Remove. * search.cc (INCLUDE_MEMORY): Remove. * semantics.cc (INCLUDE_MEMORY): Remove. * tree.cc (INCLUDE_MEMORY): Remove. * typeck.cc (INCLUDE_MEMORY): Remove. * typeck2.cc (INCLUDE_MEMORY): Remove. * vtable-class-hierarchy.cc (INCLUDE_MEMORY): Remove. gcc/d/ChangeLog: * d-attribs.cc (INCLUDE_MEMORY): Remove. * d-builtins.cc (INCLUDE_MEMORY): Remove. * d-codegen.cc (INCLUDE_MEMORY): Remove. * d-convert.cc (INCLUDE_MEMORY): Remove. * d-diagnostic.cc (INCLUDE_MEMORY): Remove. * d-frontend.cc (INCLUDE_MEMORY): Remove. * d-lang.cc (INCLUDE_MEMORY): Remove. * d-longdouble.cc (INCLUDE_MEMORY): Remove. * d-target.cc (INCLUDE_MEMORY): Remove. * decl.cc (INCLUDE_MEMORY): Remove. * expr.cc (INCLUDE_MEMORY): Remove. * intrinsics.cc (INCLUDE_MEMORY): Remove. * modules.cc (INCLUDE_MEMORY): Remove. * toir.cc (INCLUDE_MEMORY): Remove. * typeinfo.cc (INCLUDE_MEMORY): Remove. * types.cc (INCLUDE_MEMORY): Remove. gcc/fortran/ChangeLog: * arith.cc (INCLUDE_MEMORY): Remove. * array.cc (INCLUDE_MEMORY): Remove. * bbt.cc (INCLUDE_MEMORY): Remove. * check.cc (INCLUDE_MEMORY): Remove. * class.cc (INCLUDE_MEMORY): Remove. * constructor.cc (INCLUDE_MEMORY): Remove. * convert.cc (INCLUDE_MEMORY): Remove. * cpp.cc (INCLUDE_MEMORY): Remove. * data.cc (INCLUDE_MEMORY): Remove. * decl.cc (INCLUDE_MEMORY): Remove. * dependency.cc (INCLUDE_MEMORY): Remove. * dump-parse-tree.cc (INCLUDE_MEMORY): Remove. * error.cc (INCLUDE_MEMORY): Remove. * expr.cc (INCLUDE_MEMORY): Remove. * f95-lang.cc (INCLUDE_MEMORY): Remove. * frontend-passes.cc (INCLUDE_MEMORY): Remove. * interface.cc (INCLUDE_MEMORY): Remove. * intrinsic.cc (INCLUDE_MEMORY): Remove. * io.cc (INCLUDE_MEMORY): Remove. * iresolve.cc (INCLUDE_MEMORY): Remove. * match.cc (INCLUDE_MEMORY): Remove. * matchexp.cc (INCLUDE_MEMORY): Remove. * misc.cc (INCLUDE_MEMORY): Remove. * module.cc (INCLUDE_MEMORY): Remove. * openmp.cc (INCLUDE_MEMORY): Remove. * options.cc (INCLUDE_MEMORY): Remove. * parse.cc (INCLUDE_MEMORY): Remove. * primary.cc (INCLUDE_MEMORY): Remove. * resolve.cc (INCLUDE_MEMORY): Remove. * scanner.cc (INCLUDE_MEMORY): Remove. * simplify.cc (INCLUDE_MEMORY): Remove. * st.cc (INCLUDE_MEMORY): Remove. * symbol.cc (INCLUDE_MEMORY): Remove. * target-memory.cc (INCLUDE_MEMORY): Remove. * trans-array.cc (INCLUDE_MEMORY): Remove. * trans-common.cc (INCLUDE_MEMORY): Remove. * trans-const.cc (INCLUDE_MEMORY): Remove. * trans-decl.cc (INCLUDE_MEMORY): Remove. * trans-expr.cc (INCLUDE_MEMORY): Remove. * trans-intrinsic.cc (INCLUDE_MEMORY): Remove. * trans-io.cc (INCLUDE_MEMORY): Remove. * trans-openmp.cc (INCLUDE_MEMORY): Remove. * trans-stmt.cc (INCLUDE_MEMORY): Remove. * trans-types.cc (INCLUDE_MEMORY): Remove. * trans.cc (INCLUDE_MEMORY): Remove. gcc/go/ChangeLog: * go-backend.cc (INCLUDE_MEMORY): Remove. * go-lang.cc (INCLUDE_MEMORY): Remove. gcc/jit/ChangeLog: * dummy-frontend.cc (INCLUDE_MEMORY): Remove. * jit-playback.cc (INCLUDE_MEMORY): Remove. * jit-recording.cc (INCLUDE_MEMORY): Remove. gcc/lto/ChangeLog: * lto-common.cc (INCLUDE_MEMORY): Remove. * lto-dump.cc (INCLUDE_MEMORY): Remove. * lto-partition.cc (INCLUDE_MEMORY): Remove. * lto-symtab.cc (INCLUDE_MEMORY): Remove. * lto.cc (INCLUDE_MEMORY): Remove. gcc/m2/ChangeLog: * gm2-gcc/gcc-consolidation.h (INCLUDE_MEMORY): Remove. * gm2-gcc/m2configure.cc (INCLUDE_MEMORY): Remove. * mc-boot/GASCII.cc (INCLUDE_MEMORY): Remove. * mc-boot/GASCII.h (INCLUDE_MEMORY): Remove. * mc-boot/GArgs.cc (INCLUDE_MEMORY): Remove. * mc-boot/GArgs.h (INCLUDE_MEMORY): Remove. * mc-boot/GAssertion.cc (INCLUDE_MEMORY): Remove. * mc-boot/GAssertion.h (INCLUDE_MEMORY): Remove. * mc-boot/GBreak.cc (INCLUDE_MEMORY): Remove. * mc-boot/GBreak.h (INCLUDE_MEMORY): Remove. * mc-boot/GCOROUTINES.h (INCLUDE_MEMORY): Remove. * mc-boot/GCmdArgs.cc (INCLUDE_MEMORY): Remove. * mc-boot/GCmdArgs.h (INCLUDE_MEMORY): Remove. * mc-boot/GDebug.cc (INCLUDE_MEMORY): Remove. * mc-boot/GDebug.h (INCLUDE_MEMORY): Remove. Remove. * mc-boot/GDynamicStrings.cc (INCLUDE_MEMORY): Remove. * mc-boot/GDynamicStrings.h (INCLUDE_MEMORY): Remove. * mc-boot/GEnvironment.cc (INCLUDE_MEMORY): Remove. * mc-boot/GEnvironment.h (INCLUDE_MEMORY): Remove. * mc-boot/GFIO.cc (INCLUDE_MEMORY): Remove. * mc-boot/GFIO.h (INCLUDE_MEMORY): Remove. * mc-boot/GFormatStrings.cc (INCLUDE_MEMORY): Remove. * mc-boot/GFormatStrings.h (INCLUDE_MEMORY): Remove. * mc-boot/GFpuIO.cc (INCLUDE_MEMORY): Remove. * mc-boot/GFpuIO.h (INCLUDE_MEMORY): Remove. * mc-boot/GIO.cc (INCLUDE_MEMORY): Remove. * mc-boot/GIO.h (INCLUDE_MEMORY): Remove. * mc-boot/GIndexing.cc (INCLUDE_MEMORY): Remove. * mc-boot/GIndexing.h (INCLUDE_MEMORY): Remove. * mc-boot/GM2Dependent.cc (INCLUDE_MEMORY): Remove. * mc-boot/GM2Dependent.h (INCLUDE_MEMORY): Remove. * mc-boot/GM2EXCEPTION.cc (INCLUDE_MEMORY): Remove. * mc-boot/GM2EXCEPTION.h (INCLUDE_MEMORY): Remove. * mc-boot/GM2RTS.cc (INCLUDE_MEMORY): Remove. * mc-boot/GM2RTS.h (INCLUDE_MEMORY): Remove. Remove. * mc-boot/GMemUtils.cc (INCLUDE_MEMORY): Remove. * mc-boot/GMemUtils.h (INCLUDE_MEMORY): Remove. * mc-boot/GNumberIO.cc (INCLUDE_MEMORY): Remove. * mc-boot/GNumberIO.h (INCLUDE_MEMORY): Remove. * mc-boot/GPushBackInput.cc (INCLUDE_MEMORY): Remove. * mc-boot/GPushBackInput.h (INCLUDE_MEMORY): Remove. * mc-boot/GRTExceptions.cc (INCLUDE_MEMORY): Remove. * mc-boot/GRTExceptions.h (INCLUDE_MEMORY): Remove. * mc-boot/GRTco.h (INCLUDE_MEMORY): Remove. * mc-boot/GRTentity.h (INCLUDE_MEMORY): Remove. * mc-boot/GRTint.cc (INCLUDE_MEMORY): Remove. * mc-boot/GRTint.h (INCLUDE_MEMORY): Remove. * mc-boot/GSArgs.cc (INCLUDE_MEMORY): Remove. * mc-boot/GSArgs.h (INCLUDE_MEMORY): Remove. * mc-boot/GSFIO.cc (INCLUDE_MEMORY): Remove. * mc-boot/GSFIO.h (INCLUDE_MEMORY): Remove. * mc-boot/GSYSTEM.h (INCLUDE_MEMORY): Remove. * mc-boot/GSelective.h (INCLUDE_MEMORY): Remove. * mc-boot/GStdIO.cc (INCLUDE_MEMORY): Remove. * mc-boot/GStdIO.h (INCLUDE_MEMORY): Remove. * mc-boot/GStorage.cc (INCLUDE_MEMORY): Remove. * mc-boot/GStorage.h (INCLUDE_MEMORY): Remove. * mc-boot/GStrCase.cc (INCLUDE_MEMORY): Remove. * mc-boot/GStrCase.h (INCLUDE_MEMORY): Remove. * mc-boot/GStrIO.cc (INCLUDE_MEMORY): Remove. * mc-boot/GStrIO.h (INCLUDE_MEMORY): Remove. * mc-boot/GStrLib.cc (INCLUDE_MEMORY): Remove. * mc-boot/GStrLib.h (INCLUDE_MEMORY): Remove. * mc-boot/GStringConvert.cc (INCLUDE_MEMORY): Remove. * mc-boot/GStringConvert.h (INCLUDE_MEMORY): Remove. * mc-boot/GSysExceptions.h (INCLUDE_MEMORY): Remove. * mc-boot/GSysStorage.cc (INCLUDE_MEMORY): Remove. * mc-boot/GSysStorage.h (INCLUDE_MEMORY): Remove. * mc-boot/GTimeString.cc (INCLUDE_MEMORY): Remove. * mc-boot/GTimeString.h (INCLUDE_MEMORY): Remove. * mc-boot/GUnixArgs.h (INCLUDE_MEMORY): Remove. * mc-boot/Galists.cc (INCLUDE_MEMORY): Remove. * mc-boot/Galists.h (INCLUDE_MEMORY): Remove. * mc-boot/Gdecl.cc (INCLUDE_MEMORY): Remove. * mc-boot/Gdecl.h (INCLUDE_MEMORY): Remove. * mc-boot/Gdtoa.h (INCLUDE_MEMORY): Remove. * mc-boot/Gerrno.h (INCLUDE_MEMORY): Remove. * mc-boot/Gkeyc.cc (INCLUDE_MEMORY): Remove. (checkGccConfigSystem): Remove printing out `#define INCLUDE_MEMORY`. * mc-boot/Gkeyc.h (INCLUDE_MEMORY): Remove. * mc-boot/Gldtoa.h (INCLUDE_MEMORY): Remove. * mc-boot/Glibc.h (INCLUDE_MEMORY): Remove. * mc-boot/Glibm.h (INCLUDE_MEMORY): Remove. * mc-boot/Glists.cc (INCLUDE_MEMORY): Remove. * mc-boot/Glists.h (INCLUDE_MEMORY): Remove. * mc-boot/GmcComment.cc (INCLUDE_MEMORY): Remove. * mc-boot/GmcComment.h (INCLUDE_MEMORY): Remove. * mc-boot/GmcComp.cc (INCLUDE_MEMORY): Remove. * mc-boot/GmcComp.h (INCLUDE_MEMORY): Remove. * mc-boot/GmcDebug.cc (INCLUDE_MEMORY): Remove. * mc-boot/GmcDebug.h (INCLUDE_MEMORY): Remove. * mc-boot/GmcError.cc (INCLUDE_MEMORY): Remove. * mc-boot/GmcError.h (INCLUDE_MEMORY): Remove. * mc-boot/GmcFileName.cc (INCLUDE_MEMORY): Remove. * mc-boot/GmcFileName.h (INCLUDE_MEMORY): Remove. * mc-boot/GmcLexBuf.cc (INCLUDE_MEMORY): Remove. * mc-boot/GmcLexBuf.h (INCLUDE_MEMORY): Remove. * mc-boot/GmcMetaError.cc (INCLUDE_MEMORY): Remove. * mc-boot/GmcMetaError.h (INCLUDE_MEMORY): Remove. * mc-boot/GmcOptions.cc (INCLUDE_MEMORY): Remove. * mc-boot/GmcOptions.h (INCLUDE_MEMORY): Remove. * mc-boot/GmcPreprocess.cc (INCLUDE_MEMORY): Remove. * mc-boot/GmcPreprocess.h (INCLUDE_MEMORY): Remove. * mc-boot/GmcPretty.cc (INCLUDE_MEMORY): Remove. * mc-boot/GmcPretty.h (INCLUDE_MEMORY): Remove. * mc-boot/GmcPrintf.cc (INCLUDE_MEMORY): Remove. * mc-boot/GmcPrintf.h (INCLUDE_MEMORY): Remove. * mc-boot/GmcQuiet.cc (INCLUDE_MEMORY): Remove. * mc-boot/GmcQuiet.h (INCLUDE_MEMORY): Remove. * mc-boot/GmcReserved.cc (INCLUDE_MEMORY): Remove. * mc-boot/GmcReserved.h (INCLUDE_MEMORY): Remove. * mc-boot/GmcSearch.cc (INCLUDE_MEMORY): Remove. * mc-boot/GmcSearch.h (INCLUDE_MEMORY): Remove. * mc-boot/GmcStack.cc (INCLUDE_MEMORY): Remove. * mc-boot/GmcStack.h (INCLUDE_MEMORY): Remove. * mc-boot/GmcStream.cc (INCLUDE_MEMORY): Remove. * mc-boot/GmcStream.h (INCLUDE_MEMORY): Remove. * mc-boot/Gmcflex.h (INCLUDE_MEMORY): Remove. * mc-boot/Gmcp1.cc (INCLUDE_MEMORY): Remove. * mc-boot/Gmcp1.h (INCLUDE_MEMORY): Remove. * mc-boot/Gmcp2.cc (INCLUDE_MEMORY): Remove. * mc-boot/Gmcp2.h (INCLUDE_MEMORY): Remove. * mc-boot/Gmcp3.cc (INCLUDE_MEMORY): Remove. * mc-boot/Gmcp3.h (INCLUDE_MEMORY): Remove. * mc-boot/Gmcp4.cc (INCLUDE_MEMORY): Remove. * mc-boot/Gmcp4.h (INCLUDE_MEMORY): Remove. * mc-boot/Gmcp5.cc (INCLUDE_MEMORY): Remove. * mc-boot/Gmcp5.h (INCLUDE_MEMORY): Remove. * mc-boot/GnameKey.cc (INCLUDE_MEMORY): Remove. * mc-boot/GnameKey.h (INCLUDE_MEMORY): Remove. * mc-boot/GsymbolKey.cc (INCLUDE_MEMORY): Remove. * mc-boot/GsymbolKey.h (INCLUDE_MEMORY): Remove. * mc-boot/Gtermios.h (INCLUDE_MEMORY): Remove. * mc-boot/Gtop.cc (INCLUDE_MEMORY): Remove. * mc-boot/Gvarargs.cc (INCLUDE_MEMORY): Remove. * mc-boot/Gvarargs.h (INCLUDE_MEMORY): Remove. * mc-boot/Gwlists.cc (INCLUDE_MEMORY): Remove. * mc-boot/Gwlists.h (INCLUDE_MEMORY): Remove. * mc-boot/Gwrapc.h (INCLUDE_MEMORY): Remove. * pge-boot/GIndexing.h (INCLUDE_MEMORY): Remove. * pge-boot/GSEnvironment.h (INCLUDE_MEMORY): Remove. * pge-boot/GScan.h (INCLUDE_MEMORY): Remove. gcc/objc/ChangeLog: * objc-act.cc (INCLUDE_MEMORY): Remove. * objc-encoding.cc (INCLUDE_MEMORY): Remove. * objc-gnu-runtime-abi-01.cc (INCLUDE_MEMORY): Remove. * objc-lang.cc (INCLUDE_MEMORY): Remove. * objc-next-runtime-abi-01.cc (INCLUDE_MEMORY): Remove. * objc-next-runtime-abi-02.cc (INCLUDE_MEMORY): Remove. * objc-runtime-shared-support.cc (INCLUDE_MEMORY): Remove. gcc/objcp/ChangeLog: * objcp-decl.cc (INCLUDE_MEMORY): Remove. * objcp-lang.cc (INCLUDE_MEMORY): Remove. gcc/rust/ChangeLog: * resolve/rust-ast-resolve-expr.cc (INCLUDE_MEMORY): Remove. * rust-attribs.cc (INCLUDE_MEMORY): Remove. * rust-system.h (INCLUDE_MEMORY): Remove. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2024-10-29diagnostics: support multiple output formats simultaneously [PR116613]David Malcolm1-9/+4
This patch generalizes diagnostic_context so that rather than having a single output format, it has a vector of zero or more. It adds new two options: -fdiagnostics-add-output=DIAGNOSTICS-OUTPUT-SPEC -fdiagnostics-set-output=DIAGNOSTICS-OUTPUT-SPEC which both take a new configuration syntax of the form SCHEME ("text" or "sarif"), optionally followed by ":" and one or more KEY=VALUE pairs, in this form: <SCHEME> <SCHEME>:<KEY>=<VALUE> <SCHEME>:<KEY>=<VALUE>,<KEY2>=<VALUE2> ...etc where each SCHEME supports some set of keys. For example, it's now possible to use: -fdiagnostics-add-output=sarif:version=2.1,file=foo.2.1.sarif \ -fdiagnostics-add-output=sarif:version=2.2-prerelease,file=foo.2.2.sarif to add a pair of outputs, each writing to a different file, using versions 2.1 and 2.2 of the SARIF standard respectively, whilst also emitting the classic text form of the diagnostics to stderr. I hope the new syntax gives us room to potentially add new kinds of output sink in the future (e.g. RPC notifications), and to add new key/value pairs as needed by the different sinks. Implementation-wise, the diagnostic_context's m_printer which previously was used directly by the single output format now becomes a "reference printer", created by the client (such as the frontend), with defaults modified by command-line options. Each of the multiple output sinks has its own pretty_printer instance, created by cloning the context's reference printer. gcc/ChangeLog: PR other/116613 * Makefile.in (OBJS-libcommon-target): Add opts-diagnostic.o. * common.opt (fdiagnostics-add-output=): New. (fdiagnostics-set-output=): New. (diagnostics_output_format): Drop sarif-file-2.2-prerelease from enum. * common.opt.urls: Regenerate. * diagnostic-buffer.h (diagnostic_buffer::~diagnostic_buffer): New. (diagnostic_buffer::ensure_per_format_buffer): Rename to... (diagnostic_buffer::ensure_per_format_buffers): ...this. (diagnostic_buffer::m_per_format_buffer): Replace with... (diagnostic_buffer::m_per_format_buffers): ...this, updating type. * diagnostic-format-json.cc (json_output_format::update_printer): New. (json_output_format::follows_reference_printer_p): New. (diagnostic_output_format_init_json): Drop redundant call to set_path_format, as this is not a text output format. * diagnostic-format-sarif.cc: Include "diagnostic-format-text.h". (sarif_builder::set_printer): New. (sarif_builder::sarif_builder): Add "printer" param and use it for m_printer. (sarif_builder::make_location_object::escape_nonascii_renderer::render): Rather than using dc.m_printer, create a diagnostic_text_output_format instance and use its printer. (sarif_output_format::follows_reference_printer_p): New. (sarif_output_format::update_printer): New. (sarif_output_format::sarif_output_format): Pass in correct printer to m_builder's ctor. (diagnostic_output_format_init_sarif): Drop redundant call to set_path_format, as this is not a text output format. Replace calls to pp_show_color and set_token_printer with call to update_printer. Drop redundant call to set_show_highlight_colors, as this printer does not show colors. (diagnostic_output_format_init_sarif_file): Split out file opening into... (diagnostic_output_format_open_sarif_file): ...this new function. (make_sarif_sink): New. (selftest::test_make_location_object): Provide a pp for the builder. * diagnostic-format-sarif.h (diagnostic_output_format_open_sarif_file): New decl. (make_sarif_sink): New decl. * diagnostic-format-text.cc (diagnostic_text_output_format::dump): Dump sm_follows_reference_printer. (diagnostic_text_output_format::on_report_verbatim): New. (diagnostic_text_output_format::follows_reference_printer_p): New. (diagnostic_text_output_format::update_printer): New. * diagnostic-format-text.h (diagnostic_text_output_format::diagnostic_text_output_format): Add optional "follows_reference_printer" param. (diagnostic_text_output_format::on_report_verbatim): New decl. (diagnostic_text_output_format::after_diagnostic): Drop "final". (diagnostic_text_output_format::follows_reference_printer_p): New decl. (class diagnostic_text_output_format): Convert private members to protected. (diagnostic_text_output_format::m_follows_reference_printer): New field. * diagnostic-format.h (diagnostic_output_format::on_report_verbatim): New vfunc. (diagnostic_output_format::follows_reference_printer_p): New vfunc. (diagnostic_output_format::update_printer): New vfunc. (diagnostic_output_format::get_printer): Use m_printer rather than a printer from m_context. (diagnostic_output_format::diagnostic_output_format): Initialize m_printer by cloning the context's printer. (diagnostic_output_format::m_printer): New field. * diagnostic-global-context.cc (verbatim): Reimplement in terms of global_dc->report_verbatim, moving existing implementation to diagnostic_text_output_format::on_report_verbatim. (fnotice): Support multiple output sinks by using a new global_dc->supports_fnotice_on_stderr_p. * diagnostic-output-file.h (diagnostic_output_file::diagnostic_output_file): New default ctor. (diagnostic_output_file::operator=): Implement move assignment. * diagnostic-path.cc (selftest::test_interprocedural_path_1): Pass false for new param of text_output's ctor. * diagnostic-show-locus.cc (selftest::test_layout_x_offset_display_utf8): Use reference printer. (selftest::test_layout_x_offset_display_tab): Likewise. (selftest::test_one_liner_fixit_remove): Likewise. * diagnostic.cc: Include "pretty-print-urlifier.h". (diagnostic_set_caret_max_width): Update for global_dc's m_printer becoming reference printer. (diagnostic_context::initialize): Update for m_printer becoming m_reference_printer. Use ::make_unique to create it. Update for m_output_format becoming m_output_sinks. (diagnostic_context::color_init): Update the reference printer, then update the printers for any output sinks that follow it. (diagnostic_context::urls_init): Likewise. (diagnostic_context::finish): Update comment. Update for m_output_format becoming m_output_sinks. Update for m_printer becoming m_reference_printer and use "delete" on it rather than XDELETE. (diagnostic_context::dump): Update for m_printer becoming reference printer, and for multiple output sinks. (diagnostic_context::set_output_format): Reimplement for supporting multiple output sinks. (diagnostic_context::get_output_format): Likewise. (diagnostic_context::add_sink): New. (diagnostic_context::supports_fnotice_on_stderr_p): New. (diagnostic_context::set_pretty_printer): New. (diagnostic_context::refresh_output_sinks): New. (diagnostic_context::set_format_decoder): New. (diagnostic_context::set_show_highlight_colors): New. (diagnostic_context::set_prefixing_rule): New. (diagnostic_context::report_diagnostic): Update to support multiple output sinks. (diagnostic_context::report_verbatim): New. (diagnostic_context::emit_diagram): Update to support multiple output sinks. (diagnostic_context::error_recursion): Update to use m_reference_printer. (fancy_abort): Likewise. (diagnostic_context::end_group): Update to support multiple output sinks. (diagnostic_output_format::dump): Implement. (diagnostic_output_format::on_report_verbatim): Likewise. (diagnostic_output_format_init): Drop DIAGNOSTICS_OUTPUT_FORMAT_SARIF_FILE_2_2_PRERELEASE. (diagnostic_context::set_diagnostic_buffer): Reimplement to support multiple output sinks. (diagnostic_context::clear_diagnostic_buffer): Likewise. (diagnostic_context::flush_diagnostic_buffer): Likewise. (diagnostic_buffer::diagnostic_buffer): Initialize m_per_format_buffers. (diagnostic_buffer::~diagnostic_buffer): New dtor. (diagnostic_buffer::dump): Reimplement to support multiple output sinks. (diagnostic_buffer::empty_p): Likewise. (diagnostic_buffer::move_to): Likewise. (diagnostic_buffer::ensure_per_format_buffer): Likewise, renaming to... (diagnostic_buffer::ensure_per_format_buffers): ...this. * diagnostic.h (DIAGNOSTICS_OUTPUT_FORMAT_SARIF_FILE_2_2_PRERELEASE): Delete. (class diagnostic_context): Add friend class diagnostic_buffer. (diagnostic_context::set_pretty_printer): New decl. (diagnostic_context::refresh_output_sinks): New decl. (diagnostic_context::report_verbatim): New decl. (diagnostic_context::get_output_format): Drop. (diagnostic_context::set_show_highlight_colors): Drop body. (diagnostic_context::set_format_decoder): New decl. (diagnostic_context::set_prefixing_rule): New decl. (diagnostic_context::clone_printer): Reimplement. (diagnostic_context::get_reference_printer): New accessor. (diagnostic_context::add_sink): New decl. (diagnostic_context::supports_fnotice_on_stderr_p): New decl. (diagnostic_context::m_printer): Replace with... (diagnostic_context::m_reference_printer): ...this, and make private. (diagnostic_context::m_output_format): Replace with... (diagnostic_context::m_output_sinks): ...this. (diagnostic_format_decoder): Delete. (diagnostic_prefixing_rule): Delete. (diagnostic_ready_p): Delete. * doc/invoke.texi: Document -fdiagnostics-add-output= and -fdiagnostics-set-output=. * gcc.cc: Include "opts-diagnostic.h". (driver_handle_option): Handle cases OPT_fdiagnostics_add_output_ and OPT_fdiagnostics_set_output_. * opts-diagnostic.cc: New file. * opts-diagnostic.h (handle_OPT_fdiagnostics_add_output_): New decl. (handle_OPT_fdiagnostics_set_output_): New decl. * opts-global.cc (init_options_once): Update for global_dc's m_printer becoming reference printer. Call global_dc->refresh_output_sinks. * opts.cc (common_handle_option): Replace use of diagnostic_prefixing_rule with dc->set_prefixing_rule. Handle cases OPT_fdiagnostics_add_output_ and OPT_fdiagnostics_set_output_. Update for m_printer becoming reference printer. * selftest-diagnostic.cc (selftest::test_diagnostic_context::test_diagnostic_context): Update for m_printer becoming reference printer. (test_diagnostic_context::test_show_locus): Likewise. * selftest-run-tests.cc (selftest::run_tests): Call selftest::opts_diagnostic_cc_tests. * selftest.h (selftest::opts_diagnostic_cc_tests): New decl. * simple-diagnostic-path.cc (selftest::simple_diagnostic_path_cc_tests): Use reference printer. * toplev.cc (announce_function): Update for global_dc's m_printer becoming reference printer. (toplev::main): Likewise. * tree-diagnostic.cc (tree_diagnostics_defaults): Replace use of diagnostic_format_decoder with context->set_format_decoder. * tree-diagnostic.h (tree_dump_pretty_printer::tree_dump_pretty_printer): Update for global_dc's m_printer becoming reference printer. * tree.cc (escaped_string::escape): Likewise. (selftest::test_escaped_strings): Likewise. gcc/ada/ChangeLog: PR other/116613 * gcc-interface/misc.cc (internal_error_function): Update for m_printer becoming reference printer. gcc/analyzer/ChangeLog: PR other/116613 * analyzer-language.cc (on_finish_translation_unit): Update for m_printer becoming reference printer. * engine.cc (run_checkers): Likewise. * program-point.cc (function_point::print_source_line): Likewise. gcc/c-family/ChangeLog: PR other/116613 * c-format.cc (selftest::test_type_mismatch_range_labels): Update for m_printer becoming reference printer. (selftest::test_type_mismatch_range_labels): Likewise. gcc/c/ChangeLog: PR other/116613 * c-objc-common.cc: Include "make-unique.h". (c_initialize_diagnostics): Use unique_ptr for pretty_printer. Use context->set_format_decoder. gcc/cp/ChangeLog: PR other/116613 * error.cc (cxx_initialize_diagnostics): Use unique_ptr for pretty_printer. Use context->set_format_decoder. * module.cc (noisy_p): Update for global_dc's m_printer becoming reference printer. gcc/d/ChangeLog: PR other/116613 * d-diagnostic.cc (d_diagnostic_report_diagnostic): Update for m_printer becoming reference printer. gcc/fortran/ChangeLog: PR other/116613 * error.cc (gfc_diagnostic_build_kind_prefix): Update for global_dc's m_printer becoming reference printer. (gfc_diagnostics_init): Replace usage of diagnostic_format_decoder with global_dc->set_format_decoder. gcc/jit/ChangeLog: PR other/116613 * dummy-frontend.cc: Include "make-unique.h". (class jit_diagnostic_listener): New. (jit_begin_diagnostic): Update comment. (jit_end_diagnostic): Drop call to add_diagnostic. (jit_langhook_init): Set the output format to a new jit_diagnostic_listener. * jit-playback.cc (playback::context::add_diagnostic): Add "text" param and use that rather than trying to get the text from a pretty_printer. * jit-playback.h (playback::context::add_diagnostic): Add "text" param. gcc/testsuite/ChangeLog: PR other/116613 * gcc.dg/plugin/analyzer_cpython_plugin.c (dump_refcnt_info): Update for global_dc's m_printer becoming reference printer. * gcc.dg/plugin/crash-test-ice-in-header-sarif-2.2.c: Replace usage of -fdiagnostics-format=sarif-file-2.2-prerelease with -fdiagnostics-set-output=sarif:version=2.2-prerelease. * gcc.dg/plugin/diagnostic_plugin_test_paths.c: Update for global_dc's m_printer becoming reference printer. * gcc.dg/plugin/diagnostic_plugin_xhtml_format.c: Update for changes to output formats. * gcc.dg/plugin/expensive_selftests_plugin.c: Update for global_dc's m_printer becoming reference printer. * gcc.dg/sarif-output/add-output-sarif-defaults.c: New test. * gcc.dg/sarif-output/bad-binary-op.c: New test. * gcc.dg/sarif-output/bad-binary-op.py: New support script. * gcc.dg/sarif-output/multiple-outputs.c: New test. * gcc.dg/sarif-output/multiple-outputs.py: New support script. * lib/scansarif.exp (verify-sarif-file): Add an optional second argument specifying the expected filename of the .sarif file. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-10-29c++: printing AGGR_INIT_EXPR argsJason Merrill1-61/+18
PR30854 was about wrongly dumping the dummy object argument to a constructor; r126582 in 4.3 fixed that by skipping the first argument. But not all functions called by AGGR_INIT_EXPR are constructors, as observed in PR116634; we shouldn't skip for non-member functions. And let's combine the printing code for CALL_EXPR and AGGR_INIT_EXPR. This doesn't make us accept the ill-formed 116634 testcase again with a pedwarn, just fixes the diagnostic issue. PR c++/30854 PR c++/116634 gcc/cp/ChangeLog: * error.cc (dump_aggr_init_expr_args): Remove. (dump_call_expr_args): Handle AGGR_INIT_EXPR. (dump_expr): Combine AGGR_INIT_EXPR and CALL_EXPR cases. gcc/testsuite/ChangeLog: * g++.dg/coroutines/coro-bad-alloc-02-no-op-new-nt.C: Adjust diagnostic. * g++.dg/diagnostic/aggr-init1.C: New test.
2024-10-25gcc: Remove trailing whitespaceJakub Jelinek1-10/+10
I've tried to build stage3 with -Wleading-whitespace=blanks -Wtrailing-whitespace=blank -Wno-error=leading-whitespace=blanks -Wno-error=trailing-whitespace=blank added to STRICT_WARN and that expectably resulted in about 2744 unique trailing whitespace warnings and 124837 leading whitespace warnings when excluding *.md files (which obviously is in big part a generator issue). Others from that are generator related, I think those need to be solved later. The following patch just fixes up the easy case (trailing whitespace), which could be easily automated: for i in `find . -name \*.h -o -name \*.cc -o -name \*.c | xargs grep -l '[ ]$' | grep -v testsuite/`; do sed -i -e 's/[ ]*$//' $i; done I've excluded files which I knew are obviously generated or go FE. Is there anything else we'd want to avoid the changes? Due to patch size, I've split it between gcc/ part (this patch) and rest (include/, libiberty/, libgcc/, libcpp/, libstdc++-v3/). 2024-10-24 Jakub Jelinek <jakub@redhat.com> gcc/ * lra-assigns.cc: Remove trailing whitespace. * symtab.cc: Likewise. * stmt.cc: Likewise. * cgraphbuild.cc: Likewise. * cfgcleanup.cc: Likewise. * loop-init.cc: Likewise. * df-problems.cc: Likewise. * diagnostic-macro-unwinding.cc: Likewise. * langhooks.h: Likewise. * except.cc: Likewise. * tree-vect-loop.cc: Likewise. * coverage.cc: Likewise. * hash-table.cc: Likewise. * ggc-page.cc: Likewise. * gimple-ssa-strength-reduction.cc: Likewise. * tree-parloops.cc: Likewise. * internal-fn.cc: Likewise. * ipa-split.cc: Likewise. * calls.cc: Likewise. * reorg.cc: Likewise. * sbitmap.h: Likewise. * omp-offload.cc: Likewise. * cfgrtl.cc: Likewise. * reginfo.cc: Likewise. * gengtype.h: Likewise. * omp-general.h: Likewise. * ipa-comdats.cc: Likewise. * gimple-range-edge.h: Likewise. * tree-ssa-structalias.cc: Likewise. * target.def: Likewise. * basic-block.h: Likewise. * graphite-isl-ast-to-gimple.cc: Likewise. * auto-profile.cc: Likewise. * optabs.cc: Likewise. * gengtype-lex.l: Likewise. * optabs.def: Likewise. * ira-build.cc: Likewise. * ira.cc: Likewise. * function.h: Likewise. * tree-ssa-propagate.cc: Likewise. * gcov-io.cc: Likewise. * builtin-types.def: Likewise. * ddg.cc: Likewise. * lra-spills.cc: Likewise. * cfg.cc: Likewise. * bitmap.cc: Likewise. * gimple-range-gori.h: Likewise. * tree-ssa-loop-im.cc: Likewise. * cfghooks.h: Likewise. * genmatch.cc: Likewise. * explow.cc: Likewise. * lto-streamer-in.cc: Likewise. * graphite-scop-detection.cc: Likewise. * ipa-prop.cc: Likewise. * gcc.cc: Likewise. * vec.h: Likewise. * cfgexpand.cc: Likewise. * config/alpha/vms.h: Likewise. * config/alpha/alpha.cc: Likewise. * config/alpha/driver-alpha.cc: Likewise. * config/alpha/elf.h: Likewise. * config/iq2000/iq2000.h: Likewise. * config/iq2000/iq2000.cc: Likewise. * config/pa/pa-64.h: Likewise. * config/pa/som.h: Likewise. * config/pa/pa.cc: Likewise. * config/pa/pa.h: Likewise. * config/pa/pa32-regs.h: Likewise. * config/c6x/c6x.cc: Likewise. * config/openbsd-stdint.h: Likewise. * config/elfos.h: Likewise. * config/lm32/lm32.cc: Likewise. * config/lm32/lm32.h: Likewise. * config/lm32/lm32-protos.h: Likewise. * config/darwin-c.cc: Likewise. * config/rx/rx.cc: Likewise. * config/host-darwin.h: Likewise. * config/netbsd.h: Likewise. * config/ia64/ia64.cc: Likewise. * config/ia64/freebsd.h: Likewise. * config/avr/avr-c.cc: Likewise. * config/avr/avr.cc: Likewise. * config/avr/avr-arch.h: Likewise. * config/avr/avr.h: Likewise. * config/avr/stdfix.h: Likewise. * config/avr/gen-avr-mmcu-specs.cc: Likewise. * config/avr/avr-log.cc: Likewise. * config/avr/elf.h: Likewise. * config/avr/gen-avr-mmcu-texi.cc: Likewise. * config/avr/avr-devices.cc: Likewise. * config/nvptx/nvptx.cc: Likewise. * config/vx-common.h: Likewise. * config/sol2.cc: Likewise. * config/rl78/rl78.cc: Likewise. * config/cris/cris.cc: Likewise. * config/arm/symbian.h: Likewise. * config/arm/unknown-elf.h: Likewise. * config/arm/linux-eabi.h: Likewise. * config/arm/arm.cc: Likewise. * config/arm/arm-mve-builtins.h: Likewise. * config/arm/bpabi.h: Likewise. * config/arm/vxworks.h: Likewise. * config/arm/arm.h: Likewise. * config/arm/aout.h: Likewise. * config/arm/elf.h: Likewise. * config/host-linux.cc: Likewise. * config/sh/sh_treg_combine.cc: Likewise. * config/sh/vxworks.h: Likewise. * config/sh/elf.h: Likewise. * config/sh/netbsd-elf.h: Likewise. * config/sh/sh.cc: Likewise. * config/sh/embed-elf.h: Likewise. * config/sh/sh.h: Likewise. * config/darwin-driver.cc: Likewise. * config/m32c/m32c.cc: Likewise. * config/frv/frv.cc: Likewise. * config/openbsd.h: Likewise. * config/aarch64/aarch64-protos.h: Likewise. * config/aarch64/aarch64-builtins.cc: Likewise. * config/aarch64/aarch64-cost-tables.h: Likewise. * config/aarch64/aarch64.cc: Likewise. * config/bfin/bfin.cc: Likewise. * config/bfin/bfin.h: Likewise. * config/bfin/bfin-protos.h: Likewise. * config/i386/gmm_malloc.h: Likewise. * config/i386/djgpp.h: Likewise. * config/i386/sol2.h: Likewise. * config/i386/stringop.def: Likewise. * config/i386/i386-features.cc: Likewise. * config/i386/openbsdelf.h: Likewise. * config/i386/cpuid.h: Likewise. * config/i386/i386.h: Likewise. * config/i386/smmintrin.h: Likewise. * config/i386/avx10_2-512convertintrin.h: Likewise. * config/i386/i386-options.cc: Likewise. * config/i386/i386-opts.h: Likewise. * config/i386/i386-expand.cc: Likewise. * config/i386/avx512dqintrin.h: Likewise. * config/i386/wmmintrin.h: Likewise. * config/i386/gnu-user.h: Likewise. * config/i386/host-mingw32.cc: Likewise. * config/i386/avx10_2bf16intrin.h: Likewise. * config/i386/cygwin.h: Likewise. * config/i386/driver-i386.cc: Likewise. * config/i386/biarch64.h: Likewise. * config/i386/host-cygwin.cc: Likewise. * config/i386/cygming.h: Likewise. * config/i386/i386-builtins.cc: Likewise. * config/i386/avx10_2convertintrin.h: Likewise. * config/i386/i386.cc: Likewise. * config/i386/gas.h: Likewise. * config/i386/freebsd.h: Likewise. * config/mingw/winnt-cxx.cc: Likewise. * config/mingw/winnt.cc: Likewise. * config/h8300/h8300.cc: Likewise. * config/host-solaris.cc: Likewise. * config/m32r/m32r.h: Likewise. * config/m32r/m32r.cc: Likewise. * config/darwin.h: Likewise. * config/sparc/linux64.h: Likewise. * config/sparc/sparc-protos.h: Likewise. * config/sparc/sysv4.h: Likewise. * config/sparc/sparc.h: Likewise. * config/sparc/linux.h: Likewise. * config/sparc/freebsd.h: Likewise. * config/sparc/sparc.cc: Likewise. * config/gcn/gcn-run.cc: Likewise. * config/gcn/gcn.cc: Likewise. * config/gcn/gcn-tree.cc: Likewise. * config/kopensolaris-gnu.h: Likewise. * config/nios2/nios2.h: Likewise. * config/nios2/elf.h: Likewise. * config/nios2/nios2.cc: Likewise. * config/host-netbsd.cc: Likewise. * config/rtems.h: Likewise. * config/pdp11/pdp11.cc: Likewise. * config/pdp11/pdp11.h: Likewise. * config/mn10300/mn10300.cc: Likewise. * config/mn10300/linux.h: Likewise. * config/moxie/moxie.h: Likewise. * config/moxie/moxie.cc: Likewise. * config/rs6000/aix71.h: Likewise. * config/rs6000/vec_types.h: Likewise. * config/rs6000/xcoff.h: Likewise. * config/rs6000/rs6000.cc: Likewise. * config/rs6000/rs6000-internal.h: Likewise. * config/rs6000/rs6000-p8swap.cc: Likewise. * config/rs6000/rs6000-c.cc: Likewise. * config/rs6000/aix.h: Likewise. * config/rs6000/rs6000-logue.cc: Likewise. * config/rs6000/rs6000-string.cc: Likewise. * config/rs6000/rs6000-call.cc: Likewise. * config/rs6000/ppu_intrinsics.h: Likewise. * config/rs6000/altivec.h: Likewise. * config/rs6000/darwin.h: Likewise. * config/rs6000/host-darwin.cc: Likewise. * config/rs6000/freebsd64.h: Likewise. * config/rs6000/spu2vmx.h: Likewise. * config/rs6000/linux.h: Likewise. * config/rs6000/si2vmx.h: Likewise. * config/rs6000/driver-rs6000.cc: Likewise. * config/rs6000/freebsd.h: Likewise. * config/vxworksae.h: Likewise. * config/mips/frame-header-opt.cc: Likewise. * config/mips/mips.h: Likewise. * config/mips/mips.cc: Likewise. * config/mips/sde.h: Likewise. * config/darwin-protos.h: Likewise. * config/mcore/mcore-elf.h: Likewise. * config/mcore/mcore.h: Likewise. * config/mcore/mcore.cc: Likewise. * config/epiphany/epiphany.cc: Likewise. * config/fr30/fr30.h: Likewise. * config/fr30/fr30.cc: Likewise. * config/riscv/riscv-vector-builtins-shapes.cc: Likewise. * config/riscv/riscv-vector-builtins-bases.cc: Likewise. * config/visium/visium.h: Likewise. * config/mmix/mmix.cc: Likewise. * config/v850/v850.cc: Likewise. * config/v850/v850-c.cc: Likewise. * config/v850/v850.h: Likewise. * config/stormy16/stormy16.cc: Likewise. * config/stormy16/stormy16-protos.h: Likewise. * config/stormy16/stormy16.h: Likewise. * config/arc/arc.cc: Likewise. * config/vxworks.cc: Likewise. * config/microblaze/microblaze-c.cc: Likewise. * config/microblaze/microblaze-protos.h: Likewise. * config/microblaze/microblaze.h: Likewise. * config/microblaze/microblaze.cc: Likewise. * config/freebsd-spec.h: Likewise. * config/m68k/m68kelf.h: Likewise. * config/m68k/m68k.cc: Likewise. * config/m68k/netbsd-elf.h: Likewise. * config/m68k/linux.h: Likewise. * config/freebsd.h: Likewise. * config/host-openbsd.cc: Likewise. * regcprop.cc: Likewise. * dumpfile.cc: Likewise. * combine.cc: Likewise. * tree-ssa-forwprop.cc: Likewise. * ipa-profile.cc: Likewise. * hw-doloop.cc: Likewise. * opts.cc: Likewise. * gcc-ar.cc: Likewise. * tree-cfg.cc: Likewise. * incpath.cc: Likewise. * tree-ssa-sccvn.cc: Likewise. * function.cc: Likewise. * genattrtab.cc: Likewise. * rtl.def: Likewise. * genchecksum.cc: Likewise. * profile.cc: Likewise. * df-core.cc: Likewise. * tree-pretty-print.cc: Likewise. * tree.h: Likewise. * plugin.cc: Likewise. * tree-ssa-loop-ch.cc: Likewise. * emit-rtl.cc: Likewise. * haifa-sched.cc: Likewise. * gimple-range-edge.cc: Likewise. * range-op.cc: Likewise. * tree-ssa-ccp.cc: Likewise. * dwarf2cfi.cc: Likewise. * recog.cc: Likewise. * vtable-verify.cc: Likewise. * system.h: Likewise. * regrename.cc: Likewise. * tree-ssa-dom.cc: Likewise. * loop-unroll.cc: Likewise. * lra-constraints.cc: Likewise. * pretty-print.cc: Likewise. * ifcvt.cc: Likewise. * ipa.cc: Likewise. * alloc-pool.h: Likewise. * collect2.cc: Likewise. * pointer-query.cc: Likewise. * cfgloop.cc: Likewise. * toplev.cc: Likewise. * sese.cc: Likewise. * gengtype.cc: Likewise. * gimplify-me.cc: Likewise. * double-int.cc: Likewise. * bb-reorder.cc: Likewise. * dwarf2out.cc: Likewise. * tree-ssa-loop-ivcanon.cc: Likewise. * tree-ssa-reassoc.cc: Likewise. * cgraph.cc: Likewise. * sel-sched.cc: Likewise. * attribs.cc: Likewise. * expr.cc: Likewise. * tree-ssa-scopedtables.h: Likewise. * gimple-range-cache.cc: Likewise. * ipa-pure-const.cc: Likewise. * tree-inline.cc: Likewise. * genhooks.cc: Likewise. * gimple-range-phi.h: Likewise. * shrink-wrap.cc: Likewise. * tree.cc: Likewise. * gimple.cc: Likewise. * backend.h: Likewise. * opts-common.cc: Likewise. * cfg-flags.def: Likewise. * gcse-common.cc: Likewise. * tree-ssa-scopedtables.cc: Likewise. * ccmp.cc: Likewise. * builtins.def: Likewise. * builtin-attrs.def: Likewise. * postreload.cc: Likewise. * sched-deps.cc: Likewise. * ipa-inline-transform.cc: Likewise. * tree-vect-generic.cc: Likewise. * ipa-polymorphic-call.cc: Likewise. * builtins.cc: Likewise. * sel-sched-ir.cc: Likewise. * trans-mem.cc: Likewise. * ipa-visibility.cc: Likewise. * cgraph.h: Likewise. * tree-ssa-phiopt.cc: Likewise. * genopinit.cc: Likewise. * ipa-inline.cc: Likewise. * omp-low.cc: Likewise. * ipa-utils.cc: Likewise. * tree-ssa-math-opts.cc: Likewise. * tree-ssa-ifcombine.cc: Likewise. * gimple-range.cc: Likewise. * ipa-fnsummary.cc: Likewise. * ira-color.cc: Likewise. * value-prof.cc: Likewise. * varasm.cc: Likewise. * ipa-icf.cc: Likewise. * ira-emit.cc: Likewise. * lto-streamer.h: Likewise. * lto-wrapper.cc: Likewise. * regs.h: Likewise. * gengtype-parse.cc: Likewise. * alias.cc: Likewise. * lto-streamer.cc: Likewise. * real.h: Likewise. * wide-int.h: Likewise. * targhooks.cc: Likewise. * gimple-ssa-warn-access.cc: Likewise. * real.cc: Likewise. * ipa-reference.cc: Likewise. * bitmap.h: Likewise. * ginclude/float.h: Likewise. * ginclude/stddef.h: Likewise. * ginclude/stdarg.h: Likewise. * ginclude/stdatomic.h: Likewise. * optabs.h: Likewise. * sel-sched-ir.h: Likewise. * convert.cc: Likewise. * cgraphunit.cc: Likewise. * lra-remat.cc: Likewise. * tree-if-conv.cc: Likewise. * gcov-dump.cc: Likewise. * tree-predcom.cc: Likewise. * dominance.cc: Likewise. * gimple-range-cache.h: Likewise. * ipa-devirt.cc: Likewise. * rtl.h: Likewise. * ubsan.cc: Likewise. * tree-ssa.cc: Likewise. * ssa.h: Likewise. * cse.cc: Likewise. * jump.cc: Likewise. * hwint.h: Likewise. * caller-save.cc: Likewise. * coretypes.h: Likewise. * ipa-fnsummary.h: Likewise. * tree-ssa-strlen.cc: Likewise. * modulo-sched.cc: Likewise. * cgraphclones.cc: Likewise. * lto-cgraph.cc: Likewise. * hw-doloop.h: Likewise. * data-streamer.h: Likewise. * compare-elim.cc: Likewise. * profile-count.h: Likewise. * tree-vect-loop-manip.cc: Likewise. * ree.cc: Likewise. * reload.cc: Likewise. * tree-ssa-loop-split.cc: Likewise. * tree-into-ssa.cc: Likewise. * gcse.cc: Likewise. * cfgloopmanip.cc: Likewise. * df.h: Likewise. * fold-const.cc: Likewise. * wide-int.cc: Likewise. * gengtype-state.cc: Likewise. * sanitizer.def: Likewise. * tree-ssa-sink.cc: Likewise. * target-hooks-macros.h: Likewise. * tree-ssa-pre.cc: Likewise. * gimple-pretty-print.cc: Likewise. * ipa-utils.h: Likewise. * tree-outof-ssa.cc: Likewise. * tree-ssa-coalesce.cc: Likewise. * gimple-match.h: Likewise. * tree-ssa-loop-niter.cc: Likewise. * tree-loop-distribution.cc: Likewise. * tree-emutls.cc: Likewise. * tree-eh.cc: Likewise. * varpool.cc: Likewise. * ssa-iterators.h: Likewise. * asan.cc: Likewise. * reload1.cc: Likewise. * cfgloopanal.cc: Likewise. * tree-vectorizer.cc: Likewise. * simplify-rtx.cc: Likewise. * opts-global.cc: Likewise. * gimple-ssa-store-merging.cc: Likewise. * expmed.cc: Likewise. * tree-ssa-loop-prefetch.cc: Likewise. * tree-ssa-dse.h: Likewise. * tree-vect-stmts.cc: Likewise. * gimple-fold.cc: Likewise. * lra-coalesce.cc: Likewise. * data-streamer-out.cc: Likewise. * diagnostic.cc: Likewise. * tree-ssa-alias.cc: Likewise. * tree-vect-patterns.cc: Likewise. * common/common-target.def: Likewise. * common/config/rx/rx-common.cc: Likewise. * common/config/msp430/msp430-common.cc: Likewise. * common/config/avr/avr-common.cc: Likewise. * common/config/i386/i386-common.cc: Likewise. * common/config/pdp11/pdp11-common.cc: Likewise. * common/config/rs6000/rs6000-common.cc: Likewise. * common/config/mcore/mcore-common.cc: Likewise. * graphite.cc: Likewise. * gimple-low.cc: Likewise. * genmodes.cc: Likewise. * gimple-loop-jam.cc: Likewise. * lto-streamer-out.cc: Likewise. * predict.cc: Likewise. * omp-expand.cc: Likewise. * gimple-array-bounds.cc: Likewise. * predict.def: Likewise. * opts.h: Likewise. * tree-stdarg.cc: Likewise. * gimplify.cc: Likewise. * ira-lives.cc: Likewise. * loop-doloop.cc: Likewise. * lra.cc: Likewise. * gimple-iterator.h: Likewise. * tree-sra.cc: Likewise. gcc/fortran/ * trans-openmp.cc: Remove trailing whitespace. * trans-common.cc: Likewise. * match.h: Likewise. * scanner.cc: Likewise. * gfortranspec.cc: Likewise. * io.cc: Likewise. * iso-c-binding.def: Likewise. * iso-fortran-env.def: Likewise. * types.def: Likewise. * openmp.cc: Likewise. * f95-lang.cc: Likewise. gcc/analyzer/ * state-purge.cc: Remove trailing whitespace. * region-model.h: Likewise. * region-model.cc: Likewise. * program-point.cc: Likewise. * exploded-graph.h: Likewise. * program-state.cc: Likewise. * supergraph.cc: Likewise. gcc/c-family/ * c-ubsan.cc: Remove trailing whitespace. * stub-objc.cc: Likewise. * c-pragma.cc: Likewise. * c-ppoutput.cc: Likewise. * c-indentation.cc: Likewise. * c-ada-spec.cc: Likewise. * c-opts.cc: Likewise. * c-common.cc: Likewise. * c-format.cc: Likewise. * c-omp.cc: Likewise. * c-objc.h: Likewise. * c-cppbuiltin.cc: Likewise. * c-attribs.cc: Likewise. * c-target.def: Likewise. * c-common.h: Likewise. gcc/c/ * c-typeck.cc: Remove trailing whitespace. * gimple-parser.cc: Likewise. * c-parser.cc: Likewise. * c-decl.cc: Likewise. gcc/cp/ * vtable-class-hierarchy.cc: Remove trailing whitespace. * typeck2.cc: Likewise. * decl.cc: Likewise. * init.cc: Likewise. * semantics.cc: Likewise. * module.cc: Likewise. * rtti.cc: Likewise. * cxx-pretty-print.cc: Likewise. * cvt.cc: Likewise. * mangle.cc: Likewise. * name-lookup.h: Likewise. * coroutines.cc: Likewise. * error.cc: Likewise. * lambda.cc: Likewise. * tree.cc: Likewise. * g++spec.cc: Likewise. * decl2.cc: Likewise. * cp-tree.h: Likewise. * parser.cc: Likewise. * pt.cc: Likewise. * call.cc: Likewise. * lex.cc: Likewise. * cp-lang.cc: Likewise. * cp-tree.def: Likewise. * constexpr.cc: Likewise. * typeck.cc: Likewise. * name-lookup.cc: Likewise. * optimize.cc: Likewise. * search.cc: Likewise. * mapper-client.cc: Likewise. * ptree.cc: Likewise. * class.cc: Likewise. gcc/jit/ * docs/examples/tut04-toyvm/toyvm.cc: Remove trailing whitespace. gcc/lto/ * lto-object.cc: Remove trailing whitespace. * lto-symtab.cc: Likewise. * lto-partition.cc: Likewise. * lang-specs.h: Likewise. * lto-lang.cc: Likewise. gcc/objc/ * objc-encoding.cc: Remove trailing whitespace. * objc-map.h: Likewise. * objc-next-runtime-abi-01.cc: Likewise. * objc-act.cc: Likewise. * objc-map.cc: Likewise. gcc/objcp/ * objcp-decl.cc: Remove trailing whitespace. * objcp-lang.cc: Likewise. * objcp-decl.h: Likewise. gcc/rust/ * util/optional.h: Remove trailing whitespace. * util/expected.h: Likewise. * util/rust-unicode-data.h: Likewise. gcc/m2/ * mc-boot/GFpuIO.cc: Remove trailing whitespace. * mc-boot/GFIO.cc: Likewise. * mc-boot/GFormatStrings.cc: Likewise. * mc-boot/GCmdArgs.cc: Likewise. * mc-boot/GDebug.h: Likewise. * mc-boot/GM2Dependent.cc: Likewise. * mc-boot/GRTint.cc: Likewise. * mc-boot/GDebug.cc: Likewise. * mc-boot/GmcError.cc: Likewise. * mc-boot/Gmcp4.cc: Likewise. * mc-boot/GM2RTS.cc: Likewise. * mc-boot/GIO.cc: Likewise. * mc-boot/Gmcp5.cc: Likewise. * mc-boot/GDynamicStrings.cc: Likewise. * mc-boot/Gmcp1.cc: Likewise. * mc-boot/GFormatStrings.h: Likewise. * mc-boot/Gmcp2.cc: Likewise. * mc-boot/Gmcp3.cc: Likewise. * pge-boot/GFIO.cc: Likewise. * pge-boot/GDebug.h: Likewise. * pge-boot/GM2Dependent.cc: Likewise. * pge-boot/GDebug.cc: Likewise. * pge-boot/GM2RTS.cc: Likewise. * pge-boot/GSymbolKey.cc: Likewise. * pge-boot/GIO.cc: Likewise. * pge-boot/GIndexing.cc: Likewise. * pge-boot/GDynamicStrings.cc: Likewise. * pge-boot/GFormatStrings.h: Likewise. gcc/go/ * go-gcc.cc: Remove trailing whitespace. * gospec.cc: Likewise.
2024-10-13Revert "c++: Fix overeager Woverloaded-virtual with conversion operators ↵Simon Martin1-2/+1
[PR109918]" This reverts commit 60163c85730e6b7c566e219222403ac87ddbbddd.
2024-10-12c++: Fix overeager Woverloaded-virtual with conversion operators [PR109918]Simon Martin1-1/+2
We currently emit an incorrect -Woverloaded-virtual warning upon the following test case === cut here === struct A { virtual operator int() { return 42; } virtual operator char() = 0; }; struct B : public A { operator char() { return 'A'; } }; === cut here === The problem is that when iterating over ovl_range (fns), warn_hidden gets confused by the conversion operator marker, concludes that seen_non_override is true and therefore emits a warning for all conversion operators in A that do not convert to char, even if -Woverloaded-virtual is 1 (e.g. with -Wall, the case reported). A second set of problems is highlighted when -Woverloaded-virtual is 2. First, with the same test case, since base_fndecls contains all conversion operators in A (except the one to char, that's been removed when iterating over ovl_range (fns)), we emit a spurious warning for the conversion operator to int, even though it's unrelated. Second, in case there are several conversion operators with different cv-qualifiers to the same type in A, we rightfully emit a warning, however the note uses the location of the conversion operator marker instead of the right one; location_of should go over conv_op_marker. This patch fixes all these by explicitly keeping track of (1) base methods that are overriden, as well as (2) base methods that are hidden but not overriden (and by what), and warning about methods that are in (2) but not (1). It also ignores non virtual base methods, per "definition" of -Woverloaded-virtual. PR c++/109918 gcc/cp/ChangeLog: * class.cc (warn_hidden): Keep track of overloaded and of hidden base methods. Mention the actual hiding function in the warning, not the first overload. * error.cc (location_of): Skip over conv_op_marker. gcc/testsuite/ChangeLog: * g++.dg/warn/Woverloaded-virt1.C: Check that no warning is emitted for non virtual base methods. * g++.dg/warn/Woverloaded-virt5.C: New test. * g++.dg/warn/Woverloaded-virt6.C: New test. * g++.dg/warn/Woverloaded-virt7.C: New test. * g++.dg/warn/Woverloaded-virt8.C: New test. * g++.dg/warn/Woverloaded-virt9.C: New test.
2024-09-25c++: use TARGET_EXPR accessorsMarek Polacek1-2/+2
While futzing around with PR116416 I noticed that we can use the _SLOT and _INITIAL macros to make the code more readable. gcc/c-family/ChangeLog: * c-pretty-print.cc (c_pretty_printer::primary_expression): Use TARGET_EXPR accessors. (c_pretty_printer::expression): Likewise. gcc/cp/ChangeLog: * coroutines.cc (build_co_await): Use TARGET_EXPR accessors. (finish_co_yield_expr): Likewise. (register_awaits): Likewise. (tmp_target_expr_p): Likewise. (flatten_await_stmt): Likewise. * error.cc (dump_expr): Likewise. * semantics.cc (finish_omp_target_clauses): Likewise. * tree.cc (bot_manip): Likewise. (cp_tree_equal): Likewise. * typeck.cc (cxx_mark_addressable): Likewise. (cp_build_compound_expr): Likewise. (cp_build_modify_expr): Likewise. (check_return_expr): Likewise. Reviewed-by: Jason Merrill <jason@redhat.com>
2024-09-20diagnostics: convert text hooks to use diagnostic_text_output_format [PR116613]David Malcolm1-69/+80
The diagnostic_starter and diagnostic_finalizer callbacks and most of their support subroutines are only used by the "text" output format. Emphasize this and reduce the binding with diagnostic_context by renaming the callbacks to add "_text" in their names, and converting the first param from diagnostic_context * to diagnostic_text_output_output &. Update the various subroutines used by diagnostic starter/finalizer callbacks to also take a diagnostic_text_output_output & rather than a diagnostic_context *. Move m_includes and m_last_seen from the context to the text output. Use the text_output's get_printer () rather than the context's m_printer, which should ease the transition to multiple output sinks. No functional change intended. gcc/c-family/ChangeLog: PR other/116613 * c-opts.cc: Include "diagnostic-format-text.h". (c_diagnostic_finalizer): Rename to... (c_diagnostic_text_finalizer): ...this. Convert first param from diagnostic_context * to diagnostic_text_output_format & and update accordingly. (c_common_diagnostics_set_defaults): Update for renamings. gcc/ChangeLog: PR other/116613 * coretypes.h (class diagnostic_text_output_format): Add forward decl. * diagnostic-format-json.cc (json_output_format::after_diagnostic): New. * diagnostic-format-sarif.cc (sarif_output_format::after_diagnostic): New. * diagnostic-format-text.cc: Use pragmas to ignore -Wformat-diag. (diagnostic_text_output_format::~diagnostic_text_output_format): Use get_printer. Clean up m_includes_seen here, rather than in ~diagnostic_context. (diagnostic_text_output_format::on_report_diagnostic): Use get_printer. Update for callback renamings and pass *this to them, rather than &m_context. (diagnostic_text_output_format::after_diagnostic): New. (diagnostic_text_output_format::includes_seen_p): Move here from diagnostic_context/diagnostic.cc. (diagnostic_text_output_format::get_location_text): New. (maybe_line_and_column): Move here from diagnostic.cc and make non-static. (diagnostic_text_output_format::report_current_module): Move here from diagnostic_context/diagnostic.cc. (default_diagnostic_text_starter): Move here from diagnostic.cc, renaming from default_diagnostic_starter. (default_diagnostic_text_finalizer): Likewise, renaming from default_diagnostic_finalizer. * diagnostic-format-text.h (diagnostic_text_output_format::diagnostic_text_output_format): Initialize m_last_module and m_includes_seen. (diagnostic_text_output_format::after_diagnostic): New decl. (diagnostic_text_output_format::build_prefix): New decl. (diagnostic_text_output_format::report_current_module): New decl. (diagnostic_text_output_format::append_note): New decl. (diagnostic_text_output_format::file_name_as_prefix): New decl. (diagnostic_text_output_format::print_path): New decl. (diagnostic_text_output_format::show_column_p): New decl. (diagnostic_text_output_format::get_location_text): New decl. (diagnostic_text_output_format::includes_seen_p): New decl. (diagnostic_text_output_format::show_any_path): New decl. (diagnostic_text_output_format::m_last_module): New field. (diagnostic_text_output_format::m_includes_seen): New field. * diagnostic-format.h (diagnostic_output_format::after_diagnostic): New vfunc. (diagnostic_output_format::get_context): New. (diagnostic_output_format::get_diagram_theme): New. * diagnostic-macro-unwinding.cc: Include "diagnostic-format-text.h". (maybe_unwind_expanded_macro_loc): Convert first param from diagnostic_context * to diagnostic_text_output_format & and update accordingly. (virt_loc_aware_diagnostic_finalizer): Likewise. * diagnostic-macro-unwinding.h (virt_loc_aware_diagnostic_finalizer): Likewise. (maybe_unwind_expanded_macro_loc): Likewise. * diagnostic-path.cc: Include "diagnostic-format-text.h". (path_label::path_label): Drop "ctxt" param and add "colorize" and "allow_emojis" params. Update initializations. (path_label::get_text): Use m_colorize rather than querying m_ctxt.m_printer. Use m_allow_emojis rather than querying m_ctxt's diagram theme. (path_label::m_ctxt): Drop field. (path_label::m_colorize): Drop field. (path_label::m_allow_emojis): Drop field. (event_range::event_range): Drop param "ctxt". Add params "colorize_labels" and "allow_emojis". (event_range::print): Convert first param from diagnostic_context & to diagnostic_text_output_format & and update accordingly. (path_summary::path_summary): Likewise. (path_summary::print_swimlane_for_event_range): Likewise. (print_path_summary_as_text): Likewise for 3rd param. (diagnostic_context::print_path): Convert to... (diagnostic_text_output_format::print_path): ...this. (selftest::test_empty_path): Update to use a diagnostic_text_output_format. (selftest::test_intraprocedural_path): Likewise. (selftest::test_interprocedural_path_1): Likewise. (selftest::test_interprocedural_path_2): Likewise. (selftest::test_recursion): Likewise. (selftest::test_control_flow_1): Likewise. (selftest::test_control_flow_2): Likewise. (selftest::test_control_flow_3): Likewise. (selftest::assert_cfg_edge_path_streq): Likewise. (selftest::test_control_flow_5): Likewise. (selftest::test_control_flow_6): Likewise. * diagnostic.cc (file_name_as_prefix): Convert to... (diagnostic_text_output_format::file_name_as_prefix): ...this. (diagnostic_context::initialize): Update for renamings. Move m_last_module and m_includes_seen into text output. (diagnostic_context::finish): Likewise. (diagnostic_context::get_location_text): Add "colorize" param. (diagnostic_build_prefix): Convert to... (diagnostic_text_output_format::build_prefix): ...this. (diagnostic_context::includes_seen_p): Move from here to diagnostic_text_output_format/diagnostic-format-text.cc. (diagnostic_context::report_current_module): Likewise. (diagnostic_context::show_any_path): Convert to... (diagnostic_text_output_format::show_any_path): ...this. (default_diagnostic_starter): Rename and move to diagnostic-format-text.cc. (default_diagnostic_start_span_fn): Pass colorize bool to get_location_text. (default_diagnostic_finalizer): Rename and move to diagnostic-format-text.cc. (diagnostic_context::report_diagnostic): Replace call to show_any_path with call to new output format "after_diagnostic" vfunc, moving show_any_path call to the text output format. (diagnostic_append_note): Convert to... (diagnostic_text_output_format::append_note): ...this. (selftest::assert_location_text): Pass in false for colorization. * diagnostic.h (diagnostic_starter_fn): Rename to... (diagnostic_text_starter_fn): ...this. Convert first param from diagnostic_context * to diagnostic_text_output_format &. (diagnostic_finalizer_fn, diagnostic_text_finalizer_fn): Likewise. (diagnostic_context): Update friends for renamings. (diagnostic_context::report_current_module): Move to text output format. (diagnostic_context::get_location_text): Add "colorize" bool. (diagnostic_context::includes_seen_p): Move to text output format. (diagnostic_context::show_any_path): Likewise. (diagnostic_context::print_path): Likewise. (diagnostic_context::m_text_callbacks): Update for renamings. (diagnostic_context::m_last_module): Move to text output format. (diagnostic_context::m_includes_seen): Likewise. (diagnostic_starter): Rename to... (diagnostic_text_starter): ...this and update return type. (diagnostic_finalizer): Rename to... (diagnostic_text_finalizer): ...this and update return type. (diagnostic_report_current_module): Drop decl in favor of a member function of diagnostic_text_output_format. (diagnostic_append_note): Likewise. (default_diagnostic_starter): Rename to... (default_diagnostic_text_starter): ...this, updating type. (default_diagnostic_finalizer): Rename to... (default_diagnostic_text_finalizer): ...this, updating type. (file_name_as_prefix): Drop decl. * langhooks-def.h (lhd_print_error_function): Convert first param from diagnostic_context * to diagnostic_text_output_format &. * langhooks.cc: Include "diagnostic-format-text.h". (lhd_print_error_function): Likewise. Update accordingly * langhooks.h (lang_hooks::print_error_function): Convert first param from diagnostic_context * to diagnostic_text_output_format &. * tree-diagnostic.cc: Include "diagnostic-format-text.h". (diagnostic_report_current_function): Convert first param from diagnostic_context * to diagnostic_text_output_format & and update accordingly. (default_tree_diagnostic_starter): Rename to... (default_tree_diagnostic_text_starter): ...this. Convert first param from diagnostic_context * to diagnostic_text_output_format & and update accordingly. (tree_diagnostics_defaults): Update for renamings. gcc/cp/ChangeLog: PR other/116613 * cp-tree.h (cxx_print_error_function): Convert first param from diagnostic_context * to diagnostic_text_output_format &. * error.cc: Include "diagnostic-format-text.h". (cxx_initialize_diagnostics): Update for renamings. (cxx_print_error_function): Convert first param from diagnostic_context * to diagnostic_text_output_format & and update accordingly (cp_diagnostic_starter): Rename to... (cp_diagnostic_text_starter): ...this. Convert first param from diagnostic_context * to diagnostic_text_output_format & and update accordingly. (cp_print_error_function): Likewise. (print_instantiation_full_context): Likewise. (print_instantiation_partial_context_line): Likewise. (print_instantiation_partial_context): Likewise. (maybe_print_instantiation_context): Likewise. (maybe_print_constexpr_context): Likewise. (print_location): Likewise. (print_constrained_decl_info): Likewise. (print_concept_check_info): Likewise. (print_constraint_context_head): Likewise. (print_requires_expression_info): Likewise. (maybe_print_single_constraint_context): Likewise. gcc/fortran/ChangeLog: PR other/116613 * error.cc: Include "diagnostic-format-text.h". (gfc_diagnostic_starter): Rename to... (gfc_diagnostic_text_starter): ...this. Convert first param from diagnostic_context * to diagnostic_text_output_format & and update accordingly. (gfc_diagnostic_finalizer, gfc_diagnostic_text_finalizer): Likewise. (gfc_diagnostics_init): Update for renamings. (gfc_diagnostics_finish): Likewise. gcc/jit/ChangeLog: PR other/116613 * dummy-frontend.cc: Include "diagnostic-format-text.h". (jit_begin_diagnostic): Convert first param from diagnostic_context * to diagnostic_text_output_format & (jit_end_diagnostic): Likewise. Update accordingly. (jit_langhook_init): Update for renamings. gcc/rust/ChangeLog: PR other/116613 * resolve/rust-ast-resolve-expr.cc (funny_ice_finalizer): : Convert first param from diagnostic_context * to diagnostic_text_output_format &. (ResolveExpr::visit): Update for renaming. gcc/testsuite/ChangeLog: PR other/116613 * g++.dg/plugin/show_template_tree_color_plugin.c (noop_starter_fn): Rename to... (noop_text_starter_fn): ...this. Update first param from dc to text_output. (plugin_init): Update for renamings. * gcc.dg/plugin/diagnostic_group_plugin.c (test_diagnostic_starter): Rename to... (test_diagnostic_text_starter): ...this. Update first param from dc to text_output. (plugin_init): Update for renaming. * gcc.dg/plugin/diagnostic_plugin_test_show_locus.c: Include "diagnostic-format-text.h". (custom_diagnostic_finalizer): Rename to... (custom_diagnostic_text_finalizer): ...this. Update first param from dc to text_output. (test_show_locus): Update for renamings. * gcc.dg/plugin/location_overflow_plugin.c: Include "diagnostic-format-text.h". (original_finalizer): Rename to... (original_text_finalizer): ...this and update type. (verify_unpacked_ranges): Update first param from dc to text_output. Update for this and for renamings. (verify_no_columns): Likewise. (plugin_init): Update for renamings. libcc1/ChangeLog: PR other/116613 * context.cc: Include "diagnostic-format-text.h". (plugin_print_error_function): Update first param from diagnostic_context * to diagnostic_text_output_format &. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-09-09diagnostics: introduce struct diagnostic_option_idDavid Malcolm1-4/+6
Use a new struct diagnostic_option_id rather than just "int" when referring to command-line options controlling warnings in the diagnostic subsystem. No functional change intended, but better documents the meaning of the code. gcc/c-family/ChangeLog: * c-common.cc (c_option_controlling_cpp_diagnostic): Return diagnostic_option_id rather than int. (c_cpp_diagnostic): Update for renaming of diagnostic_override_option_index to diagnostic_set_option_id. gcc/c/ChangeLog: * c-errors.cc (pedwarn_c23): Use "diagnostic_option_id option_id" rather than "int opt". Update for renaming of diagnostic_info field. (pedwarn_c11): Likewise. (pedwarn_c99): Likewise. (pedwarn_c90): Likewise. * c-tree.h (pedwarn_c90): Likewise for decl. (pedwarn_c99): Likewise. (pedwarn_c11): Likewise. (pedwarn_c23): Likewise. gcc/cp/ChangeLog: * constexpr.cc (constexpr_error): Update for renaming of diagnostic_info field. * cp-tree.h (pedwarn_cxx98): Use "diagnostic_option_id" rather than "int". * error.cc (cp_adjust_diagnostic_info): Update for renaming of diagnostic_info field. (pedwarn_cxx98): Use "diagnostic_option_id option_id" rather than "int opt". Update for renaming of diagnostic_info field. (diagnostic_set_info): Likewise. gcc/d/ChangeLog: * d-diagnostic.cc (d_diagnostic_report_diagnostic): Update for renaming of diagnostic_info field. gcc/ChangeLog: * diagnostic-core.h (struct diagnostic_option_id): New. (warning): Use it rather than "int" for param. (warning_n): Likewise. (warning_at): Likewise. (warning_meta): Likewise. (pedwarn): Likewise. (permerror_opt): Likewise. (emit_diagnostic): Likewise. (emit_diagnostic_valist): Likewise. (emit_diagnostic_valist_meta): Likewise. * diagnostic-format-json.cc (json_output_format::on_report_diagnostic): Update for renaming of diagnostic_info field. * diagnostic-format-sarif.cc (sarif_builder::make_result_object): Likewise. (make_reporting_descriptor_object_for_warning): Likewise. * diagnostic-format-text.cc (print_option_information): Likewise. * diagnostic-global-context.cc (emit_diagnostic): Use "diagnostic_option_id option_id" rather than "int opt". (emit_diagnostic_valist): Likewise. (emit_diagnostic_valist_meta): Likewise. (warning): Likewise. (warning_at): Likewise. (warning_meta): Likewise. (warning_n): Likewise. (pedwarn): Likewise. (permerror_opt): Likewise. * diagnostic.cc (diagnostic_set_info_translated): Update for renaming of diagnostic_info field. (diagnostic_option_classifier::classify_diagnostic): Use "diagnostic_option_id option_id" rather than "int opt". (update_effective_level_from_pragmas): Update for renaming of diagnostic_info field. (diagnostic_context::diagnostic_enabled): Likewise. (diagnostic_context::warning_enabled_at): Use "diagnostic_option_id option_id" rather than "int opt". (diagnostic_context::diagnostic_impl): Likewise. (diagnostic_context::diagnostic_n_impl): Likewise. * diagnostic.h (diagnostic_info::diagnostic_info): Update for... (diagnostic_info::option_index): Rename... (diagnostic_info::option_id): ...to this. (class diagnostic_option_manager): Use "diagnostic_option_id option_id" rather than "int opt" for vfuncs. (diagnostic_option_classifier): Likewise for member funcs. (diagnostic_classification_change_t::option): Add comment. (diagnostic_context::warning_enabled_at): Use "diagnostic_option_id option_id" rather than "int option_index". (diagnostic_context::option_unspecified_p): Likewise. (diagnostic_context::classify_diagnostic): Likewise. (diagnostic_context::option_enabled_p): Likewise. (diagnostic_context::make_option_name): Likewise. (diagnostic_context::make_option_url): Likewise. (diagnostic_context::diagnostic_impl): Likewise. (diagnostic_context::diagnostic_n_impl): Likewise. (diagnostic_override_option_index): Rename... (diagnostic_set_option_id): ...to this, and update for diagnostic_info field renaming. (diagnostic_classify_diagnostic): Use "diagnostic_option_id" rather than "int". (warning_enabled_at): Likewise. (option_unspecified_p): Likewise. gcc/fortran/ChangeLog: * cpp.cc (cb_cpp_diagnostic_cpp_option): Convert return type from "int" to "diagnostic_option_id". (cb_cpp_diagnostic): Update for renaming of diagnostic_override_option_index to diagnostic_set_option_id. * error.cc (gfc_warning): Update for renaming of diagnostic_info field. (gfc_warning_now_at): Likewise. (gfc_warning_now): Likewise. (gfc_warning_internal): Likewise. gcc/ChangeLog: * ipa-pure-const.cc: Replace include of "opts.h" with "opts-diagnostic.h". (suggest_attribute): Convert param from int to diagnostic_option_id. * lto-wrapper.cc (class lto_diagnostic_option_manager): Use diagnostic_option_id rather than "int". * opts-common.cc (compiler_diagnostic_option_manager::option_enabled_p): Likewise. * opts-diagnostic.h (class gcc_diagnostic_option_manager): Likewise. (class compiler_diagnostic_option_manager): Likewise. * opts.cc (compiler_diagnostic_option_manager::make_option_name): Likewise. (gcc_diagnostic_option_manager::make_option_url): Likewise. * substring-locations.cc (format_string_diagnostic_t::emit_warning_n_va): Likewise. (format_string_diagnostic_t::emit_warning_va): Likewise. (format_string_diagnostic_t::emit_warning): Likewise. (format_string_diagnostic_t::emit_warning_n): Likewise. * substring-locations.h (format_string_diagnostic_t::emit_warning_va): Likewise. (format_string_diagnostic_t::emit_warning_n_va): Likewise. (format_string_diagnostic_t::emit_warning): Likewise. (format_string_diagnostic_t::emit_warning_n): Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-09-09diagnostics: rename dc.printer to m_printer [PR116613]David Malcolm1-41/+51
Rename diagnostic_context's "printer" field to "m_printer", for consistency with other fields, and to highlight places where we currently use this, to help assess feasibility of supporting multiple output sinks (PR other/116613). No functional change intended. gcc/ChangeLog: PR other/116613 * attribs.cc (decls_mismatched_attributes): Rename diagnostic_context's "printer" field to "m_printer". (attr_access::array_as_string): Likewise. * diagnostic-format-json.cc (json_output_format::on_report_diagnostic): Likewise. (diagnostic_output_format_init_json): Likewise. * diagnostic-format-sarif.cc (sarif_result::on_nested_diagnostic): Likewise. (sarif_ice_notification): Likewise. (sarif_builder::on_report_diagnostic): Likewise. (sarif_builder::make_result_object): Likewise. (sarif_builder::make_location_object): Likewise. (sarif_builder::make_message_object_for_diagram): Likewise. (diagnostic_output_format_init_sarif): Likewise. * diagnostic-format-text.cc (diagnostic_text_output_format::~diagnostic_text_output_format): Likewise. (diagnostic_text_output_format::on_report_diagnostic): Likewise. (diagnostic_text_output_format::on_diagram): Likewise. (diagnostic_text_output_format::print_any_cwe): Likewise. (diagnostic_text_output_format::print_any_rules): Likewise. (diagnostic_text_output_format::print_option_information): Likewise. * diagnostic-format.h (diagnostic_output_format::get_printer): New. * diagnostic-global-context.cc (verbatim): Rename diagnostic_context's "printer" field to "m_printer". * diagnostic-path.cc (path_label::get_text): Likewise. (print_path_summary_as_text): Likewise. (diagnostic_context::print_path): Likewise. (selftest::test_empty_path): Likewise. (selftest::test_intraprocedural_path): Likewise. (selftest::test_interprocedural_path_1): Likewise. (selftest::test_interprocedural_path_2): Likewise. (selftest::test_recursion): Likewise. (selftest::test_control_flow_1): Likewise. (selftest::test_control_flow_2): Likewise. (selftest::test_control_flow_3): Likewise. (assert_cfg_edge_path_streq): Likewise. (selftest::test_control_flow_5): Likewise. (selftest::test_control_flow_6): Likewise. * diagnostic-show-locus.cc (layout::layout): Likewise. (selftest::test_layout_x_offset_display_utf8): Likewise. (selftest::test_layout_x_offset_display_tab): Likewise. (selftest::test_diagnostic_show_locus_unknown_location): Likewise. (selftest::test_one_liner_simple_caret): Likewise. (selftest::test_one_liner_no_column): Likewise. (selftest::test_one_liner_caret_and_range): Likewise. (selftest::test_one_liner_multiple_carets_and_ranges): Likewise. (selftest::test_one_liner_fixit_insert_before): Likewise. (selftest::test_one_liner_fixit_insert_after): Likewise. (selftest::test_one_liner_fixit_remove): Likewise. (selftest::test_one_liner_fixit_replace): Likewise. (selftest::test_one_liner_fixit_replace_non_equal_range): Likewise. (selftest::test_one_liner_fixit_replace_equal_secondary_range): Likewise. (selftest::test_one_liner_fixit_validation_adhoc_locations): Likewise. (selftest::test_one_liner_many_fixits_1): Likewise. (selftest::test_one_liner_many_fixits_2): Likewise. (selftest::test_one_liner_labels): Likewise. (selftest::test_one_liner_simple_caret_utf8): Likewise. (selftest::test_one_liner_caret_and_range_utf8): Likewise. (selftest::test_one_liner_multiple_carets_and_ranges_utf8): Likewise. (selftest::test_one_liner_fixit_insert_before_utf8): Likewise. (selftest::test_one_liner_fixit_insert_after_utf8): Likewise. (selftest::test_one_liner_fixit_remove_utf8): Likewise. (selftest::test_one_liner_fixit_replace_utf8): Likewise. (selftest::test_one_liner_fixit_replace_non_equal_range_utf8): Likewise. (selftest::test_one_liner_fixit_replace_equal_secondary_range_utf8): Likewise. (selftest::test_one_liner_fixit_validation_adhoc_locations_utf8): Likewise. (selftest::test_one_liner_many_fixits_1_utf8): Likewise. (selftest::test_one_liner_many_fixits_2_utf8): Likewise. (selftest::test_one_liner_labels_utf8): Likewise. (selftest::test_one_liner_colorized_utf8): Likewise. (selftest::test_add_location_if_nearby): Likewise. (selftest::test_diagnostic_show_locus_fixit_lines): Likewise. (selftest::test_overlapped_fixit_printing): Likewise. (selftest::test_overlapped_fixit_printing_utf8): Likewise. (selftest::test_overlapped_fixit_printing_2): Likewise. (selftest::test_fixit_insert_containing_newline): Likewise. (selftest::test_fixit_insert_containing_newline_2): Likewise. (selftest::test_fixit_replace_containing_newline): Likewise. (selftest::test_fixit_deletion_affecting_newline): Likewise. (selftest::test_tab_expansion): Likewise. (selftest::test_escaping_bytes_1): Likewise. (selftest::test_escaping_bytes_2): Likewise. (selftest::test_line_numbers_multiline_range): Likewise. * diagnostic.cc (file_name_as_prefix): Likewise. (diagnostic_set_caret_max_width): Likewise. (diagnostic_context::initialize): Likewise. (diagnostic_context::color_init): Likewise. (diagnostic_context::urls_init): Likewise. (diagnostic_context::finish): Likewise. (diagnostic_context::get_location_text): Likewise. (diagnostic_build_prefix): Likewise. (diagnostic_context::report_current_module): Likewise. (default_diagnostic_starter): Likewise. (default_diagnostic_start_span_fn): Likewise. (default_diagnostic_finalizer): Likewise. (diagnostic_context::report_diagnostic): Likewise. (diagnostic_append_note): Likewise. (diagnostic_context::error_recursion): Likewise. (fancy_abort): Likewise. * diagnostic.h (diagnostic_context::set_show_highlight_colors): Likewise. (diagnostic_context::printer): Rename to... (diagnostic_context::m_printer): ...this. (diagnostic_format_decoder): Rename diagnostic_context's "printer" field to "m_printer". (diagnostic_prefixing_rule): Likewise. (diagnostic_ready_p): Likewise. * gimple-ssa-warn-access.cc (pass_waccess::maybe_warn_memmodel): Likewise. * langhooks.cc (lhd_print_error_function): Likewise. * lto-wrapper.cc (print_lto_docs_link): Likewise. * opts-global.cc (init_options_once): Likewise. * opts.cc (common_handle_option): Likewise. * simple-diagnostic-path.cc (simple_diagnostic_path_cc_tests): Likewise. * text-art/dump.h (dump_to_file<T>): Likewise. * toplev.cc (announce_function): Likewise. (toplev::main): Likewise. * tree-diagnostic.cc (default_tree_diagnostic_starter): Likewise. * tree.cc (escaped_string::escape): Likewise. (selftest::test_escaped_strings): Likewise. gcc/ada/ChangeLog: PR other/116613 * gcc-interface/misc.cc (internal_error_function): Rename diagnostic_context's "printer" field to "m_printer". gcc/analyzer/ChangeLog: PR other/116613 * access-diagram.cc (access_range::dump): Rename diagnostic_context's "printer" field to "m_printer". * analyzer-language.cc (on_finish_translation_unit): Likewise. * analyzer.cc (make_label_text): Likewise. (make_label_text_n): Likewise. * call-details.cc (call_details::dump): Likewise. * call-summary.cc (call_summary::dump): Likewise. (call_summary_replay::dump): Likewise. * checker-event.cc (checker_event::debug): Likewise. * constraint-manager.cc (range::dump): Likewise. (bounded_range::dump): Likewise. (bounded_ranges::dump): Likewise. (constraint_manager::dump): Likewise. * diagnostic-manager.cc (diagnostic_manager::emit_saved_diagnostic): Likewise. * engine.cc (exploded_node::dump): Likewise. (exploded_path::dump): Likewise. (run_checkers): Likewise. * kf-analyzer.cc (kf_analyzer_dump_escaped::impl_call_pre): Likewise. * pending-diagnostic.cc (evdesc::event_desc::formatted_print): Likewise. * program-point.cc (function_point::print_source_line): Likewise. (program_point::dump): Likewise. * program-state.cc (extrinsic_state::dump_to_file): Likewise. (sm_state_map::dump): Likewise. (program_state::dump_to_file): Likewise. * ranges.cc (symbolic_byte_offset::dump): Likewise. (symbolic_byte_range::dump): Likewise. * region-model-reachability.cc (reachable_regions::dump): Likewise. * region-model.cc (region_to_value_map::dump): Likewise. (region_model::dump): Likewise. (model_merger::dump): Likewise. * region.cc (region_offset::dump): Likewise. (region::dump): Likewise. * sm-malloc.cc (deallocator_set::dump): Likewise. (sufficiently_similar_p): Likewise. * store.cc (uncertainty_t::dump): Likewise. (binding_key::dump): Likewise. (binding_map::dump): Likewise. (binding_cluster::dump): Likewise. (store::dump): Likewise. * supergraph.cc (supergraph::dump_dot_to_file): Likewise. (superedge::dump): Likewise. * svalue.cc (svalue::dump): Likewise. gcc/c-family/ChangeLog: PR other/116613 * c-format.cc (selftest::test_type_mismatch_range_labels): Rename diagnostic_context's "printer" field to "m_printer". (selftest::test_type_mismatch_range_labels): Likewise. * c-opts.cc (c_diagnostic_finalizer): Likewise. gcc/c/ChangeLog: PR other/116613 * c-objc-common.cc (c_initialize_diagnostics): Rename diagnostic_context's "printer" field to "m_printer". gcc/cp/ChangeLog: PR other/116613 * error.cc (cxx_initialize_diagnostics): Rename diagnostic_context's "printer" field to "m_printer". (cxx_print_error_function): Likewise. (cp_diagnostic_starter): Likewise. (cp_print_error_function): Likewise. (print_instantiation_full_context): Likewise. (print_instantiation_partial_context_line): Likewise. (maybe_print_constexpr_context): Likewise. (print_location): Likewise. (print_constrained_decl_info): Likewise. (print_concept_check_info): Likewise. (print_constraint_context_head): Likewise. (print_requires_expression_info): Likewise. * module.cc (noisy_p): Likewise. gcc/d/ChangeLog: PR other/116613 * d-diagnostic.cc (d_diagnostic_report_diagnostic): Rename diagnostic_context's "printer" field to "m_printer". gcc/fortran/ChangeLog: PR other/116613 * error.cc (gfc_clear_pp_buffer): Rename diagnostic_context's "printer" field to "m_printer". (gfc_warning): Likewise. (gfc_diagnostic_build_kind_prefix): Likewise. (gfc_diagnostic_build_locus_prefix): Likewise. (gfc_diagnostic_starter): Likewise. (gfc_diagnostic_starter): Likewise. (gfc_diagnostic_start_span): Likewise. (gfc_diagnostic_finalizer): Likewise. (gfc_warning_check): Likewise. (gfc_error_opt): Likewise. (gfc_error_check): Likewise. gcc/jit/ChangeLog: PR other/116613 * jit-playback.cc (add_diagnostic): Rename diagnostic_context's "printer" field to "m_printer". gcc/testsuite/ChangeLog: PR other/116613 * gcc.dg/plugin/analyzer_cpython_plugin.c (dump_refcnt_info): Update for renaming of field "printer" to "m_printer". * gcc.dg/plugin/diagnostic_group_plugin.c (test_diagnostic_starter): Likewise. (test_diagnostic_start_span_fn): Likewise. (test_output_format::on_begin_group): Likewise. (test_output_format::on_end_group): Likewise. * gcc.dg/plugin/diagnostic_plugin_test_paths.c: Likewise. * gcc.dg/plugin/diagnostic_plugin_test_show_locus.c (custom_diagnostic_finalizer): Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-09-05c++: Add missing auto_diagnostic_groupsNathaniel Shead1-0/+2
This patch goes through all .cc files in gcc/cp and adds in any auto_diagnostic_groups that seem to be missing by looking for any 'inform' calls that aren't grouped with their respective error/warning. Now with SARIF output support this seems to be a bit more important. The patch isn't complete; I've tried to also track helper functions used for diagnostics to group them, but some may have been missed. Additionally there are a few functions that are definitely missing groupings but I wasn't able to see an obvious way to add them without potentially grouping together unrelated messages. This list includes: - lazy_load_{binding,pendings} "during load of {binding,pendings} for" - cp_finish_decomp "in initialization of structured binding variable" - require_deduced_type "using __builtin_source_location" - convert_nontype_argument "in template argument for type %qT" - coerce_template_params "so any instantiation with a non-empty parameter pack" - tsubst_default_argument "when instantiating default argument" - invalid_nontype_parm_type_p "invalid template non-type parameter" gcc/cp/ChangeLog: * class.cc (add_method): Add missing auto_diagnostic_group. (handle_using_decl): Likewise. (maybe_warn_about_overly_private_class): Likewise. (check_field_decl): Likewise. (check_field_decls): Likewise. (resolve_address_of_overloaded_function): Likewise. (note_name_declared_in_class): Likewise. * constraint.cc (associate_classtype_constraints): Likewise. (diagnose_trait_expr): Clean up whitespace. * coroutines.cc (find_coro_traits_template_decl): Add missing auto_diagnostic_group. (coro_promise_type_found_p): Likewise. (coro_diagnose_throwing_fn): Likewise. * cvt.cc (build_expr_type_conversion): Likewise. * decl.cc (validate_constexpr_redeclaration): Likewise. (duplicate_function_template_decls): Likewise. (duplicate_decls): Likewise. (lookup_label_1): Likewise. (check_previous_goto_1): Likewise. (check_goto_1): Likewise. (make_typename_type): Likewise. (make_unbound_class_template): Likewise. (check_tag_decl): Likewise. (start_decl): Likewise. (maybe_commonize_var): Likewise. (check_for_uninitialized_const_var): Likewise. (reshape_init_class): Likewise. (check_initializer): Likewise. (cp_finish_decl): Likewise. (find_decomp_class_base): Likewise. (cp_finish_decomp): Likewise. (expand_static_init): Likewise. (grokfndecl): Likewise. (grokdeclarator): Likewise. (check_elaborated_type_specifier): Likewise. (lookup_and_check_tag): Likewise. (xref_tag): Likewise. (cxx_simulate_enum_decl): Likewise. (finish_function): Likewise. * decl2.cc (check_classfn): Likewise. (record_mangling): Likewise. (mark_used): Likewise. * error.cc (qualified_name_lookup_error): Likewise. * except.cc (build_throw): Likewise. * init.cc (get_nsdmi): Likewise. (diagnose_uninitialized_cst_or_ref_member_1): Likewise. (warn_placement_new_too_small): Likewise. (build_new_1): Likewise. (build_vec_delete_1): Likewise. (build_delete): Likewise. * lambda.cc (add_capture): Likewise. (add_default_capture): Likewise. * lex.cc (unqualified_fn_lookup_error): Likewise. * method.cc (synthesize_method): Likewise. (defaulted_late_check): Likewise. * module.cc (trees_in::is_matching_decl): Likewise. (trees_in::read_enum_def): Likewise. (module_state::check_not_purview): Likewise. (module_state::deferred_macro): Likewise. (module_state::read_config): Likewise. (module_state::check_read): Likewise. (declare_module): Likewise. (init_modules): Likewise. * name-lookup.cc (diagnose_name_conflict): Likewise. (lookup_using_decl): Likewise. (set_decl_namespace): Likewise. (finish_using_directive): Likewise. (push_namespace): Likewise. (add_imported_namespace): Likewise. * parser.cc (cp_parser_check_for_definition_in_return_type): Likewise. (cp_parser_userdef_numeric_literal): Likewise. (cp_parser_nested_name_specifier_opt): Likewise. (cp_parser_new_expression): Likewise. (cp_parser_binary_expression): Likewise. (cp_parser_lambda_introducer): Likewise. (cp_parser_module_declaration): Likewise. (cp_parser_import_declaration): Likewise, removing gotos to support this. (cp_parser_declaration): Add missing auto_diagnostic_group. (cp_parser_decl_specifier_seq): Likewise. (cp_parser_template_id): Likewise. (cp_parser_template_name): Likewise. (cp_parser_explicit_specialization): Likewise. (cp_parser_placeholder_type_specifier): Likewise. (cp_parser_elaborated_type_specifier): Likewise. (cp_parser_enum_specifier): Likewise. (cp_parser_asm_definition): Likewise. (cp_parser_init_declarator): Likewise. (cp_parser_direct_declarator): Likewise. (cp_parser_class_head): Likewise. (cp_parser_member_declaration): Likewise. (cp_parser_lookup_name): Likewise. (cp_parser_explicit_template_declaration): Likewise. (cp_parser_check_class_key): Likewise. * pt.cc (maybe_process_partial_specialization): Likewise. (determine_specialization): Likewise. (check_for_bare_parameter_packs): Likewise. (check_template_shadow): Likewise. (process_partial_specialization): Likewise. (push_template_decl): Likewise. (redeclare_class_template): Likewise. (convert_nontype_argument_function): Likewise. (check_valid_ptrmem_cst_expr): Likewise. (convert_nontype_argument): Likewise. (convert_template_argument): Likewise. (coerce_template_parms): Likewise. (tsubst_qualified_id): Likewise. (tsubst_expr): Likewise. (most_specialized_partial_spec): Likewise. (do_class_deduction): Likewise. (do_auto_deduction): Likewise. * search.cc (lookup_member): Likewise. * semantics.cc (finish_non_static_data_member): Likewise. (process_outer_var_ref): Likewise. (finish_id_expression_1): Likewise. (finish_offsetof): Likewise. (omp_reduction_lookup): Likewise. (finish_omp_clauses): Likewise. * tree.cc (check_abi_tag_redeclaration): Likewise. (check_abi_tag_args): Likewise. * typeck.cc (invalid_nonstatic_memfn_p): Likewise. (complain_about_unrecognized_member): Likewise. (finish_class_member_access_expr): Likewise. (error_args_num): Likewise. (warn_for_null_address): Likewise. (cp_build_binary_op): Likewise. (build_x_unary_op): Likewise. (cp_build_unary_op): Likewise. (build_static_cast): Likewise. (cp_build_modify_expr): Likewise. (get_delta_difference): Likewise. (convert_for_assignment): Widen scope of auto_diagnostic_group. (check_return_expr): Add missing auto_diagnostic_group. * typeck2.cc (cxx_incomplete_type_diagnostic): Likewise. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Marek Polacek <polacek@redhat.com>
2024-09-03c++: support C++11 attributes in C++98Jason Merrill1-3/+4
I don't see any reason why we can't allow the [[]] attribute syntax in C++98 mode with a pedwarn just like many other C++11 features. In fact, we already do support it in some places in the grammar, but not in places that check cp_nth_tokens_can_be_std_attribute_p. Let's also follow the C front-end's lead in only warning about them when -pedantic. It still isn't necessary for this function to guard against Objective-C message passing syntax; we handle that with tentative parsing in cp_parser_statement, and we don't call this function in that context anyway. gcc/cp/ChangeLog: * parser.cc (cp_nth_tokens_can_be_std_attribute_p): Don't check cxx_dialect. * error.cc (maybe_warn_cpp0x): Only complain about C++11 attributes if pedantic. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/gen-attrs-1.C: Also run in C++98 mode. * g++.dg/cpp0x/gen-attrs-11.C: Likewise. * g++.dg/cpp0x/gen-attrs-13.C: Likewise. * g++.dg/cpp0x/gen-attrs-15.C: Likewise. * g++.dg/cpp0x/gen-attrs-75.C: Don't expect C++98 warning after __extension__.
2024-09-03pretty-print: naming cleanupsDavid Malcolm1-3/+3
This patch is a followup to r15-3311-ge31b6176996567 making some cleanups to pretty-printing to reflect those changes: - renaming "chunk_info" to "pp_formatted_chunks" - renaming "cur_chunk_array" to "m_cur_fomatted_chunks" - rewording/clarifying comments and taking the opportunity to add a "m_" prefix to all fields of output_buffer. No functional change intended. gcc/analyzer/ChangeLog: * analyzer-logging.cc (logger::logger): Prefix all output_buffer fields with "m_". gcc/c-family/ChangeLog: * c-ada-spec.cc (dump_ada_node): Prefix all output_buffer fields with "m_". * c-pretty-print.cc (pp_c_integer_constant): Likewise. (pp_c_integer_constant): Likewise. (pp_c_floating_constant): Likewise. (pp_c_fixed_constant): Likewise. gcc/c/ChangeLog: * c-objc-common.cc (print_type): Prefix all output_buffer fields with "m_". gcc/cp/ChangeLog: * error.cc (type_to_string): Prefix all output_buffer fields with "m_". (append_formatted_chunk): Likewise. Rename "chunk_info" to "pp_formatted_chunks" and field cur_chunk_array with m_cur_formatted_chunks. gcc/fortran/ChangeLog: * error.cc (gfc_move_error_buffer_from_to): Prefix all output_buffer fields with "m_". (gfc_diagnostics_init): Likewise. gcc/ChangeLog: * diagnostic.cc (diagnostic_set_caret_max_width): Prefix all output_buffer fields with "m_". * dumpfile.cc (emit_any_pending_textual_chunks): Likewise. (emit_any_pending_textual_chunks): Likewise. * gimple-pretty-print.cc (gimple_dump_bb_buff): Likewise. * json.cc (value::dump): Likewise. * pretty-print-format-impl.h (class chunk_info): Rename to... (class pp_formatted_chunks): ...this. Add friend class output_buffer. Update comment near end of decl to show the pp_formatted_chunks instance on the chunk_obstack. (pp_formatted_chunks::pop_from_output_buffer): Delete decl. (pp_formatted_chunks::on_begin_quote): Delete decl that should have been removed in r15-3311-ge31b6176996567. (pp_formatted_chunks::on_end_quote): Likewise. (pp_formatted_chunks::m_prev): Update for renaming. * pretty-print.cc (output_buffer::output_buffer): Prefix all fields with "m_". Rename "cur_chunk_array" to "m_cur_formatted_chunks". (output_buffer::~output_buffer): Prefix all fields with "m_". (output_buffer::push_formatted_chunks): New. (output_buffer::pop_formatted_chunks): New. (pp_write_text_to_stream): Prefix all output_buffer fields with "m_". (pp_write_text_as_dot_label_to_stream): Likewise. (pp_write_text_as_html_like_dot_to_stream): Likewise. (chunk_info::append_formatted_chunk): Rename to... (pp_formatted_chunks::append_formatted_chunk): ...this. (chunk_info::pop_from_output_buffer): Delete. (pretty_printer::format): Update leading comment to mention pushing pp_formatted_chunks, and to reflect changes in r15-3311-ge31b6176996567. Prefix all output_buffer fields with "m_". (pp_output_formatted_text): Update leading comment to mention popping a pp_formatted_chunks, and to reflect the changes in r15-3311-ge31b6176996567. Prefix all output_buffer fields with "m_" and rename "cur_chunk_array" to "m_cur_formatted_chunks". Replace call to chunk_info::pop_from_output_buffer with a call to output_buffer::pop_formatted_chunks. (pp_flush): Prefix all output_buffer fields with "m_". (pp_really_flush): Likewise. (pp_clear_output_area): Likewise. (pp_append_text): Likewise. (pretty_printer::remaining_character_count_for_line): Likewise. (pp_newline): Likewise. (pp_character): Likewise. (pp_markup::context::push_back_any_text): Likewise. * pretty-print.h (class chunk_info): Rename to... (class pp_formatted_chunks): ...this. (class output_buffer): Delete unimplemented rule-of-5 members. (output_buffer::push_formatted_chunks): New decl. (output_buffer::pop_formatted_chunks): New decl. (output_buffer::formatted_obstack): Rename to... (output_buffer::m_formatted_obstack): ...this. (output_buffer::chunk_obstack): Rename to... (output_buffer::m_chunk_obstack): ...this. (output_buffer::obstack): Rename to... (output_buffer::m_obstack): ...this. (output_buffer::cur_chunk_array): Rename to... (output_buffer::m_cur_formatted_chunks): ...this. (output_buffer::stream): Rename to... (output_buffer::m_stream): ...this. (output_buffer::line_length): Rename to... (output_buffer::m_line_length): ...this. (output_buffer::digit_buffer): Rename to... (output_buffer::m_digit_buffer): ...this. (output_buffer::flush_p): Rename to... (output_buffer::m_flush_p): ...this. (output_buffer_formatted_text): Prefix all output_buffer fields with "m_". (output_buffer_append_r): Likewise. (output_buffer_last_position_in_text): Likewise. (pretty_printer::set_output_stream): Likewise. (pp_scalar): Likewise. (pp_wide_int): Likewise. * tree-pretty-print.cc (dump_generic_node): Likewise. (dump_generic_node): Likewise. (pp_double_int): Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-08-29pretty-print: reimplement pp_format with a new struct pp_tokenDavid Malcolm1-48/+57
The following patch rewrites the internals of pp_format. A pretty_printer's output_buffer maintains a stack of chunk_info instances, each one responsible for handling a call to pp_format, where having a stack allows us to support re-entrant calls to pp_format on the same pretty_printer. Previously a chunk_info merely stored buffers of accumulated text per unformatted run and per formatted argument. This led to various special-casing for handling: - urlifiers, needing class quoting_info to handle awkard cases where the run of quoted text could be split between stages 1 and 2 of formatting - dumpfiles, where the optinfo machinery could lead to objects being stashed during formatting for later replay to JSON optimization records - in the C++ frontend, the format codes %H and %I can't be processed until we've seen both, leading to awkward code to manipulate the text buffers Further, supporting URLs in messages in SARIF output (PR other/116419) would add additional manipulations of text buffers, since our internal pp_begin_url API gives the URL at the beginning of the wrapped text, whereas SARIF's format for embedded URLs has the URL *after* the wrapped text. Also when handling "%@" we wouldn't necessarily know the URL of an event ID until later, requiring further nasty special-case manipulation of text buffers. This patch rewrites pretty-print formatting by introducing a new intermediate representation during formatting: pp_token and pp_token_list. Rather than simply accumulating a buffer of "char" in the chunk_obstack during formatting, we now also accumulate a pp_token_list, a doubly-linked list of pp_token, which can be: - text buffers - begin/end colorization - begin/end quote - begin/end URL - "custom data" tokens Working at the level of tokens rather than just text buffers allows the various awkward special cases above to be replaced with uniform logic. For example, all "urlification" is now done in phase 3 of formatting, in one place, by looking for [..., BEGIN_QUOTE, TEXT, END_QUOTE, ...] and injecting BEGIN_URL and END_URL wrapper tokens when the urlifier has a URL for TEXT. Doing so greatly simplifies the urlifier code, allowing the removal of class quoting_info. The tokens and token lists are allocated on the chunk_obstack, and so there's no additional heap activity required, with the memory reclaimed when the chunk_obstack is freed after phase 3 of formatting. New kinds of pp_token can be added as needed to support output formats. For example, the followup patch adds a token for "%@" for events IDs, to better support SARIF output. No functional change intended. gcc/c/ChangeLog: * c-objc-common.cc (c_tree_printer): Convert final param from const char ** to pp_token_list &. gcc/cp/ChangeLog: * error.cc: Include "make-unique.h". (deferred_printed_type::m_buffer_ptr): Replace with... (deferred_printed_type::m_printed_text): ...this and... (deferred_printed_type::m_token_list): ...this. (deferred_printed_type::deferred_printed_type): Update ctors for above changes. (deferred_printed_type::set_text_for_token_list): New. (append_formatted_chunk): Pass chunk_obstack to append_formatted_chunk. (add_quotes): Delete. (cxx_format_postprocessor::handle): Reimplement to call deferred_printed_type::set_text_for_token_list, rather than store buffer pointers. (defer_phase_2_of_type_diff): Replace param "buffer_ptr" with "formatted_token_list". Reimplement by storing a pointer to formatted_token_list so that the postprocessor can put its text there. (cp_printer): Convert param "buffer_ptr" to "formatted_token_list". Update calls to defer_phase_2_of_type_diff accordingly. gcc/ChangeLog: * diagnostic.cc (diagnostic_context::report_diagnostic): Don't pass m_urlifier to pp_format, as urlification now happens in phase 3. * dump-context.h (class dump_pretty_printer): Update leading comment. (dump_pretty_printer::emit_items): Drop decl. (dump_pretty_printer::set_optinfo): New. (class dump_pretty_printer::stashed_item): Delete class. (class dump_pretty_printer::custom_token_printer): New class. (dump_pretty_printer::format_decoder_cb): Convert param from const char ** to pp_token_list &. (dump_pretty_printer::decode_format): Likewise. (dump_pretty_printer::stash_item): Likewise. (dump_pretty_printer::emit_any_pending_textual_chunks): Drop decl. (dump_pretty_printer::m_stashed_items): Delete field. (dump_pretty_printer::m_token_printer): New member data. * dumpfile.cc (struct wrapped_optinfo_item): New. (dump_pretty_printer::dump_pretty_printer): Update for dropping of field m_stashed_items and new field m_token_printer. (dump_pretty_printer::emit_items): Delete; we now use pp_output_formatted_text.. (dump_pretty_printer::emit_any_pending_textual_chunks): Delete. (dump_pretty_printer::stash_item): Convert param from const char ** to pp_token_list &. (dump_pretty_printer::format_decoder_cb): Likewise. (dump_pretty_printer::decode_format): Likewise. (dump_pretty_printer::custom_token_printer::print_tokens): New. (dump_pretty_printer::custom_token_printer::emit_any_pending_textual_chunks): New. (dump_context::dump_printf_va): Call set_optinfo on the dump_pretty_printer. Replace call to emit_items with a call to pp_output_formatted_text. * opt-problem.cc (opt_problem::opt_problem): Replace call to emit_items with call to set_optinfo and call to pp_output_formatted_text. * pretty-print-format-impl.h (struct pp_token): New. (struct pp_token_text): New. (is_a_helper <pp_token_text *>::test): New. (is_a_helper <const pp_token_text *>::test): New. (struct pp_token_begin_color): New. (is_a_helper <pp_token_begin_color *>::test): New. (is_a_helper <const pp_token_begin_color *>::test): New. (struct pp_token_end_color): New. (struct pp_token_begin_quote): New. (struct pp_token_end_quote): New. (struct pp_token_begin_url): New. (is_a_helper <pp_token_begin_url*>::test): New. (is_a_helper <const pp_token_begin_url*>::test): New. (struct pp_token_end_url): New. (struct pp_token_custom_data): New. (is_a_helper <pp_token_custom_data *>::test): New. (is_a_helper <const pp_token_custom_data *>::test): New. (class pp_token_list): New. (chunk_info::get_args): Drop. (chunk_info::get_quoting_info): Drop. (chunk_info::get_token_lists): New accessor. (chunk_info::append_formatted_chunk): Add obstack & param. (chunk_info::dump): New decls. (chunk_info::m_args): Convert element type from const char * to pp_token_list *. Rewrite/update comment. (chunk_info::m_quotes): Drop field. * pretty-print-markup.h (class pp_token_list): New forward decl. (pp_markup::context::context): Drop urlifier param; add formatted_token_list param. (pp_markup::context::push_back_any_text): New decl. (pp_markup::context::m_urlifier): Drop field. (pp_markup::context::m_formatted_token_list): New field. * pretty-print-urlifier.h: Update comment. * pretty-print.cc: Define INCLUDE_MEMORY. Include "make-unique.h". (default_token_printer): New forward decl. (obstack_append_string): Delete. (urlify_quoted_string): Delete. (pp_token::pp_token): New. (pp_token::dump): New. (allocate_object): New. (class quoting_info): Delete. (pp_token::operator new): New. (pp_token::operator delete): New. (pp_token_list::operator new): New. (pp_token_list::operator delete): New. (pp_token_list::pp_token_list): New. (pp_token_list::~pp_token_list): New. (pp_token_list::push_back_text): New. (pp_token_list::push_back): New. (pp_token_list::push_back_list): New. (pp_token_list::pop_front): New. (pp_token_list::remove_token): New. (pp_token_list::insert_after): New. (pp_token_list::replace_custom_tokens): New. (pp_token_list::merge_consecutive_text_tokens): New. (pp_token_list::apply_urlifier): New. (pp_token_list::dump): New. (chunk_info::append_formatted_chunk): Add obstack & param and use it to reimplement in terms of token lists. (chunk_info::pop_from_output_buffer): Drop m_quotes. (chunk_info::on_begin_quote): Delete. (chunk_info::dump): New. (chunk_info::on_end_quote): Delete. (push_back_any_text): New. (pretty_printer::format): Drop "urlifier" param and quoting_info logic. Convert "formatters" and "args" from const ** to pp_token_list **. Reimplement so that rather than just accumulating a text buffer in the chunk_obstack for each arg, instead also accumulate a pp_token_list and pp_tokens for each arg. (auto_obstack::operator obstack &): New. (quoting_info::handle_phase_3): Delete. (pp_output_formatted_text): Reimplement in terms of manipulations of pp_token_lists, rather than char buffers. Call default_token_printer, or m_token_printer's print_tokens vfunc. (default_token_printer): New. (pretty_printer::pretty_printer): Initialize m_token_printer in both ctors. (pp_markup::context::begin_quote): Reimplement to use token list. (pp_markup::context::end_quote): Likewise. (pp_markup::context::begin_highlight_color): Likewise. (pp_markup::context::end_highlight_color): Likewise. (pp_markup::context::push_back_any_text): New. (selftest::test_merge_consecutive_text_tokens): New. (selftest::test_custom_tokens_1): New. (selftest::test_custom_tokens_2): New. (selftest::pp_printf_with_urlifier): Drop "urlifier" param from call to pp_format. (selftest::test_urlification): Add test of the example from pretty-print-format-impl.h. (selftest::pretty_print_cc_tests): Call the new selftest functions. * pretty-print.h (class quoting_info): Drop forward decl. (class pp_token_list): New forward decl. (printer_fn): Convert final param from const char ** to pp_token_list &. (class token_printer): New. (class pretty_printer): Add pp_output_formatted_text as friend. (pretty_printer::set_token_printer): New. (pretty_printer::format): Drop urlifier param as this now happens in phase 3. (pretty_printer::m_format_decoder): Update comment. (pretty_printer::m_token_printer): New field. (pp_format): Drop urlifier param. * tree-diagnostic.cc (default_tree_printer): Convert final param from const char ** to pp_token_list &. * tree-diagnostic.h: Likewise for decl. gcc/fortran/ChangeLog: * error.cc (gfc_format_decoder): Convert final param from const char **buffer_ptr to pp_token_list &formatted_token_list, and update call to default_tree_printer accordingly. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-08-29pretty-print: move class chunk_info into its own headerDavid Malcolm1-0/+1
No functional change intended. gcc/cp/ChangeLog: * error.cc: Include "pretty-print-format-impl.h". gcc/ChangeLog: * dumpfile.cc: Include "pretty-print-format-impl.h". * pretty-print-format-impl.h: New file, based on material from pretty-print.h. * pretty-print.cc: Include "pretty-print-format-impl.h". * pretty-print.h (chunk_info): Replace full declaration with a forward decl, moving full decl to pretty-print-format-impl.h. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-08-07c++: erroneous partial spec vs primary tmpl [PR116064]Patrick Palka1-1/+5
When a partial specialization is deemed erroneous at parse time, we currently flag the primary template as erroneous instead. Later at instantiation time we check if the primary template is erroneous rather than the selected partial specialization, so at least we're consistent. But it's better not to conflate a partial specialization with the primary template since they're instantiated independenty. This avoids rejecting the instantiation of A<int> in the below testcase. PR c++/116064 gcc/cp/ChangeLog: * error.cc (get_current_template): If the current scope is a partial specialization, return it instead of the primary template. * pt.cc (instantiate_class_template): Pass the partial specialization if any to maybe_diagnose_erroneous_template instead of the primary template. gcc/testsuite/ChangeLog: * g++.dg/template/permissive-error2.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
2024-08-07c++/modules: Ensure deduction guides are always reachable [PR115231]Nathaniel Shead1-0/+1
Deduction guides are represented as 'normal' functions currently, and have no special handling in modules. However, this causes some issues; by [temp.deduct.guide] a deduction guide is not found by normal name lookup and instead all reachable deduction guides for a class template should be considered, but this does not happen currently. To solve this, this patch ensures that all deduction guides are considered exported to ensure that they are always visible to importers if they are reachable. Another alternative here would be to add a new kind of "all reachable" flag to name lookup, but that is complicated by some difficulties in handling GM entities; this may be a better way to go if more kinds of entities end up needing this handling, however. Another issue here is that because deduction guides are "unrelated" functions, they will usually get discarded from the GMF, so this patch ensures that when finding dependencies, GMF deduction guides will also have bindings created. We do this in find_dependencies so that we don't unnecessarily create bindings for GMF deduction guides that are never reached; for consistency we do this for *all* deduction guides, not just GM ones. We also make sure that the opposite (a deduction guide being the only purview reference to a GMF template) correctly marks it as reachable. Finally, when merging deduction guides from multiple modules, the name lookup code may now return two-dimensional overload sets, so update callers to match. As a small drive-by improvement this patch also updates the error pretty printing code to add a space before the '->' when printing a deduction guide, so we get 'S(int) -> S<int>' instead of 'S(int)-> S<int>'. PR c++/115231 gcc/cp/ChangeLog: * error.cc (dump_function_decl): Add a space before '->' when printing deduction guides. * module.cc (depset::hash::add_binding_entity): Don't create bindings for guides here, only mark dependencies. (depset::hash::add_deduction_guides): New. (depset::hash::find_dependencies): Add deduction guide dependencies for a class template. (module_state::write_cluster): Always consider deduction guides as exported. * pt.cc (deduction_guides_for): Use 'lkp_iterator' instead of 'ovl_iterator'. gcc/testsuite/ChangeLog: * g++.dg/modules/dguide-1_a.C: New test. * g++.dg/modules/dguide-1_b.C: New test. * g++.dg/modules/dguide-2_a.C: New test. * g++.dg/modules/dguide-2_b.C: New test. * g++.dg/modules/dguide-3_a.C: New test. * g++.dg/modules/dguide-3_b.C: New test. * g++.dg/modules/dguide-3_c.C: New test. * g++.dg/modules/dguide-3_d.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
2024-08-06c++: permit errors inside uninstantiated templates [PR116064]Patrick Palka1-0/+67
In recent versions of GCC we've been diagnosing more and more kinds of errors inside a template ahead of time. This is a largely good thing because it catches bugs, typos, dead code etc sooner. But if the template never gets instantiated then such errors are harmless and can be inconvenient to work around if say the code in question is third party and in maintenance mode. So it'd be handy to be able to prevent these template errors from rendering the entire TU uncompilable. (Note that such code is "ill-formed no diagnostic required" according the standard.) To that end this patch turns any errors issued within a template into permerrors associated with a new -Wtemplate-body flag so that they can be downgraded via e.g. -fpermissive or -Wno-error=template-body. If the template containing a downgraded error later needs to be instantiated, we'll issue an error then. But if the template never gets instantiated then the downgraded error won't affect validity of the rest of the TU. This is implemented via a diagnostic hook that gets called for each diagnostic, and which adjusts an error diagnostic appropriately if we detect it's occurring from a template context, and additionally flags the template as erroneous. For example the new testcase permissive-error1a.C gives: gcc/testsuite/g++.dg/template/permissive-error1a.C: In function 'void f()': gcc/testsuite/g++.dg/template/permissive-error1a.C:7:5: warning: increment of read-only variable 'n' [-Wtemplate-body] 7 | ++n; | ^ ... gcc/testsuite/g++.dg/template/permissive-error1a.C: In instantiation of 'void f() [with T = int]': gcc/testsuite/g++.dg/template/permissive-error1a.C:26:9: required from here 26 | f<int>(); | ~~~~~~^~ gcc/testsuite/g++.dg/template/permissive-error1a.C:5:6: error: instantiating erroneous template 5 | void f() { | ^ gcc/testsuite/g++.dg/template/permissive-error1a.C:7:5: note: first error appeared here 7 | ++n; // { | ^ ... PR c++/116064 gcc/c-family/ChangeLog: * c.opt (Wtemplate-body): New warning. gcc/cp/ChangeLog: * cp-tree.h (erroneous_templates_t): Declare. (erroneous_templates): Declare. (cp_seen_error): Declare. (seen_error): #define to cp_seen_error. * error.cc (get_current_template): Define. (relaxed_template_errors): Define. (cp_adjust_diagnostic_info): Define. (cp_seen_error): Define. (cxx_initialize_diagnostics): Set diagnostic_context::m_adjust_diagnostic_info. * module.cc (finish_module_processing): Don't write the module if it contains an erroneous template. * pt.cc (maybe_diagnose_erroneous_template): Define. (instantiate_class_template): Call it. (instantiate_decl): Likewise. gcc/ChangeLog: * diagnostic.cc (diagnostic_context::initialize): Set m_adjust_diagnostic_info. (diagnostic_context::report_diagnostic): Call m_adjust_diagnostic_info. * diagnostic.h (diagnostic_context::m_adjust_diagnostic_info): New data member. * doc/invoke.texi (-Wno-template-body): Document. (-fpermissive): Mention -Wtemplate-body. gcc/testsuite/ChangeLog: * g++.dg/ext/typedef-init.C: Downgrade error inside template to warning due to -fpermissive. * g++.dg/pr84492.C: Likewise. * g++.old-deja/g++.pt/crash51.C: Remove unneeded dg-options. * g++.dg/template/permissive-error1.C: New test. * g++.dg/template/permissive-error1a.C: New test. * g++.dg/template/permissive-error1b.C: New test. * g++.dg/template/permissive-error1c.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
2024-08-05c++: remove function/var concepts codeMarek Polacek1-8/+3
This patch removes vestigial Concepts TS code as discussed in <https://gcc.gnu.org/pipermail/gcc-patches/2024-July/657937.html>. In particular, it removes code related to function/variable concepts. That includes variable_concept_p and function_concept_p, which then cascades into removing DECL_DECLARED_CONCEPT_P etc. So I think we no longer need to say "standard concept" since there are no non-standard ones anymore. I've added two new errors saying that "variable/function concepts are no longer supported". gcc/cp/ChangeLog: * constexpr.cc (cxx_eval_constant_expression): Don't call unpack_concept_check. Add a concept_check_p assert. Remove function_concept_p code. * constraint.cc (check_constraint_atom): Remove function concepts code. (unpack_concept_check): Remove. (get_concept_check_template): Remove Concepts TS code. (resolve_function_concept_overload): Remove. (resolve_function_concept_check): Remove. (resolve_concept_check): Remove Concepts TS code. (get_returned_expression): Remove. (get_variable_initializer): Remove. (get_concept_definition): Remove Concepts TS code. (normalize_concept_check): Likewise. (build_function_check): Remove. (build_variable_check): Remove. (build_standard_check): Use concept_definition_p instead of standard_concept_p. (build_concept_check): Remove variable_concept_p/function_concept_p code. (build_concept_id): Simplify. (build_type_constraint): Likewise. (placeholder_extract_concept_and_args): Likewise. (satisfy_nondeclaration_constraints): Likewise. (check_function_concept): Remove. (get_constraint_error_location): Remove Concepts TS code. * cp-tree.h (DECL_DECLARED_CONCEPT_P): Remove. (check_function_concept): Remove. (unpack_concept_check): Remove. (standard_concept_p): Remove. (variable_concept_p): Remove. (function_concept_p): Remove. (concept_definition_p): Simplify. (concept_check_p): Don't check for CALL_EXPR. * decl.cc (check_concept_refinement): Remove. (duplicate_decls): Remove check_concept_refinement code. (is_concept_var): Remove. (cp_finish_decl): Remove is_concept_var. (check_concept_fn): Remove. (grokfndecl): Give an error about function concepts not being supported anymore. Remove unused code. (grokvardecl): Give an error about variable concepts not being supported anymore. (finish_function): Remove DECL_DECLARED_CONCEPT_P code. * decl2.cc (min_vis_expr_r): Use concept_definition_p instead of standard_concept_p. (maybe_instantiate_decl): Remove DECL_DECLARED_CONCEPT_P check. (mark_used): Likewise. * error.cc (dump_simple_decl): Use concept_definition_p instead of standard_concept_p. (dump_function_decl): Remove DECL_DECLARED_CONCEPT_P code. (print_concept_check_info): Don't call unpack_concept_check. Simplify. * mangle.cc (write_type_constraint): Likewise. * parser.cc (cp_parser_nested_name_specifier_opt): Remove function_concept_p code. Only check concept_definition_p, not variable_concept_p/standard_concept_p. (add_debug_begin_stmt): Remove DECL_DECLARED_CONCEPT_P code. (cp_parser_template_declaration_after_parameters): Remove a stale comment. * pt.cc (check_explicit_specialization): Remove DECL_DECLARED_CONCEPT_P code. (process_partial_specialization): Remove variable_concept_p code. (lookup_template_variable): Likewise. (tsubst_expr) <case CALL_EXPR>: Remove Concepts TS code and simplify. (do_decl_instantiation): Remove DECL_DECLARED_CONCEPT_P code. (instantiate_decl): Likewise. (placeholder_type_constraint_dependent_p): Don't call unpack_concept_check. Add a concept_check_p assert. (convert_generic_types_to_packs): Likewise. * semantics.cc (finish_call_expr): Remove Concepts TS code and simplify. gcc/testsuite/ChangeLog: * g++.dg/concepts/decl-diagnose.C: Adjust dg-error. * g++.dg/concepts/fn-concept2.C: Likewise. * g++.dg/concepts/pr71128.C: Likewise. * g++.dg/concepts/var-concept6.C: Likewise. * g++.dg/cpp2a/concepts.C: Likewise.