Fixes automake bug https://bugs.gnu.org/20031.
The C++ standard does not require symbols be placed into the global
namespace, just in the std namespace. The GNU implementation will
place symbols in both. For our specific code, we don't care either.
Unfortunately, it looks like generated flex code assumes that some
stdlib.h symbols (free, malloc, exit) are in the global namespace,
even when compiling for C++. So when we include <cstdlib> but not
<stdlib.h>, we might not get the symbols in the global namespace.
We can workaround this by including stdlib.h in these tests without
invalidating the point of the tests in general.
* t/yacc-cxx.sh: Include stdlib.h.
* t/yacc-d-cxx.sh: Likewise.
* t/yacc-mix-c-cxx.sh: Likewise.
cat > parse1.yy << 'END'
%{
+// Include C header to provide global symbols that flex assumes.
+// https://bugs.gnu.org/20031
+#include <stdlib.h>
// Valid C++, but deliberately invalid C.
#include <cstdio>
#include <cstdlib>
header=$1
unindent <<END
%{
+ // Include C header to provide global symbols that flex assumes.
+ // https://bugs.gnu.org/20031
+ #include <stdlib.h>
// Valid C++, but deliberately invalid C.
#include <cstdlib>
#include "$header"
cat > parse.yy <<'END'
%{
+// Include C header to provide global symbols that flex assumes.
+// https://bugs.gnu.org/20031
+#include <stdlib.h>
+// Valid C++, but deliberately invalid C.
#include <cstdlib>
#include "parse.hh"
int yylex (void) { return 0; }