From a96917db0534c9725d6f91b7fd5fde0abcf26ef1 Mon Sep 17 00:00:00 2001 From: Bogdan Drozdowski <> Date: Tue, 6 Feb 2024 21:55:23 +0100 Subject: [PATCH] Fix yacc tests on OpenIndiana --- t/yacc-clean-cxx.sh | 8 ++++++++ t/yacc-cxx.sh | 7 +++++++ t/yacc-d-cxx.sh | 6 ++++++ t/yacc-mix-c-cxx.sh | 12 ++++++++++++ 4 files changed, 33 insertions(+) diff --git a/t/yacc-clean-cxx.sh b/t/yacc-clean-cxx.sh index facd6dbc4..6af2047c0 100644 --- a/t/yacc-clean-cxx.sh +++ b/t/yacc-clean-cxx.sh @@ -70,9 +70,17 @@ cat > sub1/parsefoo.yxx << 'END' %{ // This file should contain valid C++ but invalid C. #include +#if (defined __cplusplus) && ((!defined __sun) || (defined __EXTERN_C__)) +extern "C" { +#endif + // "std::" qualification required by Sun C++ 5.9. int yylex (void) { return std::getchar (); } void yyerror (const char *s) {} +#if (defined __cplusplus) && ((!defined __sun) || (defined __EXTERN_C__)) +} +#endif + %} %% x : 'x' { }; diff --git a/t/yacc-cxx.sh b/t/yacc-cxx.sh index f6b477c0d..3f891dac5 100644 --- a/t/yacc-cxx.sh +++ b/t/yacc-cxx.sh @@ -54,9 +54,16 @@ cat > parse1.yy << 'END' using std::exit; using std::free; using std::malloc; +#if (defined __cplusplus) && ((!defined __sun) || (defined __EXTERN_C__)) +extern "C" { +#endif // "std::" qualification required by Sun C++ 5.9. int yylex (void) { return std::getchar (); } void yyerror (const char *s) {} +#if (defined __cplusplus) && ((!defined __sun) || (defined __EXTERN_C__)) +} +#endif + %} %% a : 'a' { exit(0); }; diff --git a/t/yacc-d-cxx.sh b/t/yacc-d-cxx.sh index 255e00a71..556977c22 100644 --- a/t/yacc-d-cxx.sh +++ b/t/yacc-d-cxx.sh @@ -35,8 +35,14 @@ write_parse () using std::free; using std::malloc; #include "$header" + #if (defined __cplusplus) && ((!defined __sun) || (defined __EXTERN_C__)) + extern "C" { + #endif int yylex (void) { return 0; } void yyerror (const char *s) {} + #if (defined __cplusplus) && ((!defined __sun) || (defined __EXTERN_C__)) + } + #endif %} %% x : 'x' {}; diff --git a/t/yacc-mix-c-cxx.sh b/t/yacc-mix-c-cxx.sh index 0e7e2e104..d454fe244 100644 --- a/t/yacc-mix-c-cxx.sh +++ b/t/yacc-mix-c-cxx.sh @@ -54,8 +54,14 @@ END cat > p.y <<'END' %{ +#if (defined __cplusplus) && ((!defined __sun) || (defined __EXTERN_C__)) +extern "C" { +#endif int yylex (void) { int new = 0; return new; } void yyerror (const char *s) {} +#if (defined __cplusplus) && ((!defined __sun) || (defined __EXTERN_C__)) +} +#endif %} %token ZARDOZ %% @@ -93,8 +99,14 @@ using std::exit; using std::free; using std::malloc; #include "parse.hh" +#if (defined __cplusplus) && ((!defined __sun) || (defined __EXTERN_C__)) +extern "C" { +#endif int yylex (void) { return 0; } void yyerror (const char *s) {} +#if (defined __cplusplus) && ((!defined __sun) || (defined __EXTERN_C__)) +} +#endif %} %token FOOBAR %% -- 2.35.1