summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2019-10-10 12:04:26 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2019-10-10 12:08:42 -0700
commit3f320159e32870bbba3b526da3290880bb15debc (patch)
tree8741451b783ac2930381d66d41c381f43b833a32 /data
parentf41e0cf73cba064f828ae3faa32cbd55ad15d19a (diff)
downloadbison-3f320159e32870bbba3b526da3290880bb15debc.tar.gz
c: improve patch for UCHAR_MAX etc. problem
* data/skeletons/c.m4 (b4_c99_int_type_define): Reorder to put the signed types first, since they’re simpler and this keeps similar code closer. For signed types, don’t bother checking whether the type promotes to int since the type must be signed anyway. For unsigned types, protect a test like ‘UCHAR_MAX <= INT_MAX’ with ‘!defined __UINT_LEAST8_MAX__’, as otherwise the logic is wrong for oddball platforms; and once we do that, there should no need for ‘defined INT_MAX’ so remove that.
Diffstat (limited to 'data')
-rw-r--r--data/skeletons/c.m442
1 files changed, 22 insertions, 20 deletions
diff --git a/data/skeletons/c.m4 b/data/skeletons/c.m4
index 4c0f266b..586ee663 100644
--- a/data/skeletons/c.m4
+++ b/data/skeletons/c.m4
@@ -217,40 +217,42 @@ m4_define([b4_c99_int_type_define],
save space and decrease cache pressure. Promoting to a signed type
helps avoid bugs in integer arithmetic. */
+#ifdef __INT_LEAST8_MAX__
+typedef __INT_LEAST8_TYPE__ yytype_int8;
+#elif defined INT_LEAST8_MAX
+typedef int_least8_t yytype_int8;
+#else
+typedef signed char yytype_int8;
+#endif
+
+#ifdef __INT_LEAST16_MAX__
+typedef __INT_LEAST16_TYPE__ yytype_int16;
+#elif defined INT_LEAST16_MAX
+typedef int_least16_t yytype_int16;
+#else
+typedef short yytype_int16;
+#endif
+
#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
typedef __UINT_LEAST8_TYPE__ yytype_uint8;
-#elif defined UINT_LEAST8_MAX && defined INT_MAX && UINT_LEAST8_MAX <= INT_MAX
+#elif (!defined __UINT_LEAST8_MAX__ && defined UINT_LEAST8_MAX \
+ && UINT_LEAST8_MAX <= INT_MAX)
typedef uint_least8_t yytype_uint8;
-#elif defined UCHAR_MAX && defined INT_MAX && UCHAR_MAX <= INT_MAX
+#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
typedef unsigned char yytype_uint8;
#else
typedef short yytype_uint8;
#endif
-#if defined __INT_LEAST8_MAX__ && __INT_LEAST8_MAX__ <= __INT_MAX__
-typedef __INT_LEAST8_TYPE__ yytype_int8;
-#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;
-#endif
-
#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
typedef __UINT_LEAST16_TYPE__ yytype_uint16;
-#elif defined UINT_LEAST16_MAX && defined INT_MAX && UINT_LEAST16_MAX <= INT_MAX
+#elif (!defined __UINT_LEAST16_MAX__ && defined UINT_LEAST16_MAX \
+ && UINT_LEAST16_MAX <= INT_MAX)
typedef uint_least16_t yytype_uint16;
-#elif defined USHRT_MAX && defined INT_MAX && USHRT_MAX <= INT_MAX
+#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
typedef unsigned short yytype_uint16;
#else
typedef int yytype_uint16;
-#endif
-
-#if defined __INT_LEAST16_MAX__ && __INT_LEAST16_MAX__ <= __INT_MAX__
-typedef __INT_LEAST16_TYPE__ yytype_int16;
-#elif defined INT_LEAST16_MAX && defined INT_MAX && INT_LEAST16_MAX <= INT_MAX
-typedef int_least16_t yytype_int16;
-#else
-typedef short yytype_int16;
#endif]])