summaryrefslogtreecommitdiff
path: root/t/yacc-mix-c-cxx.sh
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2022-02-20 14:28:11 -0500
committerMike Frysinger <vapier@gentoo.org>2022-02-23 23:04:41 -0500
commit13ae585a0184a4c0113fd4f3a19a0cedf1cfe5c2 (patch)
treea4760e4f2f13e6709f951364a1fc991e74073eb2 /t/yacc-mix-c-cxx.sh
parent2cd42b7cd55b2713c7d6d976dc0791875ea7c3a5 (diff)
downloadautomake-13ae585a0184a4c0113fd4f3a19a0cedf1cfe5c2.tar.gz
tests: fix yacc C++ tests with some C++ compilers
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.
Diffstat (limited to 't/yacc-mix-c-cxx.sh')
-rw-r--r--t/yacc-mix-c-cxx.sh4
1 files changed, 4 insertions, 0 deletions
diff --git a/t/yacc-mix-c-cxx.sh b/t/yacc-mix-c-cxx.sh
index eb02d4cd5..475a8e9f5 100644
--- a/t/yacc-mix-c-cxx.sh
+++ b/t/yacc-mix-c-cxx.sh
@@ -82,6 +82,10 @@ END
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; }