On 10/3/19 10:02 PM, Akim Demaille wrote:
I'm going back to Clang 3.3 and GCC 4.6. That's all I managed to set up on
Travis. I would also like to try tcc, but only to run the tests, not build
bison itself. Travis also supports MSVC; when I feel brave enough, I'll see if
I can use it for Bison.
For what it's worth, I can't build Bison master on Fedora 30 (the current stable
version of Fedora). Something to do with gettext version numbers. At some point
I suppose I should file a bug report. I work around the bug with --disable-nls,
but that's not compatible with --enable-gcc-warnings (so I suppose I should file
*two* bug reports :-).
Also, I have been trying to build Bison master on Solaris 10 (the oldest Solaris
still supported) with Oracle Developer Studio 12.6 (the current stable version).
I found a few glitches and just now installed the attached. I think there will
be a few glitches more.
We can introduce a %define variable to enable the new type for
columns/locations, and hook it to %require 3.5 to promote the conversion.
Should we let the user specify the type (any integer type, I suppose), or limit
the user to just 'unsigned' and 'intmax_t'? Perhaps call the type 'yy_pos_num'
in yacc.c? (Is there a reason it's yy_state_num in yacc.c but yyStateNum in
glr.c?) Just thinking out loud.
YY_CONVERT_INT_BEGIN
*yyssp = yystate;
YY_CONVERT_INT_END
Why would a warning here be bogus? It looks to me like a perfect place to use
a good old cast, as we're narrowing the type.
I don't like casts, because they mean the compiler won't catch serious errors
such as mistakenly assigning a pointer to an integer. Other GNU programs
typically do not enable -Wconversion or -Wimplicit-int-conversion because they
generate too many false alarms. I figured I could remove the need for casts by
disabling the misguided warnings.
However, after seeing your diagnostics I suppose that the pragmas are more
trouble than they're worth. Bison skeletons should be robust even in the
presence of misguided compiler options like -Wconversion (because some apps are
foolish enough to use such options :-) and it's such a pain to turn off these
options portably that casts are probably the way to go in skeletons, despite
their flaws.
GCC 8 with ASAN (https://api.travis-ci.org/v3/job/592926526/log.txt):
That URL uses Clang 8, not GCC 8. Of course Bison should work with Clang too,
but see below.
113. output.at:293: testing Output file name: `~!@#$%^&*()-=_+{}[]|\:;<>, .' ...
../../tests/output.at:293: touch "\`~!@#\$%^&*()-=_+{}[]|\\:;<>, .'.tmp" ||
exit 77
../../tests/output.at:293: COLUMNS=1000; export COLUMNS; bison --color=no -fno-caret -o
"\`~!@#\$%^&*()-=_+{}[]|\\:;<>, .'.c" --defines="\`~!@#\$%^&*()-=_+{}[]|\\:;<>,
.'.h" glr.y
../../tests/output.at:293: ls "\`~!@#\$%^&*()-=_+{}[]|\\:;<>, .'.c"
"\`~!@#\$%^&*()-=_+{}[]|\\:;<>, .'.h"
stdout:
`~!@#$%^&*()-=_+{}[]|\:;<>, .'.c
`~!@#$%^&*()-=_+{}[]|\:;<>, .'.h
../../tests/output.at:293: $CC $CFLAGS $CPPFLAGS -c -o glr.o -c
"\`~!@#\$%^&*()-=_+{}[]|\\:;<>, .'.c"
stderr:
`~!@#$%^&*()-=_+{}[]|\:;<>, .'.c:1467:37: error: operand of ? changes
signedness: 'ptrdiff_t' (aka 'long') to 'unsigned long' [-Werror,-Wsign-conversion]
ptrdiff_t half_max_capacity = YYSIZEMAX / (2 * sizeof yynewStates[0]);
^~~~~~~~~ ~
`~!@#$%^&*()-=_+{}[]|\:;<>, .'.c:132:59: note: expanded from macro 'YYSIZEMAX'
#define YYSIZEMAX (PTRDIFF_MAX < SIZE_MAX ? PTRDIFF_MAX : (ptrdiff_t) SIZE_MAX)
This is a bug in Clang, as both operands of ? are ptrdiff_t. You might try
filing a bug report with the Clang folks.
My experience with Clang warnings has not been great. Clang issues multiple
bogus warnings when compiling Bison itself, and there's little point to enabling
warnings, particularly in the test cases since Clang issues a bunch of false
alarms, so many that it's not worth looking for wheat among the chaff. I suggest
using --enable-gcc-warnings only with recent versions of GCC, which is my
practice in other projects. It's too much work to pacify Clang or older GCC
versions, and there's little benefit to doing so.
There's also the problem of using __STDC_VERSION__ which might be undefined.
Sorry about that, and thanks for fixing it.
>From 41e84cddc778d2a8902b1cdff6a85f3ea3422512 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Sat, 5 Oct 2019 01:07:52 -0700
Subject: [PATCH 1/3] Port lexcalc scan.l to Solaris 10
* examples/c/lexcalc/scan.l: Include errno.h.
---
examples/c/lexcalc/scan.l | 1 +
1 file changed, 1 insertion(+)
diff --git a/examples/c/lexcalc/scan.l b/examples/c/lexcalc/scan.l
index fc73f3b0..815f7782 100644
--- a/examples/c/lexcalc/scan.l
+++ b/examples/c/lexcalc/scan.l
@@ -4,6 +4,7 @@
%option nodefault noinput nounput noyywrap
%{
+#include <errno.h> /* errno, ERANGE */
#include <limits.h> /* INT_MIN */
#include <stdlib.h> /* strtol */
--
2.17.1
>From b75b05528803de1582d7bcfbd3480ee70a0e987b Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Sat, 5 Oct 2019 01:07:52 -0700
Subject: [PATCH 2/3] Port ARGMATCH_DEFINE_GROUP calls to C99
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* src/complain.c, src/getargs.c: Omit â;â after call
to ARGMATCH_DEFINE_GROUP, as C99 does not allow â;â there.
---
src/complain.c | 2 +-
src/getargs.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/complain.c b/src/complain.c
index ead8ebf7..8715898f 100644
--- a/src/complain.c
+++ b/src/complain.c
@@ -107,7 +107,7 @@ flush (FILE *out)
| --warnings's handling. |
`------------------------*/
-ARGMATCH_DEFINE_GROUP(warning, warnings);
+ARGMATCH_DEFINE_GROUP(warning, warnings)
static const argmatch_warning_doc argmatch_warning_docs[] =
{
diff --git a/src/getargs.c b/src/getargs.c
index 68894633..8c66c925 100644
--- a/src/getargs.c
+++ b/src/getargs.c
@@ -166,7 +166,7 @@ enum color
color_auto
};
-ARGMATCH_DEFINE_GROUP(color, enum color);
+ARGMATCH_DEFINE_GROUP(color, enum color)
static const argmatch_color_doc argmatch_color_docs[] =
{
@@ -202,7 +202,7 @@ const argmatch_color_group_type argmatch_color_group =
| --report's handling. |
`----------------------*/
-ARGMATCH_DEFINE_GROUP(report, enum report);
+ARGMATCH_DEFINE_GROUP(report, enum report)
static const argmatch_report_doc argmatch_report_docs[] =
{
@@ -240,7 +240,7 @@ const argmatch_report_group_type argmatch_report_group =
| --trace's handling. |
`---------------------*/
-ARGMATCH_DEFINE_GROUP(trace, enum trace);
+ARGMATCH_DEFINE_GROUP(trace, enum trace)
static const argmatch_trace_doc argmatch_trace_docs[] =
{
@@ -299,7 +299,7 @@ const argmatch_trace_group_type argmatch_trace_group =
| --feature's handling. |
`-----------------------*/
-ARGMATCH_DEFINE_GROUP(feature, enum feature);
+ARGMATCH_DEFINE_GROUP(feature, enum feature)
static const argmatch_feature_doc argmatch_feature_docs[] =
{
--
2.17.1
>From 8f5aaa0e04185cc54cdc9c6747685f720ac355f3 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Sat, 5 Oct 2019 01:07:52 -0700
Subject: [PATCH 3/3] Avoid quiet conversion of pointer to bool
* src/location.c (caret_set_file):
* src/scan-code.l (contains_dot_or_dash):
Do not quietly convert pointer to bool, as Oracle Developer Studio
12.6 complains and it is arguably confusing style anyway.
---
src/location.c | 2 +-
src/scan-code.l | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/location.c b/src/location.c
index 6bb7ba3b..a5c37fbc 100644
--- a/src/location.c
+++ b/src/location.c
@@ -257,7 +257,7 @@ caret_set_file (const char *file)
caret_free ();
}
}
- return caret_info.file;
+ return !!caret_info.file;
}
void caret_init (void)
diff --git a/src/scan-code.l b/src/scan-code.l
index 5fae172a..563baf52 100644
--- a/src/scan-code.l
+++ b/src/scan-code.l
@@ -216,7 +216,7 @@ is_dot_or_dash (char ch)
static inline bool
contains_dot_or_dash (const char* p)
{
- return strpbrk(p, ".-");
+ return !!strpbrk (p, ".-");
}
/* Defines a variant of a symbolic name resolution. */
--
2.17.1