This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[4.0.1 patch] fix for 20907: long comments throw off line numbers


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20907
I've checked the attached patch into mainline.
Now that 4.0 is released, should I check it into
the 4.0 branch?  It seems quite safe.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/
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.

Index: line-map.c
===================================================================
RCS file: /cvs/gcc/gcc/libcpp/line-map.c,v
retrieving revision 1.1
diff -u -p -r1.1 line-map.c
--- line-map.c	24 May 2004 10:50:44 -0000	1.1
+++ line-map.c	19 Apr 2005 21:18:25 -0000
@@ -199,6 +199,8 @@ linemap_line_start (struct line_maps *se
       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 *se
 	    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)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]