This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR preprocessor/42014
- From: Krzesimir Nowak <qdlacz at gmail dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Krzesimir Nowak <qdlacz at gmail dot com>
- Date: Sat, 18 Oct 2014 23:07:31 +0200
- Subject: [PATCH] Fix PR preprocessor/42014
- Authentication-results: sourceware.org; auth=none
- References: <1413666451-15144-1-git-send-email-qdlacz at gmail dot com>
gcc/Changelog:
2014-10-18 Krzesimir Nowak <qdlacz@gmail.com>
* diagnostic.c (diagnostic_report_from): New function. It prints
one line from include chain.
(diagnostic_report_current_module): Use the above function.
gcc/testsuite/ChangeLog:
2014-10-18 Krzesimir Nowak <qdlacz@gmail.com>
* c-c++-common/cpp/pr42014.c: New.
* c-c++-common/cpp/pr42014-1.h: New.
* c-c++-common/cpp/pr42014-2.h: New.
* c-c++-common/cpp/pr42014-3.h: New.
---
gcc/ChangeLog | 6 ++++++
gcc/diagnostic.c | 27 +++++++++++++++------------
gcc/testsuite/ChangeLog | 8 ++++++++
gcc/testsuite/c-c++-common/cpp/pr42014-1.h | 3 +++
gcc/testsuite/c-c++-common/cpp/pr42014-2.h | 2 ++
gcc/testsuite/c-c++-common/cpp/pr42014-3.h | 1 +
gcc/testsuite/c-c++-common/cpp/pr42014.c | 8 ++++++++
7 files changed, 43 insertions(+), 12 deletions(-)
create mode 100644 gcc/testsuite/c-c++-common/cpp/pr42014-1.h
create mode 100644 gcc/testsuite/c-c++-common/cpp/pr42014-2.h
create mode 100644 gcc/testsuite/c-c++-common/cpp/pr42014-3.h
create mode 100644 gcc/testsuite/c-c++-common/cpp/pr42014.c
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 667da04..421dd47 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2014-10-18 Krzesimir Nowak <qdlacz@gmail.com>
+
+ * diagnostic.c (diagnostic_report_from): New function. It prints
+ one line from include chain.
+ (diagnostic_report_current_module): Use the above function.
+
2014-10-13 Marat Zakirov <m.zakirov@samsung.com>
* asan.c (instrument_derefs): BIT_FIELD_REF added.
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c
index 881da0b..f0ac8ca 100644
--- a/gcc/diagnostic.c
+++ b/gcc/diagnostic.c
@@ -501,6 +501,19 @@ diagnostic_action_after_output (diagnostic_context *context,
}
}
+static void
+diagnostic_report_from (diagnostic_context *context,
+ const struct line_map *map,
+ const char *prefix)
+{
+ /* Do not print column, it is always zero. Also, it's quite
+ pointless - it does not give any useful information as there can
+ be only one include directive per line. */
+ pp_verbatim (context->printer,
+ "%s from %r%s:%d%R", prefix, "locus",
+ LINEMAP_FILE (map), LAST_SOURCE_LINE (map));
+}
+
void
diagnostic_report_current_module (diagnostic_context *context, location_t where)
{
@@ -525,21 +538,11 @@ diagnostic_report_current_module (diagnostic_context *context, location_t where)
if (! MAIN_FILE_P (map))
{
map = INCLUDED_FROM (line_table, map);
- if (context->show_column)
- pp_verbatim (context->printer,
- "In file included from %r%s:%d:%d%R", "locus",
- LINEMAP_FILE (map),
- LAST_SOURCE_LINE (map), LAST_SOURCE_COLUMN (map));
- else
- pp_verbatim (context->printer,
- "In file included from %r%s:%d%R", "locus",
- LINEMAP_FILE (map), LAST_SOURCE_LINE (map));
+ diagnostic_report_from (context, map, "In file included");
while (! MAIN_FILE_P (map))
{
map = INCLUDED_FROM (line_table, map);
- pp_verbatim (context->printer,
- ",\n from %r%s:%d%R", "locus",
- LINEMAP_FILE (map), LAST_SOURCE_LINE (map));
+ diagnostic_report_from (context, map, ",\n ");
}
pp_verbatim (context->printer, ":");
pp_newline (context->printer);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2134ada..fabdf7c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2014-10-18 Krzesimir Nowak <qdlacz@gmail.com>
+
+ PR preprocessor/42014
+ * c-c++-common/cpp/pr42014.c: New.
+ * c-c++-common/cpp/pr42014-1.h: New.
+ * c-c++-common/cpp/pr42014-2.h: New.
+ * c-c++-common/cpp/pr42014-3.h: New.
+
2014-09-19 Marat Zakirov <m.zakirov@samsung.com>
* c-c++-common/asan/bitfield-5.c: New test.
diff --git a/gcc/testsuite/c-c++-common/cpp/pr42014-1.h b/gcc/testsuite/c-c++-common/cpp/pr42014-1.h
new file mode 100644
index 0000000..33f3b44
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cpp/pr42014-1.h
@@ -0,0 +1,3 @@
+
+
+ #include "pr42014-2.h"
diff --git a/gcc/testsuite/c-c++-common/cpp/pr42014-2.h b/gcc/testsuite/c-c++-common/cpp/pr42014-2.h
new file mode 100644
index 0000000..8ddce8e
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cpp/pr42014-2.h
@@ -0,0 +1,2 @@
+
+ #include "pr42014-3.h"
diff --git a/gcc/testsuite/c-c++-common/cpp/pr42014-3.h b/gcc/testsuite/c-c++-common/cpp/pr42014-3.h
new file mode 100644
index 0000000..75dcf7c
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cpp/pr42014-3.h
@@ -0,0 +1 @@
+int f(foo bar);
diff --git a/gcc/testsuite/c-c++-common/cpp/pr42014.c b/gcc/testsuite/c-c++-common/cpp/pr42014.c
new file mode 100644
index 0000000..ebddf96
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cpp/pr42014.c
@@ -0,0 +1,8 @@
+/* PR preprocessor/42014 */
+/* { dg-do compile } */
+
+#include "pr42014-1.h"
+
+/* { dg-excess-errors "In file included from .*pr42014-2.h:2," } */
+/* { dg-excess-errors " from .*pr42014-1.h:3," } */
+/* { dg-excess-errors " from .*pr42014.c:4:" } */
--
1.9.3