[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/2] diagnostics: fix invalid error message indentation
From: |
László Várady |
Subject: |
[PATCH 1/2] diagnostics: fix invalid error message indentation |
Date: |
Fri, 9 Aug 2019 14:24:14 +0200 |
When Bison is started with a flag that suppresses warning messages, the
error_message() function can produce a few gigabytes of indentation
because of a dangling pointer.
---
NEWS | 3 +++
src/complain.c | 2 +-
tests/input.at | 25 +++++++++++++++++++++++++
3 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/NEWS b/NEWS
index df884905..8cfda5da 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,9 @@ GNU Bison NEWS
In Java, %define api.prefix was ignored. It now behaves as expected.
+ Fixed error message indentation when Bison is started with warning
+ suppression (dangling pointer).
+
** New features
The Java backend no longer emits code and data for parser tracing if the
diff --git a/src/complain.c b/src/complain.c
index ea062f6a..7f3c8d1b 100644
--- a/src/complain.c
+++ b/src/complain.c
@@ -435,7 +435,6 @@ error_message (const location *loc, warnings flags,
severity sever,
*indent_ptr = pos;
else if (*indent_ptr > pos)
fprintf (stderr, "%*s", *indent_ptr - pos, "");
- indent_ptr = NULL;
}
const char* style = severity_style (sever);
@@ -506,6 +505,7 @@ complain_indent (location const *loc, warnings flags,
unsigned *indent,
va_start (args, message);
complains (loc, flags, message, args);
va_end (args);
+ indent_ptr = NULL;
}
void
diff --git a/tests/input.at b/tests/input.at
index 0d3a5917..80c88933 100644
--- a/tests/input.at
+++ b/tests/input.at
@@ -2711,3 +2711,28 @@ AT_BISON_CHECK([[-fcaret input.y]], [[0]], [[]],
AT_BISON_OPTION_POPDEFS
AT_CLEANUP
+
+
+AT_SETUP([[Indentation with message suppression]])
+
+# https://lists.gnu.org/archive/html/bug-bison/2019-08/msg00002.html
+
+AT_KEYWORDS([[deprec]])
+
+AT_DATA([[input.y]],
+[[%define api.pure
+%pure-parser
+%error-verbose
+%%
+exp : '0'
+]])
+AT_BISON_CHECK([[-fcaret -Wno-other input.y]], [0], [],
+[[input.y:2.1-12: warning: deprecated directive, use '%define api.pure'
[-Wdeprecated]
+ 2 | %pure-parser
+ | ^~~~~~~~~~~~
+input.y:3.1-14: warning: deprecated directive, use '%define parse.error
verbose' [-Wdeprecated]
+ 3 | %error-verbose
+ | ^~~~~~~~~~~~~~
+]])
+
+AT_CLEANUP
--
2.22.0
- [PATCH 1/2] diagnostics: fix invalid error message indentation,
László Várady <=