From d681c5211e613c64d149e734b15cdcf7d542342e Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Tue, 25 Jun 2024 20:26:30 -0400 Subject: diagnostics: eliminate various implicit uses of global_dc This patch eliminates all implicit uses of "global_dc" from the path-printing logic and from gcc_rich_location::add_location_if_nearby. No functional change intended. gcc/c/ChangeLog: * c-parser.cc (c_parser_require): Pass *global_dc to gcc_rich_location::add_location_if_nearby. gcc/cp/ChangeLog: * parser.cc (cp_parser_error_1): Pass *global_dc to gcc_rich_location::add_location_if_nearby. (cp_parser_decl_specifier_seq): Likewise. (cp_parser_set_storage_class): Likewise. (cp_parser_set_storage_class): Likewise. gcc/ChangeLog: * diagnostic-path.cc (class path_label): Add m_path field, and use it to replace all uses of global_dc. (event_range::event_range): Add "ctxt" param and use it to construct m_path_label. (event_range::maybe_add_event): Add "ctxt" param and pass it to gcc_rich_location::add_location_if_nearby. (path_summary::path_summary): Add "ctxt" param and pass it to event_range::maybe_add_event. (diagnostic_context::print_path): Pass *this to path_summary ctor. (selftest::test_empty_path): Use "dc" when constructing path_summary rather than implicitly using global_dc. (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. (selftest::diagnostic_path_cc_tests): Eliminate use of global_dc. * diagnostic-show-locus.cc (gcc_rich_location::add_location_if_nearby): Add "ctxt" param and use it instead of implicitly using global_dc. (selftest::test_add_location_if_nearby): Use test_diagnostic_context rather than implicitly using global_dc. * diagnostic.cc (pedantic_warning_kind): Delete macro. (permissive_error_kind): Delete macro. (permissive_error_option): Delete macro. (diagnostic_context::diagnostic_enabled): Remove use of permissive_error_option. (diagnostic_context::report_diagnostic): Remove use of pedantic_warning_kind. (diagnostic_impl): Convert to... (diagnostic_context::diagnostic_impl): ...this. (diagnostic_n_impl): Convert to... (diagnostic_context::diagnostic_n_impl): ...this. (emit_diagnostic): Explicitly use global_dc for method call. (emit_diagnostic_valist): Likewise. (emit_diagnostic_valist_meta): Likewise. (inform): Likewise. (inform_n): Likewise. (warning): Likewise. (warning_at): Likewise. (warning_meta): Likewise. (warning_n): Likewise. (pedwarn): Likewise. (permerror): Likewise. (permerror_opt): Likewise. (error): Likewise. (error_n): Likewise. (error_at): Likewise. (error_meta): Likewise. (sorry): Likewise. (sorry_at): Likewise. (fatal_error): Likewise. (internal_error): Likewise. (internal_error_no_backtrace): Likewise. * diagnostic.h (diagnostic_context::diagnostic_impl): New decl. (diagnostic_context::diagnostic_n_impl): New decl. * gcc-rich-location.h (gcc_rich_location::add_location_if_nearby): Add "ctxt" param. Signed-off-by: David Malcolm --- gcc/cp/parser.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'gcc/cp') diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index e5f16fe..26734be 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -3297,7 +3297,8 @@ cp_parser_error_1 (cp_parser* parser, const char* gmsgid, secondary range within the main diagnostic. */ if (matching_location != UNKNOWN_LOCATION) added_matching_location - = richloc.add_location_if_nearby (matching_location); + = richloc.add_location_if_nearby (*global_dc, + matching_location); } /* If we were parsing a string-literal and there is an unknown name @@ -16651,7 +16652,7 @@ cp_parser_decl_specifier_seq (cp_parser* parser, break; gcc_rich_location richloc (token->location); location_t oloc = decl_specs->locations[ds_storage_class]; - richloc.add_location_if_nearby (oloc); + richloc.add_location_if_nearby (*global_dc, oloc); error_at (&richloc, "% specifier conflicts with %qs", cp_storage_class_name[decl_specs->storage_class]); @@ -34429,7 +34430,8 @@ cp_parser_set_storage_class (cp_parser *parser, if (decl_specs->conflicting_specifiers_p) return; gcc_rich_location richloc (token->location); - richloc.add_location_if_nearby (decl_specs->locations[ds_storage_class]); + richloc.add_location_if_nearby (*global_dc, + decl_specs->locations[ds_storage_class]); if (decl_specs->storage_class == storage_class) error_at (&richloc, "duplicate %qD specifier", ridpointers[keyword]); else @@ -34460,7 +34462,8 @@ cp_parser_set_storage_class (cp_parser *parser, && !decl_specs->conflicting_specifiers_p) { gcc_rich_location richloc (token->location); - richloc.add_location_if_nearby (decl_specs->locations[ds_typedef]); + richloc.add_location_if_nearby (*global_dc, + decl_specs->locations[ds_typedef]); error_at (&richloc, "%qD specifier conflicts with %", ridpointers[keyword]); -- cgit v1.1