Bug 74436 - bison 1.875 produced g++ rejected code
Summary: bison 1.875 produced g++ rejected code
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Sean Chittenden
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-26 19:20 UTC by Uranus
Modified: 2004-12-06 08:03 UTC (History)
0 users

See Also:


Attachments
file.diff (1.70 KB, patch)
2004-11-26 19:20 UTC, Uranus
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Uranus 2004-11-26 19:20:19 UTC
The bison 1.875 will produce the following code:
#if defined (__GNUC_MINOR__) && 2093 <= (__GNUC__ * 1000 + __GNUC_MINOR__)
  __attribute__ ((__unused__))
#endif

When the `__attribute__ ((__unused__))' be compiled, we'll get the following error msg:
  parser.tab.cxx: In function `int yyparse()':
  parser.tab.cxx:2754: error: expected primary-expression

My g++ is system builtin version, 3.4.2 [FreeBSD] 20040728.

Fix: The solution refers to http://lists.gnu.org/archive/html/bison-patches/2003-01/msg00047.html and I reproduce a patch file here:
How-To-Repeat: Any yacc source code which could trigger that conditional compilation.
You can search from Google by the keywords `bison', `__attribute__', and `__unused__' for more information.
Comment 1 Thierry Thomas freebsd_committer freebsd_triage 2004-11-26 19:30:59 UTC
Responsible Changed
From-To: freebsd-ports-bugs->seanc


Over to maintainer.
Comment 2 Uranus 2004-12-03 06:35:04 UTC
corrected patch.

--- data/yacc.c.orig    Fri Dec  3 11:52:11 2004
+++ data/yacc.c Fri Dec  3 11:52:11 2004
@@ -465,7 +465,14 @@
 
 #define YYACCEPT       goto yyacceptlab
 #define YYABORT                goto yyabortlab
-#define YYERROR                goto yyerrlab1
+#define YYERROR                ]b4_location_if([do             \
+                        {                              \
+                          yylerrsp = ylap;             \
+                          *++yylerrsp = yyloc;         \
+                          goto yyerrlab1;              \
+                        }                              \
+                      while (0)],
+                      [goto yyerrlab1])[
 
 /* Like YYERROR except do call yyerror.  This remains here temporarily
    to ease the transition to the new meaning of YYERROR, for GCC.
@@ -1103,7 +1110,7 @@
 
   /* Else will try to reuse lookahead token after shifting the error
      token.  */
-  goto yyerrlab2;
+  goto yyerrlab1;
 
 
 /*----------------------------------------------------.
@@ -1111,21 +1118,6 @@
 `----------------------------------------------------*/
 yyerrlab1:
 
-  /* Suppress GCC warning that yyerrlab1 is unused when no action
-     invokes YYERROR.  */
-#if defined (__GNUC_MINOR__) && 2093 <= (__GNUC__ * 1000 + __GNUC_MINOR__)
-  __attribute__ ((__unused__))
-#endif
-
-]b4_location_if([  yylerrsp = yylsp;
-  *++yylerrsp = yyloc;])[
-  goto yyerrlab2;
-
-
-/*---------------------------------------------------------------.
-| yyerrlab2 -- pop states until the error token can be shifted.  |
-`---------------------------------------------------------------*/
-yyerrlab2:
   yyerrstatus = 3;     /* Each real token shifted decrements this.  */
 
   for (;;)
Comment 3 Sean Chittenden freebsd_committer freebsd_triage 2004-12-06 08:01:44 UTC
State Changed
From-To: open->closed

Patch committed, thank you!!!