bison-patches
[Top][All Lists]
Advanced

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

c: don't assume that UCHAR_MAX, etc. are defined


From: Akim Demaille
Subject: c: don't assume that UCHAR_MAX, etc. are defined
Date: Thu, 10 Oct 2019 17:44:51 +0200

I pushed this to fix issues on the CI.

commit 602d562d6f40738bede6871e555086a3a31b1fcb
Author: Akim Demaille <address@hidden>
Date:   Thu Oct 10 06:26:40 2019 +0200

    c: don't assume that UCHAR_MAX, etc. are defined
    
    A number of portability issues with GCC 4.6 .. 4.9 (inclusive):
    
        input.c:184:7: error: "UCHAR_MAX" is not defined [-Werror=undef]
         #elif UCHAR_MAX <= INT_MAX
               ^
        input.c:184:20: error: "INT_MAX" is not defined [-Werror=undef]
         #elif UCHAR_MAX <= INT_MAX
                            ^
        input.c:202:7: error: "USHRT_MAX" is not defined [-Werror=undef]
         #elif USHRT_MAX <= INT_MAX
               ^
        input.c:202:20: error: "INT_MAX" is not defined [-Werror=undef]
         #elif USHRT_MAX <= INT_MAX
                            ^
    
    * data/skeletons/c.m4 (b4_c99_int_type_define): Don't assume they are
    defined.

diff --git a/data/skeletons/c.m4 b/data/skeletons/c.m4
index 851bc652..4c0f266b 100644
--- a/data/skeletons/c.m4
+++ b/data/skeletons/c.m4
@@ -219,9 +219,9 @@ m4_define([b4_c99_int_type_define],
 
 #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
 typedef __UINT_LEAST8_TYPE__ yytype_uint8;
-#elif defined UINT_LEAST8_MAX && UINT_LEAST8_MAX <= INT_MAX
+#elif defined UINT_LEAST8_MAX && defined INT_MAX && UINT_LEAST8_MAX <= INT_MAX
 typedef uint_least8_t yytype_uint8;
-#elif UCHAR_MAX <= INT_MAX
+#elif defined UCHAR_MAX && defined INT_MAX && UCHAR_MAX <= INT_MAX
 typedef unsigned char yytype_uint8;
 #else
 typedef short yytype_uint8;
@@ -229,7 +229,7 @@ typedef short yytype_uint8;
 
 #if defined __INT_LEAST8_MAX__ && __INT_LEAST8_MAX__ <= __INT_MAX__
 typedef __INT_LEAST8_TYPE__ yytype_int8;
-#elif defined INT_LEAST8_MAX && INT_LEAST8_MAX <= INT_MAX
+#elif defined INT_LEAST8_MAX && defined INT_MAX && INT_LEAST8_MAX <= INT_MAX
 typedef int_least8_t yytype_int8;
 #else
 typedef signed char yytype_int8;
@@ -237,9 +237,9 @@ typedef signed char yytype_int8;
 
 #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
 typedef __UINT_LEAST16_TYPE__ yytype_uint16;
-#elif defined UINT_LEAST16_MAX && UINT_LEAST16_MAX <= INT_MAX
+#elif defined UINT_LEAST16_MAX && defined INT_MAX && UINT_LEAST16_MAX <= 
INT_MAX
 typedef uint_least16_t yytype_uint16;
-#elif USHRT_MAX <= INT_MAX
+#elif defined USHRT_MAX && defined INT_MAX && USHRT_MAX <= INT_MAX
 typedef unsigned short yytype_uint16;
 #else
 typedef int yytype_uint16;
@@ -247,7 +247,7 @@ typedef int yytype_uint16;
 
 #if defined __INT_LEAST16_MAX__ && __INT_LEAST16_MAX__ <= __INT_MAX__
 typedef __INT_LEAST16_TYPE__ yytype_int16;
-#elif defined INT_LEAST16_MAX && INT_LEAST16_MAX <= INT_MAX
+#elif defined INT_LEAST16_MAX && defined INT_MAX && INT_LEAST16_MAX <= INT_MAX
 typedef int_least16_t yytype_int16;
 #else
 typedef short yytype_int16;




reply via email to

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