Subject: bug#68832: Testing: POSIX yacc and C++ linkage

From: Karl Berry <[email-masked]>
Date: Wed, 31 Jan 2024 15:47:09 -0700

parse1.yy:30:7: error: conflicting declaration of 'void yyerror(const char*)' with 'C' linkage
    parse1.yy:7:6: note: previous declaration with 'C++' linkage

Thanks much for the careful and complete report.

I think this is another manifestation of what Bogdan fixed in other
cases in https://debbugs.gnu.org/cgi/bugreport.cgi?bug=62886. His idea
there was to essentially add an extern "C" only on Solaris, via
sufficient #ifdef's.

In these new cases, I guess braces would be required, so the test code
would end up looking like:

#if (defined __cplusplus) && ((!defined __sun) || (defined __EXTERN_C__))
extern "C" {
#endif
int yylex (void) { return std::getchar (); }
void yyerror (const char *s) {}
#if (defined __cplusplus) && ((!defined __sun) || (defined __EXTERN_C__))
}
#endif

Although I could try to do this, I can't easily test the result, and I'd
probably mess up the editing. I'm also far from sure that this will
actually solve the problem without introducing new ones.

So maybe you could edit one of the test *.sh files and rerun the test
and see what happens? In case you don't know, you can run a single test
with, e.g.,
  make check TESTS='t/yacc-cxx.sh' keep_testdirs=yes
(the keep_testdirs keeps the <testdir>.dir/ around so it can be
inspected afterward.)

    My proposal to solve the issue is to change affected tests to
    require bison instead of yacc.  

A lot of work has gone into making the tests work with Solaris tools
(despite the current failures), so I'm reluctant to throw that
possibility away.

Also, there have been similar bug reports with older versions of bison.
There is no panacea :( ...  --thanks, karl.