From 32d8177af50f02324bfda25478fa101cc95e2471 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Thu, 7 Jul 2016 04:53:08 -0400
Subject: [PATCH 12/25] FIXME: verify line numbers

---
 gcc/input.c | 65 ++++++++++++++++++++++++++++++++++---------------------------
 1 file changed, 36 insertions(+), 29 deletions(-)

diff --git a/gcc/input.c b/gcc/input.c
index 73a3804..d4e5c52 100644
--- a/gcc/input.c
+++ b/gcc/input.c
@@ -1733,7 +1733,7 @@ lexer_test::get_token ()
 static void
 assert_char_at_range (const location &loc,
 		      lexer_test& test,
-		      location_t strloc, int idx,
+		      location_t strloc, int idx, int expected_line,
 		      int expected_start_col, int expected_finish_col)
 {
   cpp_reader *pfile = test.m_parser;
@@ -1750,6 +1750,11 @@ assert_char_at_range (const location &loc,
       return;
     }
 
+  int actual_start_line = LOCATION_LINE (actual_range.m_start);
+  ASSERT_EQ_AT (loc, expected_line, actual_start_line);
+  int actual_finish_line = LOCATION_LINE (actual_range.m_finish);
+  ASSERT_EQ_AT (loc, expected_line, actual_finish_line);
+
   if (should_have_column_data_p (actual_range.m_start))
     {
       int actual_start_col = LOCATION_COLUMN (actual_range.m_start);
@@ -1765,9 +1770,11 @@ assert_char_at_range (const location &loc,
 /* Macro for calling assert_char_at_range, supplying SELFTEST_LOCATION for
    the effective location of any errors.  */
 
-#define ASSERT_CHAR_AT_RANGE(LEXER_TEST, STRLOC, IDX, EXPECTED_START_COL, \
+#define ASSERT_CHAR_AT_RANGE(LEXER_TEST, STRLOC, IDX, EXPECTED_LINE, \
+			     EXPECTED_START_COL,			\
 			     EXPECTED_FINISH_COL)			\
-  assert_char_at_range (SELFTEST_LOCATION, (LEXER_TEST), (STRLOC), (IDX),	\
+  assert_char_at_range (SELFTEST_LOCATION, (LEXER_TEST), (STRLOC), (IDX), \
+			(EXPECTED_LINE), \
 			(EXPECTED_START_COL), (EXPECTED_FINISH_COL))
 
 /* FIXME.  */
@@ -1830,7 +1837,7 @@ test_lexer_string_locations_simple (const line_table_case &case_)
   /* Verify ranges of individual characters.  This no longer includes the
      quotes.  */
   for (int i = 0; i < 9; i++)
-    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i,
+    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 1,
 			  10 + i, 10 + i);
 
   ASSERT_NUM_SUBSTRING_RANGES (test, tok->src_loc, 10);
@@ -1866,10 +1873,10 @@ test_lexer_string_locations_hex (const line_table_case &case_)
   /* Verify ranges of individual characters.  This no longer includes the
      quotes.  */
   for (int i = 0; i < 5; i++)
-    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 10 + i, 10 + i);
-  ASSERT_CHAR_AT_RANGE (test, tok->src_loc, 5, 15, 18);
+    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 1, 10 + i, 10 + i);
+  ASSERT_CHAR_AT_RANGE (test, tok->src_loc, 5, 1, 15, 18);
   for (int i = 6; i <= 9; i++)
-    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 13 + i, 13 + i);
+    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 1, 13 + i, 13 + i);
 
   ASSERT_NUM_SUBSTRING_RANGES (test, tok->src_loc, 10);
 }
@@ -1898,10 +1905,10 @@ test_lexer_string_locations_oct (const line_table_case &case_)
   /* Verify ranges of individual characters.  This no longer includes the
      quotes.  */
   for (int i = 0; i < 5; i++)
-    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 10 + i, 10 + i);
-  ASSERT_CHAR_AT_RANGE (test, tok->src_loc, 5, 15, 18);
+    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 1, 10 + i, 10 + i);
+  ASSERT_CHAR_AT_RANGE (test, tok->src_loc, 5, 1, 15, 18);
   for (int i = 6; i <= 9; i++)
-    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 13 + i, 13 + i);
+    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 1, 13 + i, 13 + i);
 
   ASSERT_NUM_SUBSTRING_RANGES (test, tok->src_loc, 10);
 }
@@ -1951,16 +1958,16 @@ test_lexer_string_locations_ucn4 (const line_table_case &case_)
      quotes.
      '01234'.  */
   for (int i = 0; i < 4; i++)
-    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 10 + i, 10 + i);
+    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 1, 10 + i, 10 + i);
   /* U+2174.  */
   for (int i = 5; i < 7; i++)
-    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 15, 20);
+    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 1, 15, 20);
   /* U+2175.  */
   for (int i = 8; i < 10; i++)
-    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 21, 26);
+    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 1, 21, 26);
   /* '789'.  */
   for (int i = 11; i <= 13; i++)
-    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 16 + i, 16 + i);
+    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 1, 16 + i, 16 + i);
 
   ASSERT_NUM_SUBSTRING_RANGES (test, tok->src_loc, 14);
 }
@@ -1993,16 +2000,16 @@ test_lexer_string_locations_ucn8 (const line_table_case &case_)
      quotes.
      '01234'.  */
   for (int i = 0; i < 4; i++)
-    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 10 + i, 10 + i);
+    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 1, 10 + i, 10 + i);
   /* U+2174.  */
   for (int i = 5; i < 7; i++)
-    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 15, 24);
+    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 1, 15, 24);
   /* U+2175.  */
   for (int i = 8; i < 10; i++)
-    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 25, 34);
+    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 1, 25, 34);
   /* '789' at columns 35-37  */
   for (int i = 11; i <= 13; i++)
-    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 24 + i, 24 + i);
+    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 1, 24 + i, 24 + i);
 
   ASSERT_NUM_SUBSTRING_RANGES (test, tok->src_loc, 14);
 }
@@ -2029,7 +2036,7 @@ test_lexer_string_locations_u8 (const line_table_case &case_)
   /* Verify ranges of individual characters.  This no longer includes the
      quotes.  */
   for (int i = 0; i < 9; i++)
-    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 10 + i, 10 + i);
+    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 1, 10 + i, 10 + i);
 }
 
 /* Lex a string literal containing UTF-8 source characters.
@@ -2098,7 +2105,7 @@ test_lexer_string_locations_utf8_source (const line_table_case &case_)
      Assuming that both source and execution encodings are UTF-8, we have
      a run of 25 octets in each.  */
   for (int i = 0; i < 25; i++)
-    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 10 + i, 10 + i);
+    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 1, 10 + i, 10 + i);
 
   ASSERT_NUM_SUBSTRING_RANGES (test, tok->src_loc, 25);
 }
@@ -2138,9 +2145,9 @@ test_lexer_string_locations_concatenation_1 (const line_table_case &case_)
   location_t initial_loc = input_locs[0];
 
   for (int i = 0; i < 5; i++)
-    ASSERT_CHAR_AT_RANGE (test, initial_loc, i, 10 + i, 10 + i);
+    ASSERT_CHAR_AT_RANGE (test, initial_loc, i, 1, 10 + i, 10 + i);
   for (int i = 5; i <= 9; i++)
-    ASSERT_CHAR_AT_RANGE (test, initial_loc, i, 5 + i, 5 + i);
+    ASSERT_CHAR_AT_RANGE (test, initial_loc, i, 2, 5 + i, 5 + i);
 
   ASSERT_NUM_SUBSTRING_RANGES (test, initial_loc, 10);
 }
@@ -2199,7 +2206,8 @@ test_lexer_string_locations_concatenation_2 (const line_table_case &case_)
 
   for (int i = 0; i < 5; i++)
     for (int j = 0; j < 2; j++)
-      ASSERT_CHAR_AT_RANGE (test, initial_loc, (i * 2) + j, 10 + j, 10 + j);
+      ASSERT_CHAR_AT_RANGE (test, initial_loc, (i * 2) + j,
+			    i + 1, 10 + j, 10 + j);
 
   ASSERT_NUM_SUBSTRING_RANGES (test, initial_loc, 10);
 }
@@ -2233,11 +2241,11 @@ test_lexer_string_locations_concatenation_3 (const line_table_case &case_)
   location_t initial_loc = input_locs[0];
 
   for (int i = 0; i < 4; i++)
-    ASSERT_CHAR_AT_RANGE (test, initial_loc, i, 10 + i, 10 + i);
-  ASSERT_CHAR_AT_RANGE (test, initial_loc, 5, 19, 22);
-  ASSERT_CHAR_AT_RANGE (test, initial_loc, 6, 27, 30);
+    ASSERT_CHAR_AT_RANGE (test, initial_loc, i, 1, 10 + i, 10 + i);
+  ASSERT_CHAR_AT_RANGE (test, initial_loc, 5, 1, 19, 22);
+  ASSERT_CHAR_AT_RANGE (test, initial_loc, 6, 1, 27, 30);
   for (int i = 7; i <= 9; i++)
-    ASSERT_CHAR_AT_RANGE (test, initial_loc, i, 28 + i, 28 + i);
+    ASSERT_CHAR_AT_RANGE (test, initial_loc, i, 1, 28 + i, 28 + i);
 
   ASSERT_NUM_SUBSTRING_RANGES (test, initial_loc, 10);
 }
@@ -2267,8 +2275,7 @@ test_lexer_string_locations_macro (const line_table_case &case_)
   /* Verify ranges of individual characters.  We ought to
      see columns within the macro definition.  */
   for (int i = 0; i < 9; i++)
-    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i,
-			  20 + i, 20 + i);
+    ASSERT_CHAR_AT_RANGE (test, tok->src_loc, i, 1, 20 + i, 20 + i);
 
   ASSERT_NUM_SUBSTRING_RANGES (test, tok->src_loc, 10);
 
-- 
1.8.5.3

