bug-bison
[Top][All Lists]
Advanced

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

Re: Bison 3.5.92 on IRIX


From: Akim Demaille
Subject: Re: Bison 3.5.92 on IRIX
Date: Sun, 3 May 2020 17:38:39 +0200

Bruno,

> Le 3 mai 2020 à 17:17, Bruno Haible <address@hidden> a écrit :
> 
> There are a couple of GCC warnings on IRIX (CC="gcc -mabi=n32"):
> 
> 1)
> ../src/complain.c: In function `syntax_error':
> ../src/complain.c:612: warning: subscript has type `char'
> 
> You need to cast the 'isdigit' argument to 'unsigned char' first.
> Alternatively, using c_isdigit from the gnulib module 'c-ctype' would fix 
> this.
> 
> 2)
> ../src/fixits.c: In function `fixits_run':
> ../src/fixits.c:129: warning: dereferencing type-punned pointer will break 
> strict-aliasing rules
> 
> Modern C rules wants f to be a 'const void *'. Inside the loop body,
> you can cast f to 'fixit const *' without danger.
> 
> 3)
> ../src/lalr.c: In function `goto_print':
> ../src/lalr.c:95: warning: long int format, goto_number arg (arg 3)

Thanks!

I'm curious: how old is that box?  What version of GCC is this?

I'm installing this:

commit 292409e91ee4e6f547d18d0565ccfe48bf133f75
Author: Akim Demaille <address@hidden>
Date:   Sun May 3 17:31:43 2020 +0200

    build: fix warnings (shown on IRIX)
    
    Appearing on IRIX with gcc -mabi=n32.
    Reported by Bruno Haible.
    https://lists.gnu.org/r/bug-bison/2020-05/msg00039.html
    
    * examples/c++/variant-11.yy, examples/c/bistromathic/parse.y: Don't
    give chars to isdigit, cast them to unsigned char before.
    * src/complain.c: Use c_isdigit.
    * src/fixits.c (fixits_run): Avoid casts.
    * src/lalr.c (goto_print): Use %zu for a size_t.

diff --git a/examples/c++/variant-11.yy b/examples/c++/variant-11.yy
index c83ac6a2..7d883232 100644
--- a/examples/c++/variant-11.yy
+++ b/examples/c++/variant-11.yy
@@ -139,7 +139,7 @@ namespace yy
 int
 main (int argc, const char *argv[])
 {
-  if (2 <= argc && isdigit (*argv[1]))
+  if (2 <= argc && isdigit (static_cast<unsigned char> (*argv[1])))
     {
       auto maxl = strtol (argv[1], nullptr, 10);
       max = INT_MIN <= maxl && maxl <= INT_MAX ? int(maxl) : 4;
diff --git a/examples/c/bistromathic/parse.y b/examples/c/bistromathic/parse.y
index d20d4857..8db9d457 100644
--- a/examples/c/bistromathic/parse.y
+++ b/examples/c/bistromathic/parse.y
@@ -363,7 +363,7 @@ yyreport_syntax_error (const yypcontext_t *ctx)
       }
     // %0e, %1e...: expected token.
     else if (format[0] == '%'
-             && isdigit (format[1])
+             && isdigit ((unsigned char) format[1])
              && format[2] == 'e'
              && (format[1] - '0') < argsize)
       {
diff --git a/src/complain.c b/src/complain.c
index 4dc134b8..6a78d40e 100644
--- a/src/complain.c
+++ b/src/complain.c
@@ -23,7 +23,7 @@
 #include "system.h"
 
 #include <argmatch.h>
-#include <ctype.h>
+#include <c-ctype.h>
 #include <progname.h>
 #include <stdarg.h>
 #include <sys/stat.h>
@@ -609,7 +609,7 @@ syntax_error (location loc,
 
   while (*format)
     if (format[0] == '%'
-        && isdigit (format[1])
+        && c_isdigit (format[1])
         && format[2] == '$'
         && format[3] == 's'
         && (format[1] - '0') < argc)
diff --git a/src/fixits.c b/src/fixits.c
index 37a0b7dd..2c900254 100644
--- a/src/fixits.c
+++ b/src/fixits.c
@@ -124,10 +124,11 @@ fixits_run (void)
   FILE *out = xfopen (input, "w");
   size_t line = 1;
   size_t offset = 1;
-  fixit const *f = NULL;
+  void const *p = NULL;
   gl_list_iterator_t iter = gl_list_iterator (fixits);
-  while (gl_list_iterator_next (&iter, (const void**) &f, NULL))
+  while (gl_list_iterator_next (&iter, &p, NULL))
     {
+      fixit const *f = p;
       /* Look for the correct line. */
       while (line < f->location.start.line)
         {
diff --git a/src/lalr.c b/src/lalr.c
index 8b8724d0..ee6c7cf6 100644
--- a/src/lalr.c
+++ b/src/lalr.c
@@ -92,7 +92,7 @@ goto_print (goto_number i, FILE *out)
   const state_number dst = to_state[i];
   symbol_number var = states[dst]->accessing_symbol;
   fprintf (out,
-           "goto[%ld] = (%d, %s, %d)", i, src, symbols[var]->tag, dst);
+           "goto[%zu] = (%d, %s, %d)", i, src, symbols[var]->tag, dst);
 }
 
 void




reply via email to

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