summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLászló Várady <laszlo.varady93@gmail.com>2019-08-09 14:24:14 +0200
committerAkim Demaille <akim.demaille@gmail.com>2019-09-08 11:38:29 +0200
commite63811dd86c340cd1758509b422e9c4978129804 (patch)
tree9d7b5f68dfa6571a2eae6f839813a6ec410ab3fa
parent47262c36bb13a2d0d21a3a78ce83c8f34deea008 (diff)
downloadbison-e63811dd86c340cd1758509b422e9c4978129804.tar.gz
diagnostics: fix invalid error message indentation
https://lists.gnu.org/archive/html/bison-patches/2019-08/msg00007.html 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. * src/complain.c (error_message): Don't reset indent_ptr here, but... (complain_indent): here. * tests/diagnostics.at (Indentation with message suppression): Check this case.
-rw-r--r--NEWS4
-rw-r--r--THANKS1
-rw-r--r--src/complain.c2
-rw-r--r--tests/diagnostics.at30
4 files changed, 36 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index a7a37f1c..52c85980 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,10 @@ GNU Bison NEWS
* Noteworthy changes in release ?.? (????-??-??) [?]
+** Bug fixes
+
+ In some cases, when warnings are disabled, bison could emit tons of white
+ spaces as diagnostics.
* Noteworthy changes in release 3.4.1 (2019-05-22) [stable]
diff --git a/THANKS b/THANKS
index 14a26d76..e40fc001 100644
--- a/THANKS
+++ b/THANKS
@@ -95,6 +95,7 @@ Keith Browne kbrowne@legato.com
Ken Moffat zarniwhoop@ntlworld.com
Kiyoshi Kanazawa yoi_no_myoujou@yahoo.co.jp
Laurent Mascherpa laurent.mascherpa@epita.fr
+László Várady laszlo.varady93@gmail.com
Lie Yan lie.yan@kaust.edu.sa
Magnus Fromreide magfr@lysator.liu.se
Marc Autret autret_m@epita.fr
diff --git a/src/complain.c b/src/complain.c
index 19c03cc3..3cec0ca0 100644
--- a/src/complain.c
+++ b/src/complain.c
@@ -416,7 +416,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);
@@ -487,6 +486,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/diagnostics.at b/tests/diagnostics.at
index fb24fbcf..3f9e19fa 100644
--- a/tests/diagnostics.at
+++ b/tests/diagnostics.at
@@ -242,3 +242,33 @@ input.y: <warning>warning:</warning> fix-its can be applied. Rerun with option
m4_popdef([AT_TEST])
+
+
+
+
+## -------------------------------------- ##
+## Indentation with message suppression. ##
+## -------------------------------------- ##
+
+AT_SETUP([[Indentation with message suppression]])
+
+# https://lists.gnu.org/archive/html/bug-bison/2019-08/msg00002.html
+
+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