From: Bogdan Date: Wed, 7 Feb 2024 22:56:25 +0000 (-0800) Subject: test: protect more yacc declarations against C vs. C++ linkage. X-Git-Tag: v1.16.90~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=efb9f7b298cc45e0663874b34379f618b092f2fd;p=thirdparty%2Fautomake.git test: protect more yacc declarations against C vs. C++ linkage. Fix for more of https://bugs.gnu.org/68832. * t/yacc-clean-cxx.sh: more #ifdef of yylex, etc., following https://debbugs.gnu.org/cgi/bugreport.cgi?bug=62886, now for OpenIndiana. Specifically: #if (defined __cplusplus) && ((!defined __sun) || (defined __EXTERN_C__)) * t/yacc-cxx.sh: likewise. * t/yacc-d-cxx.sh: likewise. * t/yacc-mix-c-cxx.sh: likewise. --- 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 %%