line-map.c (linemap_position_for_loc_and_offset): Add new linemap_assert_fails.
authorManuel López-Ibáñez <manu@gcc.gnu.org>
Thu, 4 Dec 2014 23:35:29 +0000 (23:35 +0000)
committerManuel López-Ibáñez <manu@gcc.gnu.org>
Thu, 4 Dec 2014 23:35:29 +0000 (23:35 +0000)
libcpp/ChangeLog:

2014-12-05  Manuel López-Ibáñez  <manu@gcc.gnu.org>

* line-map.c (linemap_position_for_loc_and_offset): Add new
linemap_assert_fails.

gcc/fortran/ChangeLog:

2014-12-05  Manuel López-Ibáñez  <manu@gcc.gnu.org>

* scanner.c (gfc_next_char_literal): Use gfc_warning_now.
(load_file): Use the line length as the column hint for
linemap_line_start. Reserve a location for the highest column of
the line.

From-SVN: r218407

gcc/fortran/ChangeLog
gcc/fortran/scanner.c
gcc/testsuite/ChangeLog
libcpp/ChangeLog
libcpp/line-map.c

index c645b6fd401faee185411b09cdf82882a0bcbe1d..95605b7089d1e4de60092797b6c600a6815d2689 100644 (file)
@@ -1,3 +1,10 @@
+2014-12-05  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+
+       * scanner.c (gfc_next_char_literal): Use gfc_warning_now.
+       (load_file): Use the line length as the column hint for
+       linemap_line_start. Reserve a location for the highest column of
+       the line.
+
 2014-12-03  Manuel López-Ibáñez  <manu@gcc.gnu.org>
 
        PR fortran/44054
index 0de09983c23349164122c1fa6f10f2c7b28cfd7d..718c323a5cc5e1679229089747958b4d674cdca7 100644 (file)
@@ -1056,7 +1056,8 @@ restart:
 
          gfc_current_locus.lb->truncated = 0;
          gfc_current_locus.nextc =  gfc_current_locus.lb->line + maxlen;
-         gfc_warning_now_1 ("Line truncated at %L", &gfc_current_locus);
+         gfc_warning_now (OPT_Wline_truncation,
+                          "Line truncated at %L", &gfc_current_locus);
          gfc_current_locus.nextc = current_nextc;
        }
 
@@ -1195,7 +1196,8 @@ restart:
          && gfc_current_locus.lb->truncated)
        {
          gfc_current_locus.lb->truncated = 0;
-         gfc_warning_now_1 ("Line truncated at %L", &gfc_current_locus);
+         gfc_warning_now (OPT_Wline_truncation,
+                          "Line truncated at %L", &gfc_current_locus);
        }
 
       prev_openmp_flag = openmp_flag;
@@ -2044,7 +2046,13 @@ load_file (const char *realfilename, const char *displayedname, bool initial)
                    + (len + 1) * sizeof (gfc_char_t));
 
       b->location
-       = linemap_line_start (line_table, current_file->line++, 120);
+       = linemap_line_start (line_table, current_file->line++, len);
+      /* ??? We add the location for the maximum column possible here,
+        because otherwise if the next call creates a new line-map, it
+        will not reserve space for any offset.  */
+      if (len > 0)
+       linemap_position_for_column (line_table, len);
+
       b->file = current_file;
       b->truncated = trunc;
       wide_strcpy (b->line, line);
index 295a8103accf465eb17630243fde228a1eef70d8..29802cd7c9440ac4a9f92b5295ad549ff6dd40fe 100644 (file)
@@ -1,3 +1,7 @@
+2014-12-05  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+
+       * gfortran.dg/line_length_5.f90: New test.
+
 2014-12-04  Sriraman Tallam  <tmsriram@google.com>
            H.J. Lu  <hongjiu.lu@intel.com>
 
index afb0f791f2c5a8c7838eda52721f5b4a5e889b9f..e26c8c9b5994185deed24289ec1553e0b5e73510 100644 (file)
@@ -1,3 +1,8 @@
+2014-12-05  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+
+       * line-map.c (linemap_position_for_loc_and_offset): Add new
+       linemap_assert_fails.
+
 2014-12-02  Manuel López-Ibáñez  <manu@gcc.gnu.org>
 
        * include/line-map.h (linemap_assert_fails): Declare.
index 6a695ab0f1bb6d74a39da39358e9d17e5dd85a42..6675634fa9763dde84737fdf446a7c8349cd5da2 100644 (file)
@@ -678,7 +678,8 @@ linemap_position_for_loc_and_offset (struct line_maps *set,
     linemap_position_for_line_and_column (map,
                                          SOURCE_LINE (map, loc),
                                          offset);
-  if (linemap_assert_fails (map == linemap_lookup (set, r)))
+  if (linemap_assert_fails (r <= set->highest_location)
+      || linemap_assert_fails (map == linemap_lookup (set, r)))
     return loc;
 
   return r;