static output_buffer *pp_error_buffer, *pp_warning_buffer;
static int warningcount_buffered, werrorcount_buffered;
+
+/* Return a location_t suitable for 'tree' for a gfortran locus. During
+ parsing in gfortran, loc->lb->location contains only the line number
+ and LOCATION_COLUMN is 0; hence, the column has to be added when generating
+ locations for 'tree'. */
+
+location_t
+gfc_get_location_with_offset (locus *loc, unsigned offset)
+{
+ gcc_checking_assert (loc->nextc >= loc->lb->line);
+ return linemap_position_for_loc_and_offset (line_table, loc->lb->location,
+ loc->nextc - loc->lb->line
+ + offset);
+}
+
/* Return buffered_p. */
bool
gfc_buffered_p (void)
int precision, bool wide, bool set_locus, bool hash,
bool *quoted, pp_token_list &formatted_token_list)
{
+ unsigned offset = 0;
switch (*spec)
{
case 'C':
static const char *result[2] = { "(1)", "(2)" };
locus *loc;
if (*spec == 'C')
- loc = &gfc_current_locus;
+ {
+ loc = &gfc_current_locus;
+ /* Point %C first offending character not the last good one. */
+ if (*loc->nextc != '\0')
+ offset++;
+ }
else
loc = va_arg (*text->m_args_ptr, locus *);
- gcc_assert (loc->nextc - loc->lb->line >= 0);
- unsigned int offset = loc->nextc - loc->lb->line;
- if (*spec == 'C' && *loc->nextc != '\0')
- /* Point %C first offending character not the last good one. */
- offset++;
+
/* If location[0] != UNKNOWN_LOCATION means that we already
processed one of %C/%L. */
int loc_num = text->get_location (0) == UNKNOWN_LOCATION ? 0 : 1;
- location_t src_loc
- = linemap_position_for_loc_and_offset (line_table,
- loc->lb->location,
- offset);
+ location_t src_loc = gfc_get_location_with_offset (loc, offset);
text->set_location (loc_num, src_loc, SHOW_RANGE_WITH_CARET);
/* Colorize the markers to match the color choices of
diagnostic_show_locus (the initial location has a color given
bool gfc_find_sym_in_expr (gfc_symbol *, gfc_expr *);
/* error.cc */
+location_t gfc_get_location_with_offset (locus *, unsigned);
+inline location_t
+gfc_get_location (locus *loc)
+{
+ return gfc_get_location_with_offset (loc, 0);
+}
+
void gfc_error_init_1 (void);
void gfc_diagnostics_init (void);
void gfc_diagnostics_finish (void);
const char gfc_msg_fault[] = N_("Array reference out of bounds");
-/* Return a location_t suitable for 'tree' for a gfortran locus. The way the
- parser works in gfortran, loc->lb->location contains only the line number
- and LOCATION_COLUMN is 0; hence, the column has to be added when generating
- locations for 'tree'. Cf. error.cc's gfc_format_decoder. */
-
-location_t
-gfc_get_location (locus *loc)
-{
- return linemap_position_for_loc_and_offset (line_table, loc->lb->location,
- loc->nextc - loc->lb->line);
-}
-
/* Advance along TREE_CHAIN n times. */
tree
/* Allocate the lang-specific part of a decl node. */
void gfc_allocate_lang_decl (tree);
-/* Get the location suitable for the ME from a gfortran locus; required to get
- the column number right. */
-location_t gfc_get_location (locus *);
-
/* Advance along a TREE_CHAIN. */
tree gfc_advance_chain (tree, int);