summaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authormanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>2014-11-11 22:50:48 +0000
committermanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>2014-11-11 22:50:48 +0000
commit766928aa6ac2c846c2d098ef4ef9e220feb4dcab (patch)
tree131a5405db6b77d647e372c65ba2c7ec3a8b9360 /libcpp
parent9fcfed2eb95fea03d967dfcadd1eec9cbab4a744 (diff)
downloadgcc-766928aa6ac2c846c2d098ef4ef9e220feb4dcab.tar.gz
libcpp/ChangeLog:
2014-11-11 Manuel López-Ibáñez <manu@gcc.gnu.org> PR fortran/44054 * include/line-map.h (linemap_position_for_loc_and_offset): Declare. * line-map.c (linemap_position_for_loc_and_offset): New. gcc/fortran/ChangeLog: 2014-11-11 Manuel López-Ibáñez <manu@gcc.gnu.org> PR fortran/44054 * gfortran.h (warn_use_without_only): Remove. (gfc_diagnostics_finish): Declare. * error.c: Include tree-diagnostics.h (gfc_format_decoder): New. (gfc_diagnostics_init): Use gfc_format_decoder. Set default caret char. (gfc_diagnostics_finish): Restore tree diagnostics defaults, but keep gfc_diagnostics_starter and finalizer. Restore default caret. * options.c: Remove all uses of warn_use_without_only. * lang.opt (Wuse-without-only): Add Var. * f95-lang.c (gfc_be_parse_file): Call gfc_diagnostics_finish. * module.c (gfc_use_module): Use gfc_warning_now_2. * parse.c (decode_statement): Likewise. (decode_gcc_attribute): Likewise. (next_free): Likewise. (next_fixed): Likewise. gcc/testsuite/ChangeLog: 2014-11-11 Manuel López-Ibáñez <manu@gcc.gnu.org> PR fortran/44054 * lib/gfortran-dg.exp: Update regexp to match locus and message without caret. * gfortran.dg/use_without_only_1.f90: Add column numbers. * gfortran.dg/warnings_are_errors_1.f: Update. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@217383 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog7
-rw-r--r--libcpp/include/line-map.h8
-rw-r--r--libcpp/line-map.c44
3 files changed, 59 insertions, 0 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index aa860b5ff1f..b75d521cf9f 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,10 @@
+2014-11-11 Manuel López-Ibáñez <manu@gcc.gnu.org>
+
+ PR fortran/44054
+ * include/line-map.h (linemap_position_for_loc_and_offset):
+ Declare.
+ * line-map.c (linemap_position_for_loc_and_offset): New.
+
2014-11-11 David Malcolm <dmalcolm@redhat.com>
* ChangeLog.jit: New.
diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h
index 1f6553c9468..2fcee1906be 100644
--- a/libcpp/include/line-map.h
+++ b/libcpp/include/line-map.h
@@ -603,6 +603,14 @@ source_location
linemap_position_for_line_and_column (const struct line_map *,
linenum_type, unsigned int);
+/* Encode and return a source_location starting from location LOC and
+ shifting it by OFFSET columns. This function does not support
+ virtual locations. */
+source_location
+linemap_position_for_loc_and_offset (struct line_maps *set,
+ source_location loc,
+ unsigned int offset);
+
/* Return the file this map is for. */
#define LINEMAP_FILE(MAP) \
(linemap_check_ordinary (MAP)->d.ordinary.to_file)
diff --git a/libcpp/line-map.c b/libcpp/line-map.c
index d10d578f62e..aff0294936c 100644
--- a/libcpp/line-map.c
+++ b/libcpp/line-map.c
@@ -633,6 +633,50 @@ linemap_position_for_line_and_column (const struct line_map *map,
+ (column & ((1 << ORDINARY_MAP_NUMBER_OF_COLUMN_BITS (map)) - 1)));
}
+/* Encode and return a source_location starting from location LOC and
+ shifting it by OFFSET columns. This function does not support
+ virtual locations. */
+
+source_location
+linemap_position_for_loc_and_offset (struct line_maps *set,
+ source_location loc,
+ unsigned int offset)
+{
+ const struct line_map * map = NULL;
+
+ /* This function does not support virtual locations yet. */
+ linemap_assert (!linemap_location_from_macro_expansion_p (set, loc));
+
+ if (offset == 0
+ /* Adding an offset to a reserved location (like
+ UNKNOWN_LOCATION for the C/C++ FEs) does not really make
+ sense. So let's leave the location intact in that case. */
+ || loc < RESERVED_LOCATION_COUNT)
+ return loc;
+
+ /* We find the real location and shift it. */
+ loc = linemap_resolve_location (set, loc, LRK_SPELLING_LOCATION, &map);
+ /* The new location (loc + offset) should be higher than the first
+ location encoded by MAP. */
+ linemap_assert (MAP_START_LOCATION (map) < loc + offset);
+
+ /* If MAP is not the last line map of its set, then the new location
+ (loc + offset) should be less than the first location encoded by
+ the next line map of the set. */
+ if (map != LINEMAPS_LAST_ORDINARY_MAP (set))
+ linemap_assert (loc + offset < MAP_START_LOCATION (&map[1]));
+
+ offset += SOURCE_COLUMN (map, loc);
+ linemap_assert (offset < (1u << map->d.ordinary.column_bits));
+
+ source_location r =
+ linemap_position_for_line_and_column (map,
+ SOURCE_LINE (map, loc),
+ offset);
+ linemap_assert (map == linemap_lookup (set, r));
+ return r;
+}
+
/* Given a virtual source location yielded by a map (either an
ordinary or a macro map), returns that map. */