diff options
author | manu <manu@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-05-16 12:31:00 +0000 |
---|---|---|
committer | manu <manu@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-05-16 12:31:00 +0000 |
commit | 389a90090343044071c1f6d1e00be17b76504040 (patch) | |
tree | e38c12f0ed89361988c13ec74581d698238467a0 /gcc/diagnostic.h | |
parent | 091723223d8d2b0dd7da37c1e94a67cfcaf5b69b (diff) | |
download | gcc-389a90090343044071c1f6d1e00be17b76504040.tar.gz |
gcc/fortran/ChangeLog:
2015-05-16 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR fortran/44054
Replace all calls to gfc_notify_std_1 with gfc_notify_std and
gfc_warning_1 with gfc_warning.
* decl.c (gfc_verify_c_interop_param): Here.
* resolve.c (resolve_branch): Here.
(resolve_fl_derived): Here.
* dependency.c (gfc_check_argument_var_dependency):
* scanner.c (preprocessor_line): Use gfc_warning_now_at. Fix line
counter and locations before and after warning.
* gfortran.h (gfc_warning_1, gfc_warning_now_1, gfc_notify_std_1):
Delete.
(gfc_warning_now_at): Declare.
* error.c (gfc_warning_1): Delete.
(gfc_notify_std_1): Delete.
(gfc_warning_now_1): Delete.
(gfc_format_decoder): Handle two locations.
(gfc_diagnostic_build_prefix): Rename as
gfc_diagnostic_build_kind_prefix.
(gfc_diagnostic_build_locus_prefix): Take an expanded_location
instead of diagnostic_info.
(gfc_diagnostic_build_locus_prefix): Add overload that takes two
expanded_location.
(gfc_diagnostic_starter): Handle two locations.
(gfc_warning_now_at): New.
(gfc_diagnostics_init): Initialize caret_chars array.
(gfc_diagnostics_finish): Reset caret_chars array to default.
gcc/cp/ChangeLog:
2015-05-16 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR fortran/44054
* error.c (cp_diagnostic_starter): Use diagnostic_location
function.
(cp_print_error_function): Likewise.
(cp_printer): Replace locus pointer with accessor function.
gcc/c/ChangeLog:
2015-05-16 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR fortran/44054
* c-objc-common.c (c_tree_printer): Replace locus pointer with
accessor function.
gcc/ChangeLog:
2015-05-16 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR fortran/44054
* tree-pretty-print.c (percent_K_format): Replace locus pointer
with accessor function.
* tree-diagnostic.c (diagnostic_report_current_function): Use
diagnostic_location function.
(maybe_unwind_expanded_macro_loc): Likewise.
(virt_loc_aware_diagnostic_finalizer): Likewise.
(default_tree_printer): Replace locus pointer with accessor function.
* diagnostic.c (diagnostic_initialize): Initialize caret_chars array.
(diagnostic_set_info_translated): Initialize second location.
(diagnostic_build_prefix): Use CARET_LINE_MARGIN.
(diagnostic_show_locus): Handle two locations. Call
diagnostic_print_caret_line.
(diagnostic_print_caret_line): New.
(default_diagnostic_starter): Use diagnostic_location function.
(diagnostic_report_diagnostic): Use diagnostic_location function.
(verbatim): Do not set text.locus.
* diagnostic.h (struct diagnostic_info): Remove location field.
(struct diagnostic_context): Make caret_chars an array of two.
(diagnostic_location): New inline.
(diagnostic_expand_location): Handle two locations.
(diagnostic_same_line): New inline.
(diagnostic_print_caret_line): Declare.
(CARET_LINE_MARGIN): New constant.
* pretty-print.c (pp_printf): Do not set text.locus.
(pp_verbatim): Do not set text.locus.
* pretty-print.h (MAX_LOCATIONS_PER_MESSAGE): New constant.
(struct text_info): Replace locus pointer with locations
array. Add accessor functions.
gcc/testsuite/ChangeLog:
2015-05-16 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR fortran/44054
* lib/gfortran-dg.exp: Update regex to handle two locations for
the same diagnostic without caret.
* gfortran.dg/badline.f: Test also that line numbers are correct
before and after "left but not entered" warning.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223237 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/diagnostic.h')
-rw-r--r-- | gcc/diagnostic.h | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h index 02434d83200..1b9b7d42865 100644 --- a/gcc/diagnostic.h +++ b/gcc/diagnostic.h @@ -29,8 +29,9 @@ along with GCC; see the file COPYING3. If not see list in diagnostic.def. */ struct diagnostic_info { + /* Text to be formatted. It also contains the location(s) for this + diagnostic. */ text_info message; - location_t location; unsigned int override_column; /* Auxiliary data for client. */ void *x_data; @@ -105,8 +106,8 @@ struct diagnostic_context /* Maximum width of the source line printed. */ int caret_max_width; - /* Character used for caret diagnostics. */ - char caret_char; + /* Characters used for caret diagnostics. */ + char caret_chars[MAX_LOCATIONS_PER_MESSAGE]; /* True if we should print the command line option which controls each diagnostic, if known. */ @@ -300,18 +301,53 @@ void diagnostic_file_cache_fini (void); int get_terminal_width (void); -/* Expand the location of this diagnostic. Use this function for consistency. */ +/* Return the location associated to this diagnostic. Parameter WHICH + specifies which location. By default, expand the first one. */ + +static inline location_t +diagnostic_location (const diagnostic_info * diagnostic, int which = 0) +{ + return diagnostic->message.get_location (which); +} + +/* Expand the location of this diagnostic. Use this function for + consistency. Parameter WHICH specifies which location. By default, + expand the first one. */ static inline expanded_location -diagnostic_expand_location (const diagnostic_info * diagnostic) +diagnostic_expand_location (const diagnostic_info * diagnostic, int which = 0) { expanded_location s - = expand_location_to_spelling_point (diagnostic->location); - if (diagnostic->override_column) + = expand_location_to_spelling_point (diagnostic_location (diagnostic, + which)); + if (which == 0 && diagnostic->override_column) s.column = diagnostic->override_column; return s; } +/* This is somehow the right-side margin of a caret line, that is, we + print at least these many characters after the position pointed at + by the caret. */ +#define CARET_LINE_MARGIN 10 + +/* Return true if the two locations can be represented within the same + caret line. This is used to build a prefix and also to determine + whether to print one or two caret lines. */ + +static inline bool +diagnostic_same_line (const diagnostic_context *context, + expanded_location s1, expanded_location s2) +{ + return s2.column && s1.line == s2.line + && context->caret_max_width - CARET_LINE_MARGIN > abs (s1.column - s2.column); +} + +void +diagnostic_print_caret_line (diagnostic_context * context, + expanded_location xloc1, + expanded_location xloc2, + char caret1, char caret2); + /* Pure text formatting support functions. */ extern char *file_name_as_prefix (diagnostic_context *, const char *); |