re PR preprocessor/20907 (long comments throw off line numbers)
authorPer Bothner <per@bothner.com>
Thu, 21 Apr 2005 17:08:27 +0000 (10:08 -0700)
committerPer Bothner <bothner@gcc.gnu.org>
Thu, 21 Apr 2005 17:08:27 +0000 (10:08 -0700)
PR preprocessor/20907
* line-map.c (linemap_line_start): Fix bug when we need to increse
column_bits but can re-use the current line_map.

From-SVN: r98515

libcpp/ChangeLog
libcpp/line-map.c

index 7050d65189efa0c4be5ba9a599af27d9634f6ff7..1a8fccf5ce1105c8eb6ce93f526d09801b92e5be 100644 (file)
@@ -1,3 +1,9 @@
+2005-04-19  Per Bothner  <per@bothner.com>
+
+       PR preprocessor/20907
+       * line-map.c (linemap_line_start): Fix bug when we need to increse
+       column_bits but can re-use the current line_map.
+
 2005-04-19  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * system.h (fopen, fdopen, freopen): Define these to the unlocked
index e6dd48df7562f5506280a1861b3d2f01e39d0502..1ace4c9585d160d0c11c4a02fea6ebb4ae792454 100644 (file)
@@ -199,6 +199,8 @@ linemap_line_start (struct line_maps *set, unsigned int to_line,
       int column_bits;
       if (max_column_hint > 100000 || highest > 0xC0000000)
        {
+         /* If the column number is ridiculous or we've allocated a huge
+            number of source_locations, give up on column numbers. */
          max_column_hint = 0;
          if (highest >0xF0000000)
            return 0;
@@ -211,13 +213,15 @@ linemap_line_start (struct line_maps *set, unsigned int to_line,
            column_bits++;
          max_column_hint = 1U << column_bits;
        }
+      /* Allocate the new line_map.  However, if the current map only has a
+        single line we can sometimes just increase its column_bits instead. */
       if (line_delta < 0
          || last_line != map->to_line
          || SOURCE_COLUMN (map, highest) >= (1U << column_bits))
        map = (struct line_map*) linemap_add (set, LC_RENAME, map->sysp,
                                      map->to_file, to_line);
       map->column_bits = column_bits;
-      r = map->start_location;
+      r = map->start_location + ((to_line - map->to_line) << column_bits);
     }
   else
     r = highest - SOURCE_COLUMN (map, highest)