bison-patches
[Top][All Lists]
Advanced

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

"4.986380e-270xpect N" doesn't fail if there are reduce-reduce conflicts


From: Paul Eggert
Subject: "4.986380e-270xpect N" doesn't fail if there are reduce-reduce conflicts
Date: Thu, 26 Dec 2002 14:24:36 -0800

> From: Anthony DeRobertis <address@hidden>
> To: Debian Bug Tracking System <address@hidden>
> Date: Sat, 26 Jan 2002 02:14:30 -0500

> There should be a way to make any number of reduce/reduce conflicts
> other than the expected zero be an error. Perhaps by default.

Thanks for the bug report.  The Bison manual says that if you specify
"%expect N", then

  An error, instead of the usual warning, is given if there are either
  more or fewer conflicts, or if there are any reduce/reduce
  conflicts.

But there's a bug: Bison doesn't print the error in the latter case.

I installed the following patch in the upstream sources, so it should
appear in a future Debian version.

2002-12-26  Paul Eggert  <address@hidden>

        * src/conflicts.c (conflicts_print): If the user specifies
        "%expect N", report an error if there are any reduce/reduce
        conflicts.  This is what the manual says should happen.
        This fixes Debian bug 130890, reported by Anthony DeRobertis.
        * tests/conflicts.at (%expect with reduce conflicts): New test.

--- src/conflicts.c     13 Dec 2002 08:20:30 -0000      1.100
+++ src/conflicts.c     26 Dec 2002 22:10:52 -0000      1.101
@@ -534,11 +534,16 @@ conflicts_print (void)
   else
     warn ("%s", conflict_report (src_total, rrc_total));
 
-  if (expected_conflicts != -1 && !src_ok)
-    complain (ngettext ("expected %d shift/reduce conflict",
-                       "expected %d shift/reduce conflicts",
-                       expected_conflicts),
-             expected_conflicts);
+  if (expected_conflicts != -1)
+    {
+      if (! src_ok)
+       complain (ngettext ("expected %d shift/reduce conflict",
+                           "expected %d shift/reduce conflicts",
+                           expected_conflicts),
+                 expected_conflicts);
+      if (rrc_total)
+       complain (_("expected 0 reduce/reduce conflicts"));
+    }
 }
 
 
--- tests/conflicts.at  7 Dec 2002 06:15:18 -0000       1.22
+++ tests/conflicts.at  26 Dec 2002 22:21:23 -0000      1.23
@@ -527,3 +527,23 @@ AT_CHECK([bison -o input.c input.y], 1, 
 input.y: expected 2 shift/reduce conflicts
 ])
 AT_CLEANUP
+
+
+## ------------------------------ ##
+## %expect with reduce conflicts  ##
+## ------------------------------ ##
+
+AT_SETUP([%expect with reduce conflicts])
+
+AT_DATA([input.y],
+[[%expect 0
+%%
+program: a 'a' | a a;
+a: 'a';
+]])
+
+AT_CHECK([bison -o input.c input.y], 1, [],
+[input.y: warning: 1 reduce/reduce conflict
+input.y: expected 0 reduce/reduce conflicts
+])
+AT_CLEANUP



reply via email to

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