bug-bison
[Top][All Lists]
Advanced

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

Re: bison-3.1.91 released [beta]


From: Akim Demaille
Subject: Re: bison-3.1.91 released [beta]
Date: Mon, 22 Oct 2018 18:09:35 +0200


> Le 21 oct. 2018 à 19:52, Derek Clegg <address@hidden> a écrit :
> 
> There are two minor warnings I’m encountering with bison-3.1.91 in my 
> generated files:

Thanks a lot for the report.

As a matter of fact, it triggered more fixes than just these
ones.  See

c++: fix signedness issues
https://lists.gnu.org/archive/html/bison-patches/2018-10/msg00095.html

tests: be strict about types
https://lists.gnu.org/archive/html/bison-patches/2018-10/msg00096.html

printf returns a signed int
https://lists.gnu.org/archive/html/bison-patches/2018-10/msg00097.html

glr.c: be strict about types
https://lists.gnu.org/archive/html/bison-patches/2018-10/msg00099.html

To which I add those two commits, more directly related to your
report.

Cheers!

commit f1de52f719d3ff54f51b169ec744de0b4f90a9e6
Author: Akim Demaille <address@hidden>
Date:   Mon Oct 22 14:30:41 2018 +0200

    yacc.c: fix warnings about integral types
    
    Reported by Derek Clegg.
    http://lists.gnu.org/archive/html/bug-bison/2018-10/msg00018.html
    
    Rather than adding casts, we should be more careful with types.  For
    instance yystate should be a yytype_int16.  But currently we can't: it
    is also used sometimes for storing other things that state numbers.
    
    * data/yacc.c (yyparse): Add missing casts.

diff --git a/TODO b/TODO
index 4e3258dc..05729fb1 100644
--- a/TODO
+++ b/TODO
@@ -5,6 +5,12 @@ itself uses int (for yylen for instance), yet stack is based 
on size_t.
 
 Maybe locations should also move to ints.
 
+** C
+Introduce state_type rather than spreading yytype_int16 everywhere?
+
+** glr.c
+yyspaceLeft should probably be a pointer diff.
+
 ** Graphviz display code thoughts
 The code for the --graph option is over two files: print_graph, and
 graphviz. This is because Bison used to also produce VCG graphs, but since
diff --git a/data/yacc.c b/data/yacc.c
index 2e1c275c..4f044a3c 100644
--- a/data/yacc.c
+++ b/data/yacc.c
@@ -788,7 +788,7 @@ yy_lac_stack_realloc (YYSIZE_T *yycapacity, YYSIZE_T yyadd,
                       yytype_int16 **yytop, yytype_int16 *yytop_empty)
 {
   YYSIZE_T yysize_old =
-    *yytop == yytop_empty ? 0 : *yytop - *yybottom + 1;
+    (YYSIZE_T) (*yytop == yytop_empty ? 0 : *yytop - *yybottom + 1);
   YYSIZE_T yysize_new = yysize_old + yyadd;
   if (*yycapacity < yysize_new)
     {
@@ -954,7 +954,7 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes,
         YYDPRINTF ((stderr, " R%d", yyrule - 1));
         if (yyesp != yyes_prev)
           {
-            YYSIZE_T yysize = yyesp - *yyes + 1;
+            YYSIZE_T yysize = (YYSIZE_T) (yyesp - *yyes + 1);
             if (yylen < yysize)
               {
                 yyesp -= yylen;
@@ -970,7 +970,7 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes,
           yyesp = yyes_prev -= yylen;
       }
       {
-        int yystate;
+        yytype_int16 yystate;
         {
           const int yylhs = yyr1[yyrule] - YYNTOKENS;
           const int yyi = yypgoto[yylhs] + *yyesp;
@@ -1084,7 +1084,7 @@ yytnamerr (char *yyres, const char *yystr)
   if (! yyres)
     return yystrlen (yystr);
 
-  return yystpcpy (yyres, yystr) - yyres;
+  return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres);
 }
 # endif
 
@@ -1445,12 +1445,12 @@ b4_locations_if([[  yylsp[0] = 
]b4_push_if([b4_pure_if([*])yypushed_loc], [yyllo
   yyssp++;
 
  yysetstate:
-  *yyssp = yystate;
+  *yyssp = (yytype_int16) yystate;
 
   if (yyss + yystacksize - 1 <= yyssp)
     {
       /* Get the current used size of the three stacks, in elements.  */
-      YYSIZE_T yysize = yyssp - yyss + 1;
+      YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1);
 
 #ifdef yyoverflow
       {
@@ -1470,10 +1470,9 @@ b4_locations_if([[  yylsp[0] = 
]b4_push_if([b4_pure_if([*])yypushed_loc], [yyllo
                     &yyvs1, yysize * sizeof (*yyvsp),]b4_locations_if([
                     &yyls1, yysize * sizeof (*yylsp),])[
                     &yystacksize);
-]b4_locations_if([
-        yyls = yyls1;])[
         yyss = yyss1;
-        yyvs = yyvs1;
+        yyvs = yyvs1;]b4_locations_if([
+        yyls = yyls1;])[
       }
 #else /* no yyoverflow */
 # ifndef YYSTACK_RELOCATE











commit fe1cdd8d0cdedf99d344d8010c5c3989a166e96f
Author: Akim Demaille <address@hidden>
Date:   Mon Oct 22 08:22:53 2018 +0200

    build: enable more warnings during tests
    
    Prompted by Derek Clegg.
    http://lists.gnu.org/archive/html/bug-bison/2018-10/msg00018.html
    
    * configure.ac: here.

diff --git a/configure.ac b/configure.ac
index a569ef7c..f2240100 100644
--- a/configure.ac
+++ b/configure.ac
@@ -107,7 +107,9 @@ if test "$enable_gcc_warnings" = yes; then
   # -Wno-keyword-macro: We use the "#define private public" dirty
   # trick in the test suite to check some private implementation
   # details for lalr1.cc.
-  warn_tests='-Wundef -pedantic -Wdeprecated -Wsign-compare 
-fno-color-diagnostics
+  warn_tests='-Wundef -pedantic -Wconversion
+    -Wdeprecated -Wsign-compare -Wsign-conversion
+    -fno-color-diagnostics
     -Wno-keyword-macro'
 
   AC_LANG_PUSH([C])
@@ -137,7 +139,7 @@ if test "$enable_gcc_warnings" = yes; then
     AS_VAR_APPEND([WARN_CFLAGS], [" $WARN_CFLAGS_TEST"])
 
   # Warnings for the test suite only.
-  for i in $warn_tests;
+  for i in $warn_tests -Wincompatible-pointer-types;
   do
     gl_WARN_ADD([$i], [WARN_CFLAGS_TEST])
   done




reply via email to

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