From b8813c99e220073b528511f47cc0c4cfd8ef1c20 Mon Sep 17 00:00:00 2001 From: Bogdan Drozdowski <> Date: Sun, 16 Apr 2023 17:39:26 +0200 Subject: [PATCH] Fix lex/yacc C++ tests on SunOS --- t/lex-clean-cxx.sh | 10 ++++++++-- t/lex-depend-cxx.sh | 5 ++++- t/yacc-cxx.sh | 3 +++ t/yacc-d-cxx.sh | 3 +++ t/yacc-mix-c-cxx.sh | 3 +++ 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/t/lex-clean-cxx.sh b/t/lex-clean-cxx.sh index 3632d5c87..afbacf392 100644 --- a/t/lex-clean-cxx.sh +++ b/t/lex-clean-cxx.sh @@ -54,7 +54,10 @@ END 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 +74,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) { diff --git a/t/lex-depend-cxx.sh b/t/lex-depend-cxx.sh index 60615a54e..817450fc0 100644 --- a/t/lex-depend-cxx.sh +++ b/t/lex-depend-cxx.sh @@ -47,7 +47,10 @@ END 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; } %} diff --git a/t/yacc-cxx.sh b/t/yacc-cxx.sh index 1bf75a975..5b385870c 100644 --- a/t/yacc-cxx.sh +++ b/t/yacc-cxx.sh @@ -49,6 +49,9 @@ cat > parse1.yy << 'END' // Valid C++, but deliberately invalid C. #include #include +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) {} diff --git a/t/yacc-d-cxx.sh b/t/yacc-d-cxx.sh index 56f43c940..576e8e2aa 100644 --- a/t/yacc-d-cxx.sh +++ b/t/yacc-d-cxx.sh @@ -31,6 +31,9 @@ write_parse () #include // Valid C++, but deliberately invalid C. #include + using std::exit; + using std::free; + using std::malloc; #include "$header" int yylex (void) { return 0; } void yyerror (const char *s) {} diff --git a/t/yacc-mix-c-cxx.sh b/t/yacc-mix-c-cxx.sh index a73935c39..7c44e0926 100644 --- a/t/yacc-mix-c-cxx.sh +++ b/t/yacc-mix-c-cxx.sh @@ -86,6 +86,9 @@ cat > parse.yy <<'END' // https://bugs.gnu.org/20031 #include // Valid C++, but deliberately invalid C. +using std::exit; +using std::free; +using std::malloc; #include #include "parse.hh" int yylex (void) { return 0; } -- 2.35.1