]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
tests: avoid some SunOS declaration conflicts.
authorBogdan <bogdro_rep@gmx.us>
Sun, 9 Jul 2023 16:57:15 +0000 (09:57 -0700)
committerKarl Berry <karl@freefriends.org>
Sun, 9 Jul 2023 16:57:15 +0000 (09:57 -0700)
This change: finishes fixing https://bugs.gnu.org/34151
  and https://bugs.gnu.org/30612 and https://bugs.gnu.org/42393;
fixes https://bugs.gnu.org/44795 and https://bugs.gnu.org/49755;
partially fixes https://bugs.gnu.org/45205
  and https://bugs.gnu.org/55073.
Still open: https://bugs.gnu.org/15256;

* t/lex-clean-cxx.sh: test __cplusplus, __sun, and __EXTERN_C__
before using extern "C" for the yylex decl, as explained at
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=45205#13.
* t/lex-depend-cxx.sh: likewise.

* t/yacc-cxx.sh: "using" std::exit, std::free, std::malloc.
* t/yacc-d-cxx.sh: likewise.
* t/yacc-mix-c-cxx.sh: likewise.

* NEWS: mention this.

NEWS
t/lex-clean-cxx.sh
t/lex-depend-cxx.sh
t/yacc-cxx.sh
t/yacc-d-cxx.sh
t/yacc-mix-c-cxx.sh

diff --git a/NEWS b/NEWS
index 61d631ba0706cb907319d6bf129074d312594e9a..23b2cc50a6370a21d3e9476e2bfdac6078090bbc 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -46,6 +46,8 @@ New in 1.17:
   - distcleancheck ignores "silly rename" files (.nfs* .smb* .__afs*)
     that can show up on network file systems.
 
+  - tests: avoid some declaration conflicts for lex et al. on SunOS.
+
 * Obsolescent features:
 
   - py-compile no longer supports Python 0.x or 1.x versions.  Python 2.0,
index 3632d5c873f91dc5eb06b18669605386c1ac341c..8a086304f9a2c8ac23a4aa7fefb0f6d9b76966cc 100644 (file)
@@ -51,10 +51,15 @@ CLEANFILES = parsebaz.l++ parsequx.lpp
 LDADD = $(LEXLIB)
 END
 
+# For the explanation of the conditionals on using extern "C",
+# see https://debbugs.gnu.org/cgi/bugreport.cgi?bug=45205#13.
 cat > parsefoo.lxx << 'END'
 %{
 #define YY_DECL int yylex (void)
-extern "C" YY_DECL;
+#if (defined __cplusplus) && ((!defined __sun) || (defined __EXTERN_C__))
+extern "C"
+#endif
+YY_DECL;
 #define YY_NO_UNISTD_H 1
 int isatty (int fd) { return 0; }
 %}
@@ -71,7 +76,10 @@ cp parsefoo.lxx parsebar.ll
 
 cat > mainfoo.cc << 'END'
 // This file should contain valid C++ but invalid C.
-extern "C" int yylex (void);
+#if (defined __cplusplus) && ((!defined __sun) || (defined __EXTERN_C__))
+extern "C"
+#endif
+int yylex (void);
 using namespace std;
 int main (int argc, char **argv)
 {
index 60615a54ee514bd5cbf69734071f8abe3631bddb..682b2ccc5de5c222f8783e059b1f8a77888e3e0b 100644 (file)
@@ -44,10 +44,15 @@ test-obj-updated: joe.$(OBJEXT) moe.$(OBJEXT)
        is_newest moe.$(OBJEXT) my-hdr.hxx
 END
 
+# For the explanation of the conditionals on using extern "C",
+# see https://debbugs.gnu.org/cgi/bugreport.cgi?bug=45205#13.
 cat > joe.ll << 'END'
 %{
 #define YY_DECL int yylex (void)
-extern "C" YY_DECL;
+#if (defined __cplusplus) && ((!defined __sun) || (defined __EXTERN_C__))
+extern "C"
+#endif
+YY_DECL;
 #define YY_NO_UNISTD_H 1
 int isatty (int fd) { return 0; }
 %}
index 1bf75a9753b6b90f3473fa32b33bf995628201a7..5b385870c3c25e1aed508cf328ded38f3af289e3 100644 (file)
@@ -49,6 +49,9 @@ cat > parse1.yy << 'END'
 // Valid C++, but deliberately invalid C.
 #include <cstdio>
 #include <cstdlib>
+using std::exit;
+using std::free;
+using std::malloc;
 // "std::" qualification required by Sun C++ 5.9.
 int yylex (void) { return std::getchar (); }
 void yyerror (const char *s) {}
index 56f43c940660393001ab9a0b236a31cde8a0878b..576e8e2aa162c5764ff51a8cc0e817b65b398cb9 100644 (file)
@@ -31,6 +31,9 @@ write_parse ()
     #include <stdlib.h>
     // Valid C++, but deliberately invalid C.
     #include <cstdlib>
+    using std::exit;
+    using std::free;
+    using std::malloc;
     #include "$header"
     int yylex (void) { return 0; }
     void yyerror (const char *s) {}
index a73935c3966046590d26d7061933e71442e5e0b9..7c44e092606cda03de6edb5970ea71b7edc4394d 100644 (file)
@@ -86,6 +86,9 @@ cat > parse.yy <<'END'
 // https://bugs.gnu.org/20031
 #include <stdlib.h>
 // Valid C++, but deliberately invalid C.
+using std::exit;
+using std::free;
+using std::malloc;
 #include <cstdlib>
 #include "parse.hh"
 int yylex (void) { return 0; }