]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR preprocessor/69664: fix rich_location::override_column
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 8 Feb 2016 17:33:45 +0000 (17:33 +0000)
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 8 Feb 2016 17:33:45 +0000 (17:33 +0000)
gcc/testsuite/ChangeLog:
PR preprocessor/69664
* gcc.dg/cpp/trad/comment-2.c: Add expected column number.
* gcc.dg/cpp/warn-comments.c: Likewise.

libcpp/ChangeLog:
PR preprocessor/69664
* errors.c (cpp_diagnostic_with_line): Only call
rich_location::override_column if the column is non-zero.
* line-map.c (rich_location::override_column): Update columns
within m_ranges[0].  Add assertions to verify that doing so is
sane.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@233223 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/cpp/trad/comment-2.c
gcc/testsuite/gcc.dg/cpp/warn-comments.c
libcpp/ChangeLog
libcpp/errors.c
libcpp/line-map.c

index b30f01d0ad2f80ef43df6349a23b5f7acf72be9b..82521ec2935c5bf94a4a5e084168f866d7658315 100644 (file)
@@ -1,3 +1,9 @@
+2016-02-08  David Malcolm  <dmalcolm@redhat.com>
+
+       PR preprocessor/69664
+       * gcc.dg/cpp/trad/comment-2.c: Add expected column number.
+       * gcc.dg/cpp/warn-comments.c: Likewise.
+
 2016-02-08  Marek Polacek  <polacek@redhat.com>
 
        PR c++/69688
index 8d54e3a0f3220dbfc81f97e7626c6c165c4b3661..310f569427681800a84c7a1984f8226fa4c94f88 100644 (file)
@@ -8,4 +8,4 @@
 
 /*
 
- /* { dg-warning "within comment" } */
+ /* { dg-warning "2: within comment" } */
index 1cdf75cf273957896f43cb76c65241b296da28c0..bbe28215894e887161b3e171f3daa1e03de8c526 100644 (file)
@@ -1,7 +1,7 @@
 // { dg-do preprocess }
 // { dg-options "-std=gnu99 -fdiagnostics-show-option -Wcomments" }
 
-/* /* */  // { dg-warning "\"\.\*\" within comment .-Wcomment." }
+/* /* */  // { dg-warning "4: \"\.\*\" within comment .-Wcomment." }
 
 // \
-          // { dg-warning "multi-line comment .-Wcomment." "multi-line" { target *-*-* } 6 }
+          // { dg-warning "1: multi-line comment .-Wcomment." "multi-line" { target *-*-* } 6 }
index 385b965488e3c925bb0b786d3182fd749a6f278b..a5cef17df458a4735ee1c6d959ebac4be8ab83fc 100644 (file)
@@ -1,3 +1,12 @@
+2016-02-08  David Malcolm  <dmalcolm@redhat.com>
+
+       PR preprocessor/69664
+       * errors.c (cpp_diagnostic_with_line): Only call
+       rich_location::override_column if the column is non-zero.
+       * line-map.c (rich_location::override_column): Update columns
+       within m_ranges[0].  Add assertions to verify that doing so is
+       sane.
+
 2016-02-05  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/69628
index d92b38662eaaa478fb192900e4cf12a9c7cf1624..984737877be5e7827f0e515380b7f6298ff2e85f 100644 (file)
@@ -141,7 +141,8 @@ cpp_diagnostic_with_line (cpp_reader * pfile, int level, int reason,
   if (!pfile->cb.error)
     abort ();
   rich_location richloc (pfile->line_table, src_loc);
-  richloc.override_column (column);
+  if (column)
+    richloc.override_column (column);
   ret = pfile->cb.error (pfile, level, reason, &richloc, _(msgid), ap);
 
   return ret;
index fcf025956d1579beda34ac10856b4623125fe6e4..e9175dfa307017c81307ec46b365878677fc2e21 100644 (file)
@@ -2036,13 +2036,22 @@ rich_location::lazily_expand_location ()
   return m_expanded_location;
 }
 
-/* Set the column of the primary location.  */
+/* Set the column of the primary location.  This can only be called for
+   rich_location instances for which the primary location has
+   caret==start==finish.  */
 
 void
 rich_location::override_column (int column)
 {
   lazily_expand_location ();
+  gcc_assert (m_ranges[0].m_show_caret_p);
+  gcc_assert (m_ranges[0].m_caret.column == m_expanded_location.column);
+  gcc_assert (m_ranges[0].m_start.column == m_expanded_location.column);
+  gcc_assert (m_ranges[0].m_finish.column == m_expanded_location.column);
   m_expanded_location.column = column;
+  m_ranges[0].m_caret.column = column;
+  m_ranges[0].m_start.column = column;
+  m_ranges[0].m_finish.column = column;
 }
 
 /* Add the given range.  */