mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-08-08 10:15:14 +00:00
bison: allow trivially copyable C++ YYLTYPE
Problem reported by James K. Lowden in: https://lists.gnu.org/r/bison-patches/2026-07/msg00000.html * data/skeletons/yacc.c: In C++, check that YYLTYPE is trivially copyable if this is not already known. But skip the check in older compilers.
This commit is contained in:
@@ -8,6 +8,9 @@ GNU Bison NEWS
|
|||||||
|
|
||||||
The C++ skeletons now expose copy and move operators for symbols.
|
The C++ skeletons now expose copy and move operators for symbols.
|
||||||
|
|
||||||
|
The default (C) skeleton now supports user-defined semantic and location
|
||||||
|
types that are trivially copyable in C++.
|
||||||
|
|
||||||
Fixed portability issues of the test suite on Solaris.
|
Fixed portability issues of the test suite on Solaris.
|
||||||
|
|
||||||
Fixed spurious warnings about input containing `m4_` or `b4_`.
|
Fixed spurious warnings about input containing `m4_` or `b4_`.
|
||||||
|
|||||||
+21
-4
@@ -581,10 +581,27 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
|
|||||||
# define YYCOPY_NEEDED 1]])[
|
# define YYCOPY_NEEDED 1]])[
|
||||||
#endif /* ]b4_lac_if([[1]], [b4_parse_error_case([simple], [[!defined yyoverflow]], [[1]])])[ */
|
#endif /* ]b4_lac_if([[1]], [b4_parse_error_case([simple], [[!defined yyoverflow]], [[1]])])[ */
|
||||||
|
|
||||||
#if (! defined yyoverflow \
|
#ifndef yyoverflow
|
||||||
&& (! defined __cplusplus \
|
/* In C++, ]b4_api_PREFIX[STYPE must be trivially copyable.
|
||||||
|| (]b4_locations_if([[defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL \
|
If ]b4_api_PREFIX[STYPE_IS_TRIVIAL, this is already known.
|
||||||
&& ]])[defined ]b4_api_PREFIX[STYPE_IS_TRIVIAL && ]b4_api_PREFIX[STYPE_IS_TRIVIAL)))
|
Otherwise check this if easy, as in newer C++ compilers.]b4_locations_if([[
|
||||||
|
Likewise for ]b4_api_PREFIX[LTYPE.]])[ */
|
||||||
|
# if (! (]b4_locations_if([[defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL \
|
||||||
|
&& ]])[defined ]b4_api_PREFIX[STYPE_IS_TRIVIAL && ]b4_api_PREFIX[STYPE_IS_TRIVIAL) \
|
||||||
|
&& defined __cplusplus && 201103 <= __cplusplus \
|
||||||
|
&& !(defined _GLIBCXX_RELEASE \
|
||||||
|
? _GLIBCXX_RELEASE < 5 \
|
||||||
|
: defined __GLIBCXX__) \
|
||||||
|
&& defined __has_include)
|
||||||
|
# if __has_include (<type_traits>)
|
||||||
|
# include <type_traits>
|
||||||
|
]b4_locations_if(
|
||||||
|
[[static_assert (std::is_trivially_copyable<]b4_api_PREFIX[LTYPE>::value,
|
||||||
|
"Bison error: api.location.type is not trivially copyable");
|
||||||
|
]])[static_assert (std::is_trivially_copyable<]b4_api_PREFIX[STYPE>::value,
|
||||||
|
"Bison error: api.value.type is not trivially copyable");
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
/* A type that is properly aligned for any stack member. */
|
/* A type that is properly aligned for any stack member. */
|
||||||
union yyalloc
|
union yyalloc
|
||||||
|
|||||||
Reference in New Issue
Block a user