c++: issue a compile-time warning when #define YYSTYPE is used
commit9acc9d2aeeee21be4572a0eaac6146867f264243
authorAkim Demaille <akim.demaille@gmail.com>
Sun, 31 Jan 2021 15:05:13 +0000 (31 16:05 +0100)
committerAkim Demaille <akim.demaille@gmail.com>
Mon, 1 Feb 2021 04:54:06 +0000 (1 05:54 +0100)
tree833812ec39398a25a1510d902c452bfc71e15d3d
parentdc8fe0678a6f32a1d755bb163efcac42976220d9
c++: issue a compile-time warning when #define YYSTYPE is used

Using #define YYSTYPE has always been strongly discouraged in C++.
Macros are dangerous and can result in subtle bugs.
https://lists.gnu.org/r/bug-bison/2020-12/msg00007.html

Maybe some people are currently using #define YYSTYPE.  Instead of
dropping support right now, first issue a warning.  Bison can "see" if
YYDEBUG is defined (it could even be on the command line), only the
compiler knows.  Unfortunately `#warning` is non-portable, and
actually GCC even dies on it when `-pedantic` is enabled.  So we need
to use `#pragma message`.  We must make it conditional as some
compilers might not support it, but it doesn't matter if only _some_
compilers emit the warning: it should be enough to catch the attention
of the developers.

* data/skeletons/c++.m4: Issue a warning when the user defined
YYSTYPE.
* tests/actions.at: Don't #define YYSTYPE.
* tests/headers.at (Several parsers): Ignore the YYSTYPE in the
warning.
data/skeletons/c++.m4
tests/actions.at
tests/headers.at