Hi Dennis, > Le 4 nov. 2021 à 01:51, Dennis Clarke <dcla...@blastwave.org> a écrit : > > I have for you a pile of data. > > I don't want to bore you with a ton of details here but I will attach > a log file that explains everything.
On the example side, we have: > "examples/c/bistromathic/parse.c", line 2023: warning: implicit function > declaration: strdup IOW, same problems as before. I have updated the commit to also apply to bistromathic, see below. On the test suite side: > 613. torture.at:385: 613. Many lookahead tokens (torture.at:385): FAILED > (torture.at:394) > ./torture.at:394: $CC $CFLAGS $CPPFLAGS $LDFLAGS -o input input.c $LIBS > stderr: > c99: Warning: Option -64 passed to ld, if ld is invoked, ignored otherwise > "input.c", line 17804: internal compiler error: Out of memory > c99: acomp failed for input.c I won't fight this. > 705. cxx-type.at:406: testing GLR: Resolve ambiguity, impure, no locations ... > c99: Warning: Option -64 passed to ld, if ld is invoked, ignored otherwise > "types.y", line 188: warning: implicit function declaration: strdup Likewise 706, 707, 708, 709, 710, 711, 712, 713. So I will install the following commit to, imho, address all the failures, except test 613 from the test suite. The following tarball contains that commit. While at it, I have also updated gnulib. Could you please check it too? Thanks Dennis! https://www.lrde.epita.fr/~akim/private/bison/bison-3.8.2.7-76301.tar.gz https://www.lrde.epita.fr/~akim/private/bison/bison-3.8.2.7-76301.tar.lz https://www.lrde.epita.fr/~akim/private/bison/bison-3.8.2.7-76301.tar.xz commit c83425ef4e1c66c81d328338e6bf98f5e3c33b81 Author: Akim Demaille <akim.demai...@gmail.com> Date: Sat Oct 23 06:01:44 2021 +0200 tests: address portability issues about strdup Reported by Dennis Clarke <https://lists.gnu.org/r/bug-bison/2021-10/msg00005.html>. In particular <https://lists.gnu.org/r/bug-bison/2021-10/msg00023.html>. * doc/bison.texi, examples/c/glr/c++-types.y, * examples/c/bistromathic/parse.y tests/testsuite.h: Define _XOPEN_SOURCE to 600, to get a strdup that works on Solaris. * tests/glr-regression.at: Use strdup freely. diff --git a/doc/bison.texi b/doc/bison.texi index a559649c..77357813 100644 --- a/doc/bison.texi +++ b/doc/bison.texi @@ -2644,6 +2644,13 @@ @node Mfcalc Declarations You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. */ + +%code top { + /* Portability issues for strdup. */ +#ifndef _XOPEN_SOURCE +# define _XOPEN_SOURCE 600 +#endif +} @end example @end ignore @@ -2875,7 +2882,7 @@ @node Mfcalc Symbol Table not make these assumptions. */ #include <assert.h> #include <stdlib.h> /* malloc, realloc. */ -#include <string.h> /* strlen. */ +#include <string.h> /* strdup, strlen. */ @end group @group diff --git a/examples/c/bistromathic/parse.y b/examples/c/bistromathic/parse.y index fbdeb7fc..5c1e6055 100644 --- a/examples/c/bistromathic/parse.y +++ b/examples/c/bistromathic/parse.y @@ -21,6 +21,11 @@ // Emitted on top of the implementation file. %code top { + /* Portability issues for strdup. */ + #ifndef _XOPEN_SOURCE + # define _XOPEN_SOURCE 600 + #endif + #include <ctype.h> // isdigit #include <locale.h> // LC_ALL #include <math.h> // cos, sin, etc. diff --git a/examples/c/glr/c++-types.y b/examples/c/glr/c++-types.y index 4c978386..ff1b62fb 100644 --- a/examples/c/glr/c++-types.y +++ b/examples/c/glr/c++-types.y @@ -53,6 +53,10 @@ %code { + /* Portability issues for strdup. */ +#ifndef _XOPEN_SOURCE +# define _XOPEN_SOURCE 600 +#endif #include <assert.h> #include <ctype.h> diff --git a/tests/glr-regression.at b/tests/glr-regression.at index a10f69ba..3a226f65 100644 --- a/tests/glr-regression.at +++ b/tests/glr-regression.at @@ -295,9 +295,7 @@ m4_pushdef([AT_TEST], else { assert (strlen (buf) < sizeof buf - 1); - char *s = YY_CAST (char *, malloc (strlen (buf) + 1)); - strcpy (s, buf); - ]AT_VAL[ = s; + ]AT_VAL[ = strdup (buf); return 'V'; } break; diff --git a/tests/testsuite.h b/tests/testsuite.h index 46e99dfe..d2be5e62 100644 --- a/tests/testsuite.h +++ b/tests/testsuite.h @@ -10,3 +10,8 @@ # pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" # endif #endif + +/* We use strdup, make it available. */ +#ifndef _XOPEN_SOURCE +# define _XOPEN_SOURCE 600 +#endif