bison-patches
[Top][All Lists]
Advanced

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

Patch for b4_uint_type and b4_sint_type range problem


From: Paul Hilfinger
Subject: Patch for b4_uint_type and b4_sint_type range problem
Date: Sun, 12 May 2002 17:32:34 -0700

m4 evaluates integer expressions as 32-bit signed quantities.  As a
result, the b4_sint_type and b4_uint_type definitions don't work for
arguments larger than 32767 or 65535, respectively.  More precisely,
with b4_sint_type, NO argument will cause the error message, whereas
with b4_uint_type, ANY argument larger than 65535 will cause a fatal
m4 error (because 4294967295 == -1 mod 2**32).  

The patch below (previously discussed; just committed) corrects this
problem by simply omitting the tests for types int and unsigned int.

Paul Hilfinger

------------------------------------------------------------

2002-05-12  Paul Hilfinger  <address@hidden>

        * data/bison.simple (b4_sint_type, b4_uint_type): Correct to reflect
        32-bit arithmetic.
        * data/bison.c++ (b4_sint_type, b4_uint_type): Ditto.

Index: data/bison.simple
===================================================================
RCS file: /cvsroot/bison/bison/data/bison.simple,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- data/bison.simple   5 May 2002 11:56:27 -0000       1.24
+++ data/bison.simple   13 May 2002 00:27:26 -0000      1.25
@@ -6,8 +6,7 @@
 m4_define([b4_sint_type],
 [m4_if(m4_eval([$1 <= 127]),        [1], [signed char],
        m4_eval([$1 <= 32767]),      [1], [signed short],
-       m4_eval([$1 <= 2147483647]), [1], [signed int],
-       [m4_fatal([no signed int type for $1])])])
+       [signed int])])
 
 
 # b4_uint_type(MAX)
@@ -16,8 +15,7 @@
 m4_define([b4_uint_type],
 [m4_if(m4_eval([$1 <= 255]),        [1], [unsigned char],
        m4_eval([$1 <= 65535]),      [1], [unsigned short],
-       m4_eval([$1 <= 4294967295]), [1], [unsigned int],
-       [m4_fatal([no unsigned int type for $1])])])
+       [unsigned int])])
 
 
 # b4_lhs_value([TYPE])
Index: data/bison.c++
===================================================================
RCS file: /cvsroot/bison/bison/data/bison.c++,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- data/bison.c++      5 May 2002 11:56:27 -0000       1.29
+++ data/bison.c++      13 May 2002 00:27:26 -0000      1.30
@@ -6,8 +6,7 @@
 m4_define([b4_sint_type],
 [m4_if(m4_eval([$1 <= 127]),        [1], [signed char],
        m4_eval([$1 <= 32767]),      [1], [signed short],
-       m4_eval([$1 <= 2147483647]), [1], [signed int],
-       [m4_fatal([no signed int type for $1])])])
+       [signed int])])
 
 
 # b4_uint_type(MAX)
@@ -16,8 +15,7 @@
 m4_define([b4_uint_type],
 [m4_if(m4_eval([$1 <= 255]),        [1], [unsigned char],
        m4_eval([$1 <= 65535]),      [1], [unsigned short],
-       m4_eval([$1 <= 4294967295]), [1], [unsigned int],
-       [m4_fatal([no unsigned int type for $1])])])
+       [unsigned int])])
 
 
 # b4_lhs_value([TYPE])



reply via email to

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