aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2016-02-08 17:33:45 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2016-02-08 17:33:45 +0000
commit44714d8ce1ec1b5ac5dc9a2ed3d57713b9253e81 (patch)
tree9fcd123fd85a32e3a218356b240e6888a8a295fa
parentf258ad62e3ede7069fa9d3926d6377c111f9c6e5 (diff)
downloadgcc-44714d8ce1ec1b5ac5dc9a2ed3d57713b9253e81.zip
gcc-44714d8ce1ec1b5ac5dc9a2ed3d57713b9253e81.tar.gz
gcc-44714d8ce1ec1b5ac5dc9a2ed3d57713b9253e81.tar.bz2
PR preprocessor/69664: fix rich_location::override_column
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. From-SVN: r233223
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/cpp/trad/comment-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/cpp/warn-comments.c4
-rw-r--r--libcpp/ChangeLog9
-rw-r--r--libcpp/errors.c3
-rw-r--r--libcpp/line-map.c11
6 files changed, 30 insertions, 5 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b30f01d..82521ec 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
diff --git a/gcc/testsuite/gcc.dg/cpp/trad/comment-2.c b/gcc/testsuite/gcc.dg/cpp/trad/comment-2.c
index 8d54e3a..310f569 100644
--- a/gcc/testsuite/gcc.dg/cpp/trad/comment-2.c
+++ b/gcc/testsuite/gcc.dg/cpp/trad/comment-2.c
@@ -8,4 +8,4 @@
/*
- /* { dg-warning "within comment" } */
+ /* { dg-warning "2: within comment" } */
diff --git a/gcc/testsuite/gcc.dg/cpp/warn-comments.c b/gcc/testsuite/gcc.dg/cpp/warn-comments.c
index 1cdf75c..bbe2821 100644
--- a/gcc/testsuite/gcc.dg/cpp/warn-comments.c
+++ b/gcc/testsuite/gcc.dg/cpp/warn-comments.c
@@ -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 }
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index 385b965..a5cef17 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -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
diff --git a/libcpp/errors.c b/libcpp/errors.c
index d92b386..9847378 100644
--- a/libcpp/errors.c
+++ b/libcpp/errors.c
@@ -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;
diff --git a/libcpp/line-map.c b/libcpp/line-map.c
index fcf0259..e9175df 100644
--- a/libcpp/line-map.c
+++ b/libcpp/line-map.c
@@ -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. */