bug-bison
[Top][All Lists]
Advanced

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

RE: __attribute__((__unused__)) problem


From: victor khomenko
Subject: RE: __attribute__((__unused__)) problem
Date: Wed, 10 Apr 2013 20:31:29 +0000

Dear Akim and John,

I tried to add:

static int yyFalse_(){ return 0; }

#define YYFALSE yyFalse_()

and then adjusted the definition of YYSTACK_RELOCATE to use YYFALSE. 
Unfortunately this did not remove the warning - the compiler was clever enough 
to work out that the expression is still constant. (Removing 'static' from the 
definition of yyFalse_() didn't help either.)

Maybe I'm missing something, but as YYSTACK_RELOCATE is not documented, and 
there is no 'break'/'continue' in its definition, I *guess* it is used only 
internally, and so the do{...}while(0) can be replaced just by the scope {...} 
(and fix all the places where this causes a problem, if any).

Regards,
Victor.



> -----Original Message-----
> From: John Horigan [mailto:address@hidden
> Sent: Wednesday, April 10, 2013 5:31 PM
> To: Akim Demaille
> Cc: victor khomenko; address@hidden
> Subject: Re: __attribute__((__unused__)) problem
> 
> Why not replace '/*CONSTCOND*/ 0' with a non-constant expression that is
> guaranteed to be false, like 'rand() < 0'? Or if you don't want to modify the
> global random seed then define yyFalse() and yyTrue().
> 
> 
> -- john
> 
> 
> On Wed, Apr 10, 2013 at 7:31 AM, Akim Demaille <address@hidden>
> wrote:
> 
> 
> 
>       Le 8 avr. 2013 à 21:14, victor khomenko
> <address@hidden> a écrit :
> 
>       > Dear Akim,
> 
>       Hi Victor,
> 
>       Thanks for the report.
> 
> 
>       > c:\punf\picallib\parse_pi.cpp(1202) : warning C4365: 'return' :
> conversion from 'int' to 'size_t', signed/unsigned mismatch
> 
> 
>       This is the second return.
> 
>       > static YYSIZE_T
>       > yytnamerr (char *yyres, const char *yystr)
>       > {
>       >   [.]
>       >   if (! yyres)
>       >     return yystrlen (yystr);
>       >
>       >   return yystpcpy (yyres, yystr) - yyres;
> 
>       > }
> 
> 
>       > c:\punf\picallib\parse_pi.cpp(1657) : warning C4242: '=' : conversion
> from 'int' to 'yytype_int16', possible loss of data
> 
> 
>       This is the assignment:
> 
>        yysetstate:
>         *yyssp = yystate;
> 
>       because
> 
>           yytype_int16 *yyssp;
>           int yystate;
> 
>       it would make sense to be more consistent here.
> 
> 
>       > c:\punf\picallib\parse_pi.cpp(1662) : warning C4365: 'initializing' :
> conversion from 'int' to 'size_t', signed/unsigned mismatch
> 
> 
>             YYSIZE_T yysize = yyssp - yyss + 1;
> 
> 
>       > c:\punf\picallib\parse_pi.cpp(1704) : warning C4127: conditional
> expression is constant
> 
> 
>       This is because of the do {.} while (false) trick in the
>       macros:
> 
>       # define YYSTACK_RELOCATE(Stack_alloc, Stack)                           
> \
>           do                                                                  
> \
>             {                                                                 
> \
>               YYSIZE_T yynewbytes;                                            
> \
>               YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    
> \
>               Stack = &yyptr->Stack_alloc;                                    
> \
>               yynewbytes = yystacksize * sizeof (*Stack) +
> YYSTACK_GAP_MAXIMUM; \
>               yyptr += yynewbytes / sizeof (*yyptr);                          
> \
>             }                                                                 
> \
>           while (YYID (0))
> 
> 
> 
>       > c:\punf\picallib\parse_pi.cpp(1705) : warning C4127: conditional
> expression is constant
>       >
>       > c:\punf\picallib\parse_pi.cpp(1706) : warning C4127: conditional
> expression is constant
>       >
>       > c:\punf\picallib\parse_pi.cpp(1773) : warning C4127: conditional
> expression is constant
>       >
>       > c:\punf\picallib\parse_pi.cpp(1826) : warning C4127: conditional
> expression is constant
>       >
>       > c:\punf\picallib\parse_pi.cpp(2292) : warning C4127: conditional
> expression is constant
>       >
>       > c:\punf\picallib\parse_pi.cpp(2344) : warning C4127: conditional
> expression is constant
> 
> 
>       They are all alike.
> 
> 
>       >
>       > c:\punf\picallib\parse_pi.cpp(854) : warning C4505:
> 'yy_location_print_' : unreferenced local function has been removed
>       >
>       > c:\punf\picallib\parse_pi.cpp(2295) : warning C4702: unreachable
> code
> 
>       > <parse_pi.y><parse_pi.cpp>
> 
>       yyerrorlab:
> 
>         /* Pacify compilers like GCC when the user code never invokes
>            YYERROR and the label yyerrorlab therefore never appears in user
>            code.  */
>         if (/*CONSTCOND*/ 0)
>            goto yyerrorlab;
> 
>         yyerror_range[1] = yylsp[1-yylen];  <======== this line
> 
>       Well, it's going to be painful to address these warning.
>       I don't think I will do that in 2.7.1, which I'd like to
>       release soon.  They can be covered in 3.x.  I'd like to
>       avoid #pragma if I can, so if you have ideas, please contribute!
> 
> 
> 
> 




reply via email to

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