bug-bison
[Top][All Lists]
Advanced

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

Re: [Bison-Announce] Bison 3.4.91 released [beta]


From: Akim Demaille
Subject: Re: [Bison-Announce] Bison 3.4.91 released [beta]
Date: Sun, 1 Dec 2019 07:31:50 +0100

Hi Frank,

> Le 30 nov. 2019 à 06:52, Frank Heckenbach <address@hidden> a écrit :
> 
> % g++-7 -Wextra -Wuseless-cast -c test.cc

Doh...  Yet another compiler flag...

This one is really troublesome, I don't think I'll eliminate all the warnings 
before 3.5.

> test.cc: In static member function 'static yy::parser::token_number_type 
> yy::parser::yytranslate_(int)':
> test.cc:1620:28: warning: useless cast to type 'int' [-Wuseless-cast]
>     if (static_cast<int> (t) <= yyeof_)
>                            ^

This one is addressed as follows.

commit a4bf7cdf9ebd2250df98aadb907f31fc88a5434e
Author: Akim Demaille <address@hidden>
Date:   Sat Nov 30 16:52:48 2019 +0100

    c++: remove useless cast about yyeof_
    
    Reported by Frank Heckenbach.
    https://lists.gnu.org/archive/html/bug-bison/2019-11/msg00016.html
    
    * data/skeletons/c++.m4 (b4_yytranslate_define): Don't use yyeof_ as
    if it had two different types.
    It is used once against the input argument, which is the value
    returned by yylex, which is an "external token number", typically an
    int.  It is also used as output type, an "internal symbol number".
    It turns out that in both cases we mean "0", but let's keep yyeof_
    only for the case "internal symbol number", i.e., _after_ conversion
    by yytranslate.
    This frees us from one cast.

diff --git a/data/skeletons/c++.m4 b/data/skeletons/c++.m4
index fd021fd0..75b9e1b8 100644
--- a/data/skeletons/c++.m4
+++ b/data/skeletons/c++.m4
@@ -545,7 +545,7 @@ m4_define([b4_yytranslate_define],
     const int user_token_number_max_ = ]b4_user_token_number_max[;
     const token_number_type undef_token_ = ]b4_undef_token_number[;
 
-    if (static_cast<int> (t) <= yyeof_)
+    if (t <= 0)
       return yyeof_;
     else if (static_cast<int> (t) <= user_token_number_max_)
       return translate_table[t];


I'll see the rest afterwards.

Cheers!


reply via email to

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