summaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorbothner <bothner@138bc75d-0d04-0410-961f-82ee72b054a4>2005-04-21 17:08:27 +0000
committerbothner <bothner@138bc75d-0d04-0410-961f-82ee72b054a4>2005-04-21 17:08:27 +0000
commit0b7f838f424378c4813af7042b8be1a1a5201855 (patch)
treeb15d8e7557f1913eb0160b3519aa2094cc02bc47 /libcpp
parentdea55b965e6d9797591ae1cf17a71c92d691cb1c (diff)
downloadgcc-0b7f838f424378c4813af7042b8be1a1a5201855.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@98515 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog6
-rw-r--r--libcpp/line-map.c6
2 files changed, 11 insertions, 1 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index 7050d65189e..1a8fccf5ce1 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -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
diff --git a/libcpp/line-map.c b/libcpp/line-map.c
index e6dd48df756..1ace4c9585d 100644
--- a/libcpp/line-map.c
+++ b/libcpp/line-map.c
@@ -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)