diff options
author | David Malcolm <dmalcolm@redhat.com> | 2024-12-06 11:29:54 -0500 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2024-12-06 11:29:54 -0500 |
commit | 4f5b7f1b738f7206402d008e52718abfd78e2a07 (patch) | |
tree | d5dcd7520031ad82b22517e3680ba3c8af790584 /gcc | |
parent | a1fa104f2dde3ab185397f41a300f7a0ee04d5f2 (diff) | |
download | gcc-4f5b7f1b738f7206402d008e52718abfd78e2a07.zip gcc-4f5b7f1b738f7206402d008e52718abfd78e2a07.tar.gz gcc-4f5b7f1b738f7206402d008e52718abfd78e2a07.tar.bz2 |
c++: consolidate location printing in error.cc [PR116253]
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>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/error.cc | 71 |
1 files changed, 24 insertions, 47 deletions
diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc index ce8d5b1..b3ab8fa 100644 --- a/gcc/cp/error.cc +++ b/gcc/cp/error.cc @@ -3828,6 +3828,20 @@ print_instantiation_full_context (diagnostic_text_output_format &text_output) print_instantiation_partial_context (text_output, p, location); } +static void +print_location (diagnostic_text_output_format &text_output, + location_t loc) +{ + expanded_location xloc = expand_location (loc); + pretty_printer *const pp = text_output.get_printer (); + if (text_output.show_column_p ()) + pp_verbatim (pp, _("%r%s:%d:%d:%R "), + "locus", xloc.file, xloc.line, xloc.column); + else + pp_verbatim (pp, _("%r%s:%d:%R "), + "locus", xloc.file, xloc.line); +} + /* Helper function of print_instantiation_partial_context() that prints a single line of instantiation context. */ @@ -3839,17 +3853,10 @@ print_instantiation_partial_context_line (diagnostic_text_output_format &text_ou if (loc == UNKNOWN_LOCATION) return; - expanded_location xloc = expand_location (loc); + print_location (text_output, loc); pretty_printer *const pp = text_output.get_printer (); - if (text_output.show_column_p ()) - pp_verbatim (pp, _("%r%s:%d:%d:%R "), - "locus", xloc.file, xloc.line, xloc.column); - else - pp_verbatim (pp, _("%r%s:%d:%R "), - "locus", xloc.file, xloc.line); - if (t != NULL) { if (t->list_p ()) @@ -3922,22 +3929,11 @@ print_instantiation_partial_context (diagnostic_text_output_format &text_output, } if (t != NULL && skip > 0) { - expanded_location xloc; - xloc = expand_location (loc); - pretty_printer *const pp = text_output.get_printer (); - if (text_output.show_column_p ()) - pp_verbatim (pp, - _("%r%s:%d:%d:%R [ skipping %d instantiation " - "contexts, use -ftemplate-backtrace-limit=0 to " - "disable ]\n"), - "locus", xloc.file, xloc.line, xloc.column, skip); - else - pp_verbatim (pp, - _("%r%s:%d:%R [ skipping %d instantiation " - "contexts, use -ftemplate-backtrace-limit=0 to " - "disable ]\n"), - "locus", xloc.file, xloc.line, skip); - + print_location (text_output, loc); + pp_verbatim (text_output.get_printer (), + _("[ skipping %d instantiation contexts," + " use -ftemplate-backtrace-limit=0 to disable ]\n"), + skip); do { loc = t->locus; t = t->next; @@ -3983,37 +3979,18 @@ maybe_print_constexpr_context (diagnostic_text_output_format &text_output) FOR_EACH_VEC_ELT (call_stack, ix, t) { - expanded_location xloc = expand_location (EXPR_LOCATION (t)); const char *s = expr_as_string (t, 0); pretty_printer *const pp = text_output.get_printer (); - if (text_output.show_column_p ()) - pp_verbatim (pp, - _("%r%s:%d:%d:%R in %<constexpr%> expansion of %qs"), - "locus", xloc.file, xloc.line, xloc.column, s); - else - pp_verbatim (pp, - _("%r%s:%d:%R in %<constexpr%> expansion of %qs"), - "locus", xloc.file, xloc.line, s); + print_location (text_output, EXPR_LOCATION (t)); + pp_verbatim (pp, + _("in %<constexpr%> expansion of %qs"), + s); pp_newline (pp); } } static void -print_location (diagnostic_text_output_format &text_output, - location_t loc) -{ - expanded_location xloc = expand_location (loc); - pretty_printer *const pp = text_output.get_printer (); - if (text_output.show_column_p ()) - pp_verbatim (pp, _("%r%s:%d:%d:%R "), - "locus", xloc.file, xloc.line, xloc.column); - else - pp_verbatim (pp, _("%r%s:%d:%R "), - "locus", xloc.file, xloc.line); -} - -static void print_constrained_decl_info (diagnostic_text_output_format &text_output, tree decl) { |