* Re: Error compiling bison 3.4.2 on Solaris
2019-10-16 13:36 ` Dagobert Michelsen
@ 2019-10-17 19:49 ` Paul Eggert
2019-10-18 4:52 ` Akim Demaille
2019-10-22 12:04 ` Dagobert Michelsen
0 siblings, 2 replies; 8+ messages in thread
From: Paul Eggert @ 2019-10-17 19:49 UTC (permalink / raw)
To: Dagobert Michelsen; +Cc: bug-gnulib, bug-bison
[-- Attachment #1: Type: text/plain, Size: 1105 bytes --]
On 10/16/19 6:36 AM, Dagobert Michelsen wrote:
> I would think these are all compiler bugs and probably wouldn’t worry too much.
Thanks for mentioning the problems.
I built and and ran the Bison tests with Bison HEAD on Solaris 10 sparc
with Studio 12.3 (which supports C89 and C++03 by default, if I'm not
mistaken) and found one failure that was definitely a C++ compiler bug,
another one where I wasn't sure (I don't use C++ much) but a simple
workaround is available, two failures due to Solaris 10 /usr/bin
programs not quite conforming to POSIX, three integer overflow bugs
(ouch!), and two portability bugs where Bison was incorrectly assuming
partial support by Studio for C99 and for GCC __attribute__ syntax. I
installed the attached patches into Bison HEAD to fix everything but the
C++ compiler bug, which I just now reported separately
<https://lists.gnu.org/r/bug-bison/2019-10/msg00058.html>.
If you build Bison HEAD (which requires special tools) I suspect that
almost all the problems are now fixed on Solaris x86 as well, but I
haven't checked this.
[-- Attachment #2: 0001-autoconf-update.patch --]
[-- Type: text/x-patch, Size: 551 bytes --]
From f33689099f74bee0cf27372dba94dccce6edbe28 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Wed, 16 Oct 2019 17:33:16 -0700
Subject: [PATCH 01/11] autoconf:update
---
submodules/autoconf | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/submodules/autoconf b/submodules/autoconf
index 487d6aaa..babc8660 160000
--- a/submodules/autoconf
+++ b/submodules/autoconf
@@ -1 +1 @@
-Subproject commit 487d6aaaa4fe45001d30c439ea6240fc74f1b5d7
+Subproject commit babc8660d5a7561ed7e99e09aeabffaccfe06d6d
--
2.21.0
[-- Attachment #3: 0002-gnulib-update.patch --]
[-- Type: text/x-patch, Size: 1276 bytes --]
From 663a8565afb7325c16d98a08f7132b5a18f0c6a8 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Wed, 16 Oct 2019 17:33:23 -0700
Subject: [PATCH 02/11] gnulib:update
---
bootstrap | 2 +-
gnulib | 2 +-
m4/.gitignore | 1 +
3 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/bootstrap b/bootstrap
index 5b08e7e2..e273ea73 100755
--- a/bootstrap
+++ b/bootstrap
@@ -166,7 +166,7 @@ bootstrap_epilogue() { :; }
# specified directory. Fill in the first %s with the destination
# directory and the second with the domain name.
po_download_command_format=\
-"wget --mirror --level=1 -nd -q -A.po -P '%s' \
+"wget --mirror --level=1 -nd -nv -A.po -P '%s' \
https://translationproject.org/latest/%s/"
# Prefer a non-empty tarname (4th argument of AC_INIT if given), else
diff --git a/gnulib b/gnulib
index 672663ac..996cae1d 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit 672663aca33a8fac097f114693f69f09896ea62d
+Subproject commit 996cae1ddb5eb56222a4f7018aad1e1dc201b8c9
diff --git a/m4/.gitignore b/m4/.gitignore
index f661f375..3c20a6f2 100644
--- a/m4/.gitignore
+++ b/m4/.gitignore
@@ -115,6 +115,7 @@
/obstack.m4
/off_t.m4
/open-cloexec.m4
+/open-slash.m4
/open.m4
/pathmax.m4
/perror.m4
--
2.21.0
[-- Attachment #4: 0003-c-improve-port-of-stdint.h-usage-to-pre-C99.patch --]
[-- Type: text/x-patch, Size: 3421 bytes --]
From ff4eeda9266e27fc6e660aefa877de783c504da3 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 17 Oct 2019 09:27:37 -0700
Subject: [PATCH 03/11] c: improve port of stdint.h usage to pre-C99
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Oracle Solaris Studio 12.3 (Sun C 5.12 2011/11/16) by default does
not conform to C99; it defines __STDC_VERSION__ to be 199409L, so
the Bison code does not include <stdint.h> (not required by C89
amendment 1) even though this compiler does have <stdint.h>. On
this platform <limits.h> defines INT_LEAST8_MAX (POSIX allows
this) so the skeleton got confused and thought that <stdint.h> had
been included even though it wasn’t.
* data/skeletons/c.m4 (b4_c99_int_type_define) [!__PTRDIFF_MAX__]:
Always include <limits.h>.
(YY_STDINT_H): Define when <stdint.h> was included.
All uses of expressions like ‘defined INT_LEAST8_MAX’ changed to
‘defined YY_STDINT_H’, since Sun C 5.12 <limits.h> defines macros
like INT_LEAST8_MAX but does not declare types like int_least8_t.
---
data/skeletons/c.m4 | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/data/skeletons/c.m4 b/data/skeletons/c.m4
index 586ee663..4580fd75 100644
--- a/data/skeletons/c.m4
+++ b/data/skeletons/c.m4
@@ -202,13 +202,10 @@ m4_define([b4_c99_int_type_define],
so that the code can choose integer types of a good width. */
#ifndef __PTRDIFF_MAX__
-# ifndef INT_MAX
-# include <limits.h> /* INFRINGES ON USER NAME SPACE */
-# endif
-# ifndef PTRDIFF_MAX
-# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
-# include <stdint.h> /* INFRINGES ON USER NAME SPACE */
-# endif
+# include <limits.h> /* INFRINGES ON USER NAME SPACE */
+# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
+# include <stdint.h> /* INFRINGES ON USER NAME SPACE */
+# define YY_STDINT_H
# endif
#endif
@@ -219,7 +216,7 @@ m4_define([b4_c99_int_type_define],
#ifdef __INT_LEAST8_MAX__
typedef __INT_LEAST8_TYPE__ yytype_int8;
-#elif defined INT_LEAST8_MAX
+#elif defined YY_STDINT_H
typedef int_least8_t yytype_int8;
#else
typedef signed char yytype_int8;
@@ -227,7 +224,7 @@ typedef signed char yytype_int8;
#ifdef __INT_LEAST16_MAX__
typedef __INT_LEAST16_TYPE__ yytype_int16;
-#elif defined INT_LEAST16_MAX
+#elif defined YY_STDINT_H
typedef int_least16_t yytype_int16;
#else
typedef short yytype_int16;
@@ -235,7 +232,7 @@ typedef short yytype_int16;
#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
typedef __UINT_LEAST8_TYPE__ yytype_uint8;
-#elif (!defined __UINT_LEAST8_MAX__ && defined UINT_LEAST8_MAX \
+#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
&& UINT_LEAST8_MAX <= INT_MAX)
typedef uint_least8_t yytype_uint8;
#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
@@ -246,7 +243,7 @@ typedef short yytype_uint8;
#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
typedef __UINT_LEAST16_TYPE__ yytype_uint16;
-#elif (!defined __UINT_LEAST16_MAX__ && defined UINT_LEAST16_MAX \
+#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
&& UINT_LEAST16_MAX <= INT_MAX)
typedef uint_least16_t yytype_uint16;
#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
--
2.21.0
[-- Attachment #5: 0004-c-port-YY_ATTRIBUTE_UNUSED-to-Sun-C-5.12.patch --]
[-- Type: text/x-patch, Size: 2620 bytes --]
From cbfe33545514c0c6b837fb57ad5d4f1c094771ab Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 17 Oct 2019 11:28:38 -0700
Subject: [PATCH 04/11] c: port YY_ATTRIBUTE_UNUSED to Sun C 5.12
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Sun C 5.12 defines __SUNPRO_C to 0x5120 but diagnoses
‘__attribute__ ((__unused__))’. Change the ifdefs to use
the same method as Gnulib in this area.
* data/skeletons/c.m4 (YY_ATTRIBUTE): Remove, since
not all attributes were added in the same compiler version.
(YY_ATTRIBUTE_PURE, YY_ATTRIBUTE_UNUSED):
Use specific GCC version for each attribute.
Pay no attention to __SUNPRO_C.
* tests/headers.at (Several parsers): Tighten tests accordingly.
---
data/skeletons/c.m4 | 20 +++++++++-----------
| 2 +-
2 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/data/skeletons/c.m4 b/data/skeletons/c.m4
index 4580fd75..a1d55d47 100644
--- a/data/skeletons/c.m4
+++ b/data/skeletons/c.m4
@@ -282,22 +282,20 @@ m4_define([b4_table_value_equals],
# Provide portable compiler "attributes". If "noreturn" is passed, define
# _Noreturn.
m4_define([b4_attribute_define],
-[[#ifndef YY_ATTRIBUTE
-# if (defined __GNUC__ \
- && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
- || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
-# define YY_ATTRIBUTE(Spec) __attribute__(Spec)
+[[#ifndef YY_ATTRIBUTE_PURE
+# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
+# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
# else
-# define YY_ATTRIBUTE(Spec) /* empty */
+# define YY_ATTRIBUTE_PURE
# endif
#endif
-#ifndef YY_ATTRIBUTE_PURE
-# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
-#endif
-
#ifndef YY_ATTRIBUTE_UNUSED
-# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
+# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
+# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
+# else
+# define YY_ATTRIBUTE_UNUSED
+# endif
#endif
]m4_bmatch([$1], [\bnoreturn\b], [[/* The _Noreturn keyword of C11. */
--git a/tests/headers.at b/tests/headers.at
index d1e75bf8..390dfa4c 100644
--- a/tests/headers.at
+++ b/tests/headers.at
@@ -321,7 +321,7 @@ AT_PERL_CHECK([[-n -0777 -e '
|YYChar
|YYPUSH_MORE(?:_DEFINED)?
|YYUSE
- |YY_ATTRIBUTE(?:_PURE|_UNUSED)?
+ |YY_ATTRIBUTE(?:_PURE|_UNUSED)
|YY_CONSTEXPR
|YY_COPY
|YY_CPLUSPLUS
--
2.21.0
[-- Attachment #6: 0005-bison-check-version-numbers-more-carefully.patch --]
[-- Type: text/x-patch, Size: 2173 bytes --]
From 91d8fb4087dba6daf390dc79d5dd01016b8ec15f Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 17 Oct 2019 11:31:59 -0700
Subject: [PATCH 05/11] bison: check version numbers more carefully
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* src/parse-gram.y: Include intprops.h.
(handle_require): Don’t indulge in undefined behavior if the major
or minor number is out of range. Instead, check that the
resulting value is nonnegative, fits in int, and that the minor
number is less than 100. Also, check that a number was parsed.
---
src/parse-gram.y | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/parse-gram.y b/src/parse-gram.y
index 043fa581..54b20880 100644
--- a/src/parse-gram.y
+++ b/src/parse-gram.y
@@ -40,6 +40,7 @@
#include "files.h"
#include "getargs.h"
#include "gram.h"
+ #include "intprops.h"
#include "named-ref.h"
#include "quotearg.h"
#include "reader.h"
@@ -975,23 +976,24 @@ handle_require (location const *loc, char const *version)
/* Changes of behavior are only on minor version changes, so "3.0.5"
is the same as "3.0". */
errno = 0;
- char* cp = NULL;
+ char *cp = NULL, *cp1;
long major = strtol (version, &cp, 10);
- if (errno || *cp != '.')
+ if (errno || cp == version || *cp != '.' || major < 0)
{
complain (loc, complaint, _("invalid version requirement: %s"),
version);
return;
}
++cp;
- long minor = strtol (cp, NULL, 10);
- if (errno)
+ long minor = strtol (cp, &cp1, 10);
+ if (errno || cp1 == cp || ! (0 <= minor && minor < 100)
+ || INT_MULTIPLY_WRAPV (major, 100, &required_version)
+ || INT_ADD_WRAPV (minor, required_version, &required_version))
{
complain (loc, complaint, _("invalid version requirement: %s"),
version);
return;
}
- required_version = major * 100 + minor;
/* Pretend to be at least 3.4, to check features published in 3.4
while developping it. */
const char* api_version = "3.4";
--
2.21.0
[-- Attachment #7: 0006-bison-check-for-int-overflow-when-scanning.patch --]
[-- Type: text/x-patch, Size: 2122 bytes --]
From d1ddb2114fbd068f3919463a2af7d28ed92bd6ff Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 17 Oct 2019 11:33:54 -0700
Subject: [PATCH 06/11] bison: check for int overflow when scanning
* src/scan-gram.l: Include errno.h, for errno.
(scan_integer, handle_syncline): Check for integer overflow.
* tests/input.at (too-large.y): Adjust to match new diagnostics.
---
src/scan-gram.l | 8 ++++++--
tests/input.at | 2 ++
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/scan-gram.l b/src/scan-gram.l
index 861a58cb..7667648d 100644
--- a/src/scan-gram.l
+++ b/src/scan-gram.l
@@ -21,6 +21,8 @@
%option prefix="gram_" outfile="lex.yy.c"
%{
+#include <errno.h>
+
#include <c-ctype.h>
#include <mbswidth.h>
#include <quote.h>
@@ -818,9 +820,10 @@ scan_integer (char const *number, int base, location loc)
complain (&loc, Wyacc,
_("POSIX Yacc does not support hexadecimal literals"));
+ errno = 0;
long num = strtol (number, NULL, base);
- if (! (0 <= num && num <= INT_MAX))
+ if (! (0 <= num && num <= INT_MAX && errno == 0))
{
complain (&loc, complaint, _("integer out of range: %s"),
quote (number));
@@ -896,8 +899,9 @@ static void
handle_syncline (char *args, location loc)
{
char *file;
+ errno = 0;
long lineno = strtol (args, &file, 10);
- if (! (0 <= lineno && lineno <= INT_MAX))
+ if (! (0 <= lineno && lineno <= INT_MAX && errno == 0))
{
complain (&loc, Wother, _("line number overflow"));
lineno = INT_MAX;
diff --git a/tests/input.at b/tests/input.at
index f696f0cf..fe03f2e1 100644
--- a/tests/input.at
+++ b/tests/input.at
@@ -1523,7 +1523,9 @@ start: TOO_LARGE_DEC TOO_LARGE_HEX
AT_BISON_CHECK([too-large.y], [1], [],
[[too-large.y:9.22-42: error: integer out of range: '999999999999999999999'
+too-large.y:9.22-42: error: user token number of TOO_LARGE_DEC too large
too-large.y:10.24-44: error: integer out of range: '0xFFFFFFFFFFFFFFFFFFF'
+too-large.y:10.24-44: error: user token number of TOO_LARGE_HEX too large
]])
AT_BISON_OPTION_POPDEFS
--
2.21.0
[-- Attachment #8: 0007-bison-check-for-int-overflow-in-token-numbers.patch --]
[-- Type: text/x-patch, Size: 2029 bytes --]
From ddb9ec59ec0388273bc53ea1c3a36a3ed93ea996 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 17 Oct 2019 11:35:48 -0700
Subject: [PATCH 07/11] bison: check for int overflow in token numbers
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* src/symtab.c: Include intprops.h
(symbol_user_token_number_set): Don’t allow user_token_number ==
INT_MAX because too much other code adds 1 to the user token number.
(symbols_token_translations_init): Complain on integer overflow
instead of indulging in undefined behavior.
---
src/symtab.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/symtab.c b/src/symtab.c
index f2454725..a619d177 100644
--- a/src/symtab.c
+++ b/src/symtab.c
@@ -30,6 +30,7 @@
#include "complain.h"
#include "getargs.h"
#include "gram.h"
+#include "intprops.h"
#include "quote.h"
@@ -549,6 +550,9 @@ symbol_user_token_number_set (symbol *sym, int user_token_number, location loc)
&& *user_token_numberp != user_token_number)
complain (&loc, complaint, _("redefining user token number of %s"),
sym->tag);
+ else if (user_token_number == INT_MAX)
+ complain (&loc, complaint, _("user token number of %s too large"),
+ sym->tag);
else
{
*user_token_numberp = user_token_number;
@@ -1005,7 +1009,11 @@ symbols_token_translations_init (void)
{
sym_content *this = symbols[i]->content;
if (this->user_token_number == USER_NUMBER_UNDEFINED)
- this->user_token_number = ++max_user_token_number;
+ {
+ if (INT_ADD_WRAPV (max_user_token_number, 1, &max_user_token_number))
+ complain (NULL, fatal, _("token number too large"));
+ this->user_token_number = max_user_token_number;
+ }
if (this->user_token_number > max_user_token_number)
max_user_token_number = this->user_token_number;
}
--
2.21.0
[-- Attachment #9: 0008-tests-port-to-Solaris-10-sed.patch --]
[-- Type: text/x-patch, Size: 963 bytes --]
From 24872a578ce0156187ccd06b3e3cd2507d8084e1 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 17 Oct 2019 11:39:51 -0700
Subject: [PATCH 08/11] tests: port to Solaris 10 sed
As documented in the Autoconf manual, Solaris 10 sed rejects
script labels contianing more than 7 characters. POSIX requires
support for at least 8 characters, but we might as well be portable
to Solaris 10 which is still supported.
* tests/local.at (AT_SETS_CHECK): Use only the first 7 characters
in sed labels.
---
tests/local.at | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/local.at b/tests/local.at
index 14cd448c..43de4abc 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -1435,10 +1435,10 @@ m4_define([AT_SETS_CHECK],
[[#n
]m4_foreach([m4_Set], [$2], [[
/^]m4_Set[/ {
- :]m4_Set[
+ :]m4_substr(m4_Set, 0, 7)[
p
n
- /^ *$/ !b ]m4_Set[
+ /^ *$/ !b ]m4_substr(m4_Set, 0, 7)[
}
]])])
--
2.21.0
[-- Attachment #10: 0009-tests-port-to-Solaris-10-grep.patch --]
[-- Type: text/x-patch, Size: 972 bytes --]
From f43512828955e0e991d19c73943e99e2a2374971 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 17 Oct 2019 11:40:56 -0700
Subject: [PATCH 09/11] tests: port to Solaris 10 grep
* tests/scanner.at (Token numbers: $1): Use $EGREP, not grep -E.
---
tests/scanner.at | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/scanner.at b/tests/scanner.at
index 543d5cfc..39abf693 100644
--- a/tests/scanner.at
+++ b/tests/scanner.at
@@ -189,7 +189,7 @@ AT_FULL_COMPILE([input])
# yacc.c, glr.c and glr.cc use 'yytranslate' (and YYTRANSLATE).
# lalr1.cc uses 'translate_table' (and yytranslate_).
# lalr1.d uses 'byte[] translate_table =' (and yytranslate_).
-AT_CHECK([[grep -Ec 'yytranslate\[\]|translate_table\[\]|translate_table =' input.]AT_LANG_EXT],
+AT_CHECK([[$EGREP -c 'yytranslate\[\]|translate_table\[\]|translate_table =' input.]AT_LANG_EXT],
[ignore],
[AT_TOKEN_RAW_IF([0], [1])[
]])
--
2.21.0
[-- Attachment #11: 0010-regen.patch --]
[-- Type: text/x-patch, Size: 15058 bytes --]
From 93b2e58ebefc9b8929301889bc6ee7f8db68595d Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 17 Oct 2019 11:50:34 -0700
Subject: [PATCH 10/11] regen
---
src/parse-gram.c | 151 +++++++++++++++++++++++------------------------
src/parse-gram.h | 2 +-
2 files changed, 75 insertions(+), 78 deletions(-)
diff --git a/src/parse-gram.c b/src/parse-gram.c
index db2454c6..86cd782d 100644
--- a/src/parse-gram.c
+++ b/src/parse-gram.c
@@ -1,4 +1,4 @@
-/* A Bison parser, made by GNU Bison 3.4.2.169-2644f. */
+/* A Bison parser, made by GNU Bison 3.4.2.189-f435. */
/* Bison implementation for Yacc-like parsers in C
@@ -48,7 +48,7 @@
#define YYBISON 1
/* Bison version. */
-#define YYBISON_VERSION "3.4.2.169-2644f"
+#define YYBISON_VERSION "3.4.2.189-f435"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -113,6 +113,7 @@
#include "files.h"
#include "getargs.h"
#include "gram.h"
+ #include "intprops.h"
#include "named-ref.h"
#include "quotearg.h"
#include "reader.h"
@@ -208,13 +209,10 @@
so that the code can choose integer types of a good width. */
#ifndef __PTRDIFF_MAX__
-# ifndef INT_MAX
-# include <limits.h> /* INFRINGES ON USER NAME SPACE */
-# endif
-# ifndef PTRDIFF_MAX
-# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
-# include <stdint.h> /* INFRINGES ON USER NAME SPACE */
-# endif
+# include <limits.h> /* INFRINGES ON USER NAME SPACE */
+# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
+# include <stdint.h> /* INFRINGES ON USER NAME SPACE */
+# define YY_STDINT_H
# endif
#endif
@@ -225,7 +223,7 @@
#ifdef __INT_LEAST8_MAX__
typedef __INT_LEAST8_TYPE__ yytype_int8;
-#elif defined INT_LEAST8_MAX
+#elif defined YY_STDINT_H
typedef int_least8_t yytype_int8;
#else
typedef signed char yytype_int8;
@@ -233,7 +231,7 @@ typedef signed char yytype_int8;
#ifdef __INT_LEAST16_MAX__
typedef __INT_LEAST16_TYPE__ yytype_int16;
-#elif defined INT_LEAST16_MAX
+#elif defined YY_STDINT_H
typedef int_least16_t yytype_int16;
#else
typedef short yytype_int16;
@@ -241,7 +239,7 @@ typedef short yytype_int16;
#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
typedef __UINT_LEAST8_TYPE__ yytype_uint8;
-#elif (!defined __UINT_LEAST8_MAX__ && defined UINT_LEAST8_MAX \
+#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
&& UINT_LEAST8_MAX <= INT_MAX)
typedef uint_least8_t yytype_uint8;
#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
@@ -252,7 +250,7 @@ typedef short yytype_uint8;
#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
typedef __UINT_LEAST16_TYPE__ yytype_uint16;
-#elif (!defined __UINT_LEAST16_MAX__ && defined UINT_LEAST16_MAX \
+#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
&& UINT_LEAST16_MAX <= INT_MAX)
typedef uint_least16_t yytype_uint16;
#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
@@ -295,10 +293,11 @@ typedef int yytype_uint16;
#define YYSIZEOF(X) ((YYPTRDIFF_T) sizeof (X))
+/* Stored state numbers (used for stacks). */
+typedef yytype_uint8 yy_state_t;
-/* State numbers. */
-typedef yytype_uint8 yy_state_num;
-
+/* State numbers in computations. */
+typedef int yy_state_fast_t;
#ifndef YY_
# if defined YYENABLE_NLS && YYENABLE_NLS
@@ -312,22 +311,20 @@ typedef yytype_uint8 yy_state_num;
# endif
#endif
-#ifndef YY_ATTRIBUTE
-# if (defined __GNUC__ \
- && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
- || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
-# define YY_ATTRIBUTE(Spec) __attribute__(Spec)
+#ifndef YY_ATTRIBUTE_PURE
+# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
+# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
# else
-# define YY_ATTRIBUTE(Spec) /* empty */
+# define YY_ATTRIBUTE_PURE
# endif
#endif
-#ifndef YY_ATTRIBUTE_PURE
-# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
-#endif
-
#ifndef YY_ATTRIBUTE_UNUSED
-# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
+# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
+# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
+# else
+# define YY_ATTRIBUTE_UNUSED
+# endif
#endif
/* Suppress unused-variable warnings by "using" E. */
@@ -412,7 +409,7 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
/* A type that is properly aligned for any stack member. */
union yyalloc
{
- yy_state_num yyss_alloc;
+ yy_state_t yyss_alloc;
YYSTYPE yyvs_alloc;
YYLTYPE yyls_alloc;
};
@@ -423,7 +420,7 @@ union yyalloc
/* The size of an array large to enough to hold all stacks, each with
N elements. */
# define YYSTACK_BYTES(N) \
- ((N) * (YYSIZEOF (yy_state_num) + YYSIZEOF (YYSTYPE) \
+ ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE) \
+ YYSIZEOF (YYLTYPE)) \
+ 2 * YYSTACK_GAP_MAXIMUM)
@@ -493,19 +490,19 @@ union yyalloc
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_int16 yyrline[] =
{
- 0, 291, 291, 300, 301, 305, 306, 312, 316, 321,
- 322, 327, 328, 329, 330, 331, 336, 341, 342, 343,
- 344, 345, 346, 346, 347, 348, 349, 350, 351, 352,
- 353, 354, 358, 359, 368, 369, 373, 384, 388, 392,
- 400, 410, 411, 421, 422, 428, 441, 441, 446, 446,
- 451, 455, 465, 466, 467, 468, 472, 473, 478, 479,
- 483, 484, 488, 489, 490, 503, 512, 516, 520, 528,
- 529, 533, 546, 547, 559, 563, 567, 575, 577, 582,
- 589, 599, 603, 607, 615, 616, 624, 625, 631, 632,
- 633, 640, 640, 648, 649, 650, 655, 658, 660, 662,
- 664, 666, 668, 670, 672, 674, 679, 680, 689, 713,
- 714, 715, 716, 728, 730, 757, 762, 763, 768, 777,
- 778, 782, 783
+ 0, 292, 292, 301, 302, 306, 307, 313, 317, 322,
+ 323, 328, 329, 330, 331, 332, 337, 342, 343, 344,
+ 345, 346, 347, 347, 348, 349, 350, 351, 352, 353,
+ 354, 355, 359, 360, 369, 370, 374, 385, 389, 393,
+ 401, 411, 412, 422, 423, 429, 442, 442, 447, 447,
+ 452, 456, 466, 467, 468, 469, 473, 474, 479, 480,
+ 484, 485, 489, 490, 491, 504, 513, 517, 521, 529,
+ 530, 534, 547, 548, 560, 564, 568, 576, 578, 583,
+ 590, 600, 604, 608, 616, 617, 625, 626, 632, 633,
+ 634, 641, 641, 649, 650, 651, 656, 659, 661, 663,
+ 665, 667, 669, 671, 673, 675, 680, 681, 690, 714,
+ 715, 716, 717, 729, 731, 758, 763, 764, 769, 778,
+ 779, 783, 784
};
#endif
@@ -1113,7 +1110,7 @@ yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE
`------------------------------------------------------------------*/
static void
-yy_stack_print (yy_state_num *yybottom, yy_state_num *yytop)
+yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
{
YYFPRINTF (stderr, "Stack now");
for (; yybottom <= yytop; yybottom++)
@@ -1136,7 +1133,7 @@ do { \
`------------------------------------------------*/
static void
-yy_reduce_print (yy_state_num *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule)
+yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule)
{
int yylno = yyrline[yyrule];
int yynrhs = yyr2[yyrule];
@@ -1204,9 +1201,9 @@ yy_lac_stack_realloc (YYPTRDIFF_T *yycapacity, YYPTRDIFF_T yyadd,
char const *yydebug_prefix,
char const *yydebug_suffix,
#endif
- yy_state_num **yybottom,
- yy_state_num *yybottom_no_free,
- yy_state_num **yytop, yy_state_num *yytop_empty)
+ yy_state_t **yybottom,
+ yy_state_t *yybottom_no_free,
+ yy_state_t **yytop, yy_state_t *yytop_empty)
{
YYPTRDIFF_T yysize_old =
*yytop == yytop_empty ? 0 : *yytop - *yybottom + 1;
@@ -1214,7 +1211,7 @@ yy_lac_stack_realloc (YYPTRDIFF_T *yycapacity, YYPTRDIFF_T yyadd,
if (*yycapacity < yysize_new)
{
YYPTRDIFF_T yyalloc = 2 * yysize_new;
- yy_state_num *yybottom_new;
+ yy_state_t *yybottom_new;
/* Use YYMAXDEPTH for maximum stack size given that the stack
should never need to grow larger than the main state stack
needs to grow without LAC. */
@@ -1227,7 +1224,7 @@ yy_lac_stack_realloc (YYPTRDIFF_T *yycapacity, YYPTRDIFF_T yyadd,
if (YYMAXDEPTH < yyalloc)
yyalloc = YYMAXDEPTH;
yybottom_new =
- (yy_state_num *) YYSTACK_ALLOC ((YYSIZE_T)
+ (yy_state_t *) YYSTACK_ALLOC ((YYSIZE_T)
(yyalloc * YYSIZEOF (*yybottom_new)));
if (!yybottom_new)
{
@@ -1328,11 +1325,11 @@ do { \
contents of either array, alter *YYES and *YYES_CAPACITY, and free
any old *YYES other than YYESA. */
static int
-yy_lac (yy_state_num *yyesa, yy_state_num **yyes,
- YYPTRDIFF_T *yyes_capacity, yy_state_num *yyssp, int yytoken)
+yy_lac (yy_state_t *yyesa, yy_state_t **yyes,
+ YYPTRDIFF_T *yyes_capacity, yy_state_t *yyssp, int yytoken)
{
- yy_state_num *yyes_prev = yyssp;
- yy_state_num *yyesp = yyes_prev;
+ yy_state_t *yyes_prev = yyssp;
+ yy_state_t *yyesp = yyes_prev;
YYDPRINTF ((stderr, "LAC: checking lookahead %s:", yytname[yytoken]));
if (yytoken == YYUNDEFTOK)
{
@@ -1389,7 +1386,7 @@ yy_lac (yy_state_num *yyesa, yy_state_num **yyes,
yyesp = yyes_prev -= yylen;
}
{
- int yystate;
+ yy_state_fast_t yystate;
{
const int yylhs = yyr1[yyrule] - YYNTOKENS;
const int yyi = yypgoto[yylhs] + *yyesp;
@@ -1400,7 +1397,7 @@ yy_lac (yy_state_num *yyesa, yy_state_num **yyes,
if (yyesp == yyes_prev)
{
yyesp = *yyes;
- *yyesp = (yy_state_num) yystate;
+ *yyesp = (yy_state_t) yystate;
}
else
{
@@ -1413,7 +1410,7 @@ yy_lac (yy_state_num *yyesa, yy_state_num **yyes,
YYDPRINTF ((stderr, "\n"));
return 2;
}
- *++yyesp = (yy_state_num) yystate;
+ *++yyesp = (yy_state_t) yystate;
}
YYDPRINTF ((stderr, " G%d", yystate));
}
@@ -1522,8 +1519,8 @@ yytnamerr (char *yyres, const char *yystr)
yy_lac returned 2. */
static int
yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
- yy_state_num *yyesa, yy_state_num **yyes,
- YYPTRDIFF_T *yyes_capacity, yy_state_num *yyssp, int yytoken)
+ yy_state_t *yyesa, yy_state_t **yyes,
+ YYPTRDIFF_T *yyes_capacity, yy_state_t *yyssp, int yytoken)
{
YYPTRDIFF_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
YYPTRDIFF_T yysize = yysize0;
@@ -1743,7 +1740,7 @@ YYLTYPE yylloc = yyloc_default;
/* Number of syntax errors so far. */
int yynerrs;
- int yystate;
+ yy_state_fast_t yystate;
/* Number of tokens to shift before error messages enabled. */
int yyerrstatus;
@@ -1756,9 +1753,9 @@ YYLTYPE yylloc = yyloc_default;
to reallocate them elsewhere. */
/* The state stack. */
- yy_state_num yyssa[YYINITDEPTH];
- yy_state_num *yyss;
- yy_state_num *yyssp;
+ yy_state_t yyssa[YYINITDEPTH];
+ yy_state_t *yyss;
+ yy_state_t *yyssp;
/* The semantic value stack. */
YYSTYPE yyvsa[YYINITDEPTH];
@@ -1775,8 +1772,8 @@ YYLTYPE yylloc = yyloc_default;
YYPTRDIFF_T yystacksize;
- yy_state_num yyesa[20];
- yy_state_num *yyes;
+ yy_state_t yyesa[20];
+ yy_state_t *yyes;
YYPTRDIFF_T yyes_capacity;
int yy_lac_established = 0;
@@ -1847,7 +1844,7 @@ yynewstate:
yysetstate:
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
- *yyssp = (yy_state_num) yystate;
+ *yyssp = (yy_state_t) yystate;
if (yyss + yystacksize - 1 <= yyssp)
#if !defined yyoverflow && !defined YYSTACK_RELOCATE
@@ -1862,7 +1859,7 @@ yysetstate:
/* Give user a chance to reallocate the stack. Use copies of
these so that the &'s don't force the real ones into
memory. */
- yy_state_num *yyss1 = yyss;
+ yy_state_t *yyss1 = yyss;
YYSTYPE *yyvs1 = yyvs;
YYLTYPE *yyls1 = yyls;
@@ -1888,7 +1885,7 @@ yysetstate:
yystacksize = YYMAXDEPTH;
{
- yy_state_num *yyss1 = yyss;
+ yy_state_t *yyss1 = yyss;
union yyalloc *yyptr =
(union yyalloc *) YYSTACK_ALLOC ((YYSIZE_T)
YYSTACK_BYTES (yystacksize));
@@ -1978,16 +1975,15 @@ yybackup:
/* Shift the lookahead token. */
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
-
- /* Discard the shifted token. */
- yychar = YYEMPTY;
- YY_LAC_DISCARD ("shift");
-
yystate = yyn;
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
*++yylsp = yylloc;
+
+ /* Discard the shifted token. */
+ yychar = YYEMPTY;
+ YY_LAC_DISCARD ("shift");
goto yynewstate;
@@ -2989,23 +2985,24 @@ handle_require (location const *loc, char const *version)
/* Changes of behavior are only on minor version changes, so "3.0.5"
is the same as "3.0". */
errno = 0;
- char* cp = NULL;
+ char *cp = NULL, *cp1;
long major = strtol (version, &cp, 10);
- if (errno || *cp != '.')
+ if (errno || cp == version || *cp != '.' || major < 0)
{
complain (loc, complaint, _("invalid version requirement: %s"),
version);
return;
}
++cp;
- long minor = strtol (cp, NULL, 10);
- if (errno)
+ long minor = strtol (cp, &cp1, 10);
+ if (errno || cp1 == cp || ! (0 <= minor && minor < 100)
+ || INT_MULTIPLY_WRAPV (major, 100, &required_version)
+ || INT_ADD_WRAPV (minor, required_version, &required_version))
{
complain (loc, complaint, _("invalid version requirement: %s"),
version);
return;
}
- required_version = major * 100 + minor;
/* Pretend to be at least 3.4, to check features published in 3.4
while developping it. */
const char* api_version = "3.4";
diff --git a/src/parse-gram.h b/src/parse-gram.h
index 15bf4ebc..97b9d1a5 100644
--- a/src/parse-gram.h
+++ b/src/parse-gram.h
@@ -1,4 +1,4 @@
-/* A Bison parser, made by GNU Bison 3.4.2.169-2644f. */
+/* A Bison parser, made by GNU Bison 3.4.2.189-f435. */
/* Bison interface for Yacc-like parsers in C
--
2.21.0
[-- Attachment #12: 0011-c-port-to-Sun-C-5.12.patch --]
[-- Type: text/x-patch, Size: 1437 bytes --]
From 0759f79241d147233b62e85de2139734949b903b Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 17 Oct 2019 12:24:33 -0700
Subject: [PATCH 11/11] c++: port to Sun C++ 5.12
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The documentation for Oracle Solaris Studio 12.3 (Sun C++ 5.12
2011/11/16) says it supports C++03. This compiler rejects the
location.cc use of std::max for some reason; I don’t know why
since I don’t use C++ as a rule. The simplest workaround is to
open-code ‘max’.
* data/skeletons/location.cc (add_):
Do max by hand rather than relying on std::max.
Don’t include <algorithm.h>; no longer needed.
---
data/skeletons/location.cc | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/data/skeletons/location.cc b/data/skeletons/location.cc
index 8a330b92..78af3698 100644
--- a/data/skeletons/location.cc
+++ b/data/skeletons/location.cc
@@ -113,7 +113,7 @@ m4_define([b4_location_define],
/// Compute max (min, lhs+rhs).
static int add_ (int lhs, int rhs, int min)
{
- return std::max (min, lhs + rhs);
+ return lhs + rhs < min ? min : lhs + rhs;
}
};
@@ -345,7 +345,6 @@ m4_ifdef([b4_location_file], [[
]b4_cpp_guard_open([b4_location_path])[
-# include <algorithm> // std::max
# include <iostream>
# include <string>
--
2.21.0
^ permalink raw reply related [flat|nested] 8+ messages in thread