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]

[preprocessor/91991] column location overflow


this patch fixes 91991. My fix for 91639 tickled a latent bug in the line map code. In that patch I set highest_line when linemap_line_start ran out of locations.

But I did not clear max_column_hint. The latter's clearing is presumed by linemap_position_for_column. It was happily reporting a location that was in the macro range for a column after we'd run out of line numbers. And that led to the assert.

this patch fixes linemap_line_start to:
1) when we run out of locations, set the max_column_hint to 1
2) record that max column hint on the failure path
3) make sure all failure paths go through a common exit block.

With this patch I can compile the sqlite package in the PR.

committing to trunk.

nathan
--
Nathan Sidwell
2019-10-04  Nathan Sidwell  <nathan@acm.org>

	PR preprocessor/91991
	* line-map.c (linemap_line_start): Clear max_column_hint if we run
	out of locations.

Index: libcpp/line-map.c
===================================================================
--- libcpp/line-map.c	(revision 276586)
+++ libcpp/line-map.c	(working copy)
@@ -718,9 +718,9 @@ linemap_line_start (line_maps *set, line
 	     number of location_ts, give up on column numbers
 	     (and on packed ranges).  */
-	  max_column_hint = 0;
+	  max_column_hint = 1;
 	  column_bits = 0;
 	  range_bits = 0;
 	  if (highest >= LINE_MAP_MAX_LOCATION)
-	    return 0;
+	    goto overflowed;
 	}
       else
@@ -736,4 +736,5 @@ linemap_line_start (line_maps *set, line
 	  column_bits += range_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. */
@@ -766,6 +767,9 @@ linemap_line_start (line_maps *set, line
   if (r >= LINE_MAP_MAX_LOCATION)
     {
+    overflowed:
       /* Remember we overflowed.  */
       set->highest_line = set->highest_location = LINE_MAP_MAX_LOCATION - 1;
+      /* No column numbers!  */
+      set->max_column_hint = 1;
       return 0;
     }

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