mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-21 18:23:03 +00:00
skeletons: update the handling of compiler attributes
* data/c.m4 (b4_attribute_define): Instead of defining __attribute__, define YY_ATTRIBUTE conditionally. (YY_ATTRIBUTE_PURE, YY_ATTRIBUTE_UNUSED, _Noreturn): New. Use them. * data/glr.c: Use them.
This commit is contained in:
33
data/c.m4
33
data/c.m4
@@ -205,13 +205,32 @@ m4_define([b4_table_value_equals],
|
|||||||
|
|
||||||
# b4_attribute_define
|
# b4_attribute_define
|
||||||
# -------------------
|
# -------------------
|
||||||
# Provide portability for __attribute__.
|
# Provide portable compiler "attributes".
|
||||||
m4_define([b4_attribute_define],
|
m4_define([b4_attribute_define],
|
||||||
[#ifndef __attribute__
|
[#ifndef YY_ATTRIBUTE
|
||||||
/* This feature is available in gcc versions 2.5 and later. */
|
# if (defined __GNUC__ \
|
||||||
# if (! defined __GNUC__ || __GNUC__ < 2 \
|
&& (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
|
||||||
|| (__GNUC__ == 2 && __GNUC_MINOR__ < 5))
|
|| defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
|
||||||
# define __attribute__(Spec) /* empty */
|
# define YY_ATTRIBUTE(Spec) __attribute__(Spec)
|
||||||
|
# else
|
||||||
|
# define YY_ATTRIBUTE(Spec) /* empty */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef YY_ATTRIBUTE_PURE
|
||||||
|
# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef YY_ATTRIBUTE_UNUSED
|
||||||
|
# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined _Noreturn \
|
||||||
|
&& (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
|
||||||
|
# if defined _MSC_VER && 1200 <= _MSC_VER
|
||||||
|
# define _Noreturn __declspec (noreturn)
|
||||||
|
# else
|
||||||
|
# define _Noreturn YY_ATTRIBUTE ((__noreturn__))
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -783,7 +802,7 @@ m4_define([b4_yy_location_print_define],
|
|||||||
|
|
||||||
/* Print *YYLOCP on YYO. Private, do not rely on its existence. */
|
/* Print *YYLOCP on YYO. Private, do not rely on its existence. */
|
||||||
|
|
||||||
__attribute__((__unused__))
|
YY_ATTRIBUTE_UNUSED
|
||||||
]b4_function_define([yy_location_print_],
|
]b4_function_define([yy_location_print_],
|
||||||
[static unsigned],
|
[static unsigned],
|
||||||
[[FILE *yyo], [yyo]],
|
[[FILE *yyo], [yyo]],
|
||||||
|
|||||||
19
data/glr.c
19
data/glr.c
@@ -445,9 +445,9 @@ int yydebug;
|
|||||||
|
|
||||||
struct yyGLRStack;
|
struct yyGLRStack;
|
||||||
static void yypstack (struct yyGLRStack* yystackp, size_t yyk)
|
static void yypstack (struct yyGLRStack* yystackp, size_t yyk)
|
||||||
__attribute__ ((__unused__));
|
YY_ATTRIBUTE_UNUSED;
|
||||||
static void yypdumpstack (struct yyGLRStack* yystackp)
|
static void yypdumpstack (struct yyGLRStack* yystackp)
|
||||||
__attribute__ ((__unused__));
|
YY_ATTRIBUTE_UNUSED;
|
||||||
|
|
||||||
#else /* !]b4_api_PREFIX[DEBUG */
|
#else /* !]b4_api_PREFIX[DEBUG */
|
||||||
|
|
||||||
@@ -669,9 +669,7 @@ struct yyGLRStack {
|
|||||||
static void yyexpandGLRStack (yyGLRStack* yystackp);
|
static void yyexpandGLRStack (yyGLRStack* yystackp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void yyFail (yyGLRStack* yystackp]b4_pure_formals[, const char* yymsg)
|
static _Noreturn void
|
||||||
__attribute__ ((__noreturn__));
|
|
||||||
static void
|
|
||||||
yyFail (yyGLRStack* yystackp]b4_pure_formals[, const char* yymsg)
|
yyFail (yyGLRStack* yystackp]b4_pure_formals[, const char* yymsg)
|
||||||
{
|
{
|
||||||
if (yymsg != YY_NULL)
|
if (yymsg != YY_NULL)
|
||||||
@@ -679,9 +677,7 @@ yyFail (yyGLRStack* yystackp]b4_pure_formals[, const char* yymsg)
|
|||||||
YYLONGJMP (yystackp->yyexception_buffer, 1);
|
YYLONGJMP (yystackp->yyexception_buffer, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void yyMemoryExhausted (yyGLRStack* yystackp)
|
static _Noreturn void
|
||||||
__attribute__ ((__noreturn__));
|
|
||||||
static void
|
|
||||||
yyMemoryExhausted (yyGLRStack* yystackp)
|
yyMemoryExhausted (yyGLRStack* yystackp)
|
||||||
{
|
{
|
||||||
YYLONGJMP (yystackp->yyexception_buffer, 2);
|
YYLONGJMP (yystackp->yyexception_buffer, 2);
|
||||||
@@ -702,7 +698,7 @@ yytokenName (yySymbol yytoken)
|
|||||||
/** Fill in YYVSP[YYLOW1 .. YYLOW0-1] from the chain of states starting
|
/** Fill in YYVSP[YYLOW1 .. YYLOW0-1] from the chain of states starting
|
||||||
* at YYVSP[YYLOW0].yystate.yypred. Leaves YYVSP[YYLOW1].yystate.yypred
|
* at YYVSP[YYLOW0].yystate.yypred. Leaves YYVSP[YYLOW1].yystate.yypred
|
||||||
* containing the pointer to the next state in the chain. */
|
* containing the pointer to the next state in the chain. */
|
||||||
static void yyfillin (yyGLRStackItem *, int, int) __attribute__ ((__unused__));
|
static void yyfillin (yyGLRStackItem *, int, int) YY_ATTRIBUTE_UNUSED;
|
||||||
static void
|
static void
|
||||||
yyfillin (yyGLRStackItem *yyvsp, int yylow0, int yylow1)
|
yyfillin (yyGLRStackItem *yyvsp, int yylow0, int yylow1)
|
||||||
{
|
{
|
||||||
@@ -729,7 +725,7 @@ yyfillin (yyGLRStackItem *yyvsp, int yylow0, int yylow1)
|
|||||||
* YYVSP[YYLOW1 .. *YYLOW-1] as in yyfillin and set *YYLOW = YYLOW1.
|
* YYVSP[YYLOW1 .. *YYLOW-1] as in yyfillin and set *YYLOW = YYLOW1.
|
||||||
* For convenience, always return YYLOW1. */
|
* For convenience, always return YYLOW1. */
|
||||||
static inline int yyfill (yyGLRStackItem *, int *, int, yybool)
|
static inline int yyfill (yyGLRStackItem *, int *, int, yybool)
|
||||||
__attribute__ ((__unused__));
|
YY_ATTRIBUTE_UNUSED;
|
||||||
static inline int
|
static inline int
|
||||||
yyfill (yyGLRStackItem *yyvsp, int *yylow, int yylow1, yybool yynormal)
|
yyfill (yyGLRStackItem *yyvsp, int *yylow, int yylow1, yybool yynormal)
|
||||||
{
|
{
|
||||||
@@ -751,8 +747,7 @@ yyuserAction (yyRuleNum yyn, size_t yyrhslen, yyGLRStackItem* yyvsp,
|
|||||||
yyGLRStack* yystackp,
|
yyGLRStack* yystackp,
|
||||||
YYSTYPE* yyvalp]b4_locuser_formals[)
|
YYSTYPE* yyvalp]b4_locuser_formals[)
|
||||||
{
|
{
|
||||||
yybool yynormal __attribute__ ((__unused__)) =
|
yybool yynormal YY_ATTRIBUTE_UNUSED = (yystackp->yysplitPoint == YY_NULL);
|
||||||
(yystackp->yysplitPoint == YY_NULL);
|
|
||||||
int yylow;
|
int yylow;
|
||||||
]b4_parse_param_use([yyvalp], [yylocp])dnl
|
]b4_parse_param_use([yyvalp], [yylocp])dnl
|
||||||
[ YYUSE (yyrhslen);
|
[ YYUSE (yyrhslen);
|
||||||
|
|||||||
Reference in New Issue
Block a user