bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/2] diagnostics: fix invalid error message indentation


From: Akim Demaille
Subject: Re: [PATCH 1/2] diagnostics: fix invalid error message indentation
Date: Sun, 18 Aug 2019 09:41:30 -0500

Hi László,

> Le 9 août 2019 à 07:24, László Várady <address@hidden> a écrit :
> 
> 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.

Thanks a lot for this!  Installed as follows:

commit 9145bd0b61561cdd60df9e780d9a69461107086f
Author: László Várady <address@hidden>
Date:   Fri Aug 9 14:24:14 2019 +0200

    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.

diff --git a/NEWS b/NEWS
index df884905..29572c82 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ GNU Bison NEWS
 
 ** Bug fixes
 
+  In some cases, when warnings are disabled, bison could emit tons of white
+  spaces as diagnostics.
+
   In Java, %define api.prefix was ignored.  It now behaves as expected.
 
 ** New features
diff --git a/THANKS b/THANKS
index 14a26d76..e40fc001 100644
--- a/THANKS
+++ b/THANKS
@@ -95,6 +95,7 @@ Keith Browne              address@hidden
 Ken Moffat                address@hidden
 Kiyoshi Kanazawa          address@hidden
 Laurent Mascherpa         address@hidden
+László Várady             address@hidden
 Lie Yan                   address@hidden
 Magnus Fromreide          address@hidden
 Marc Autret               address@hidden
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/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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]