aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2015-06-08 15:16:12 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2015-06-08 15:16:12 +0000
commita1661b90dcbaed222e647bda75540e8a87f250ed (patch)
treefe37332799f04ee9e13b2ad6fdc2167b0d47d1a8 /gcc
parentad3e2ba07405b81ed2c4729f63040ce2463c8108 (diff)
downloadgcc-a1661b90dcbaed222e647bda75540e8a87f250ed.zip
gcc-a1661b90dcbaed222e647bda75540e8a87f250ed.tar.gz
gcc-a1661b90dcbaed222e647bda75540e8a87f250ed.tar.bz2
re PR c/66415 (ice in location_column_from_byte_offset)
PR c/66415 * c-format.c (location_from_offset): Return LOC if LINE is null. * line-map.c (linemap_position_for_loc_and_offset): Remove linemap_assert_fails; reverse conditions. * gcc.dg/cpp/pr66415-1.c: New test. * gcc.dg/cpp/pr66415-2.c: New test. From-SVN: r224236
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c-family/ChangeLog5
-rw-r--r--gcc/c-family/c-format.c4
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/cpp/pr66415-1.c9
-rw-r--r--gcc/testsuite/gcc.dg/cpp/pr66415-2.c11
5 files changed, 34 insertions, 1 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 6de6af5..17816a3 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,8 @@
+2015-06-08 Marek Polacek <polacek@redhat.com>
+
+ PR c/66415
+ * c-format.c (location_from_offset): Return LOC if LINE is null.
+
2015-06-05 Aldy Hernandez <aldyh@redhat.com>
* c-common.h (c_parse_final_cleanups): New prototype.
diff --git a/gcc/c-family/c-format.c b/gcc/c-family/c-format.c
index 719b3a9..564e47b 100644
--- a/gcc/c-family/c-format.c
+++ b/gcc/c-family/c-format.c
@@ -138,9 +138,11 @@ location_from_offset (location_t loc, int offset)
expanded_location s = expand_location_to_spelling_point (loc);
int line_width;
const char *line = location_get_source_line (s, &line_width);
+ if (line == NULL)
+ return loc;
line += s.column - 1 ;
line_width -= s.column - 1;
- unsigned int column =
+ unsigned int column =
location_column_from_byte_offset (line, line_width, (unsigned) offset);
return linemap_position_for_loc_and_offset (line_table, loc, column);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5537a46..202551f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2015-06-08 Marek Polacek <polacek@redhat.com>
+
+ PR c/66415
+ * gcc.dg/cpp/pr66415-1.c: New test.
+ * gcc.dg/cpp/pr66415-2.c: New test.
+
2015-06-08 Richard Biener <rguenther@suse.de>
PR tree-optimization/66422
diff --git a/gcc/testsuite/gcc.dg/cpp/pr66415-1.c b/gcc/testsuite/gcc.dg/cpp/pr66415-1.c
new file mode 100644
index 0000000..922e326
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/pr66415-1.c
@@ -0,0 +1,9 @@
+/* PR c/66415 */
+/* { dg-do compile } */
+/* { dg-options "-Wformat" } */
+
+void
+fn1 (void)
+{
+ __builtin_printf ("xxxxxxxxxxxxxxxxx%dxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); /* { dg-warning "format" } */
+}
diff --git a/gcc/testsuite/gcc.dg/cpp/pr66415-2.c b/gcc/testsuite/gcc.dg/cpp/pr66415-2.c
new file mode 100644
index 0000000..c168ce9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/pr66415-2.c
@@ -0,0 +1,11 @@
+/* PR c/66415 */
+/* { dg-do compile } */
+/* { dg-options "-Wformat" } */
+
+#24
+void
+fn1 (void)
+{
+ __builtin_printf ("xxxxxxxxxxxxxxxxx%dxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
+ /* { dg-warning "format" "" { target *-*-* } 27 } */
+}