[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
proposed patch to data/yacc.c to fix the "unused label" warning
From: |
Paul Eggert |
Subject: |
proposed patch to data/yacc.c to fix the "unused label" warning |
Date: |
Fri, 17 Jan 2003 01:18:26 -0800 (PST) |
We seem to have continuing problems with people reporting "unused
label" warnings for yyerrlab1, due to my 2002-12-27 yacc.c bugfix.
Here's a proposed patch to fix this.
2003-01-17 Paul Eggert <address@hidden>
* data/yacc.c (YYERROR): Move code from yyerrlab1 to here, so that
we don't need to worry about yyerrlab1 being reported as an
"unused label" by non-GCC C compilers. The downside is that if
locations are used then a couple of statements are duplicated each
time YYERROR is invoked, but the upside is that the warnings
should vanish.
(yyerrlab1): Move code to YERROR.
(yyerrlab2): Remove. Change uses back to yyerrlab1.
This reverts some of the 2002-12-27 change.
--- yacc.c.~1.50.~ 2003-01-04 16:31:06.000000000 -0800
+++ yacc.c 2003-01-17 01:10:30.700840000 -0800
@@ -465,7 +465,15 @@ static const ]b4_int_type_for([b4_stos])
#define YYACCEPT goto yyacceptlab
#define YYABORT goto yyabortlab
-#define YYERROR goto yyerrlab1
+#define YYERROR ]b4_location_if([do
\
+ { \
+ yylerrsp = yylsp; \
+ *++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,33 +1111,13 @@ yyerrlab:
/* Else will try to reuse lookahead token after shifting the error
token. */
- goto yyerrlab2;
+ goto yyerrlab1;
/*----------------------------------------------------.
| yyerrlab1 -- error raised explicitly by an action. |
`----------------------------------------------------*/
yyerrlab1:
-
- /* Suppress GCC warning that yyerrlab1 is unused when no action
- invokes YYERROR. MacOS 10.2.3's buggy "smart preprocessor"
- insists on the trailing semicolon. */
-#if defined (__GNUC_MINOR__) && 2093 <= (__GNUC__ * 1000 + __GNUC_MINOR__)
- /* GNU C++ (as of version 3.2.1) does not allow attributes on labels. */
-# ifndef __cplusplus
- __attribute__ ((__unused__));
-# endif
-#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 (;;)
- proposed patch to data/yacc.c to fix the "unused label" warning,
Paul Eggert <=