X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/4323e0dac386d777d070c68564f1c0041b06935d..62cb570a8dc4895110c087dbfa5810cd0bc316a8:/data/yacc.c diff --git a/data/yacc.c b/data/yacc.c index 7376f900..9ff20322 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -85,7 +85,7 @@ m4_define([b4_yacc_pure_if], # Arguments passed to yyerror: user args plus yylloc. m4_define([b4_yyerror_args], [b4_yacc_pure_if([b4_locations_if([&yylloc, ])])dnl -m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])]) +m4_ifset([b4_parse_param], [b4_args(b4_parse_param), ])]) # b4_lex_param @@ -172,6 +172,28 @@ m4_define([b4_declare_scanner_communication_variables], [[ /* The lookahead symbol. */ int yychar; +]b4_pure_if([[ +#if defined __GNUC__ && (4 < __GNUC__ + (6 <= __GNUC_MINOR__)) +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") +#else +/* Default value used for initialization, for pacifying older GCCs + or non-GCC compilers. */ +static YYSTYPE yyval_default; +# define YYLVAL_INITIALIZE() (yylval = yyval_default) +#endif]])[ +#ifndef YYLVAL_INITIALIZE +# define YYLVAL_INITIALIZE() +#endif +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#endif + /* The semantic value of the lookahead symbol. */ YYSTYPE yylval;]b4_locations_if([[ @@ -239,19 +261,19 @@ enum { YYPUSH_MORE = 4 }; typedef struct ]b4_prefix[pstate ]b4_prefix[pstate; -]b4_pull_if([b4_c_function_decl([b4_prefix[parse]], [[int]], b4_parse_param) -])b4_c_function_decl([b4_prefix[push_parse]], [[int]], +]b4_pull_if([b4_function_declare([b4_prefix[parse]], [[int]], b4_parse_param) +])b4_function_declare([b4_prefix[push_parse]], [[int]], [[b4_prefix[pstate *ps]], [[ps]]]b4_pure_if([, [[[int pushed_char]], [[pushed_char]]], [[b4_api_PREFIX[STYPE const *pushed_val]], [[pushed_val]]]b4_locations_if([, [[b4_api_PREFIX[LTYPE const *pushed_loc]], [[pushed_loc]]]])])m4_ifset([b4_parse_param], [, b4_parse_param])) -b4_pull_if([b4_c_function_decl([b4_prefix[pull_parse]], [[int]], +b4_pull_if([b4_function_declare([b4_prefix[pull_parse]], [[int]], [[b4_prefix[pstate *ps]], [[ps]]]m4_ifset([b4_parse_param], [, b4_parse_param]))]) -b4_c_function_decl([b4_prefix[pstate_new]], [b4_prefix[pstate *]], +b4_function_declare([b4_prefix[pstate_new]], [b4_prefix[pstate *]], [[[void]], []]) -b4_c_function_decl([b4_prefix[pstate_delete]], [[void]], +b4_function_declare([b4_prefix[pstate_delete]], [[void]], [[b4_prefix[pstate *ps]], [[ps]]])dnl ]) @@ -259,13 +281,7 @@ b4_c_function_decl([b4_prefix[pstate_delete]], [[void]], # ------------------- # When not the push parser. m4_define([b4_declare_yyparse_], -[[#ifdef YYPARSE_PARAM -]b4_c_function_decl(b4_prefix[parse], [int], - [[void *YYPARSE_PARAM], [YYPARSE_PARAM]])[ -#else /* ! YYPARSE_PARAM */ -]b4_c_function_decl(b4_prefix[parse], [int], b4_parse_param)[ -#endif /* ! YYPARSE_PARAM */]dnl -]) +[b4_function_declare(b4_prefix[parse], [int], b4_parse_param)]) # b4_declare_yyparse @@ -346,9 +362,11 @@ m4_if(b4_api_prefix, [yy], [], # define YYERROR_VERBOSE ]b4_error_verbose_if([1], [0])[ #endif -/* In a future release of Bison, this section will be replaced +]m4_ifval(m4_quote(b4_spec_defines_file), +[[/* In a future release of Bison, this section will be replaced by #include "@basename(]b4_spec_defines_file[@)". */ -]b4_shared_declarations[ +]])dnl +b4_shared_declarations[ /* Copy the second part of user declarations. */ ]b4_user_post_prologue @@ -366,10 +384,8 @@ typedef unsigned char yytype_uint8; #ifdef YYTYPE_INT8 typedef YYTYPE_INT8 yytype_int8; -#elif ]b4_c_modern[ -typedef signed char yytype_int8; #else -typedef short int yytype_int8; +typedef signed char yytype_int8; #endif #ifdef YYTYPE_UINT16 @@ -389,7 +405,7 @@ typedef short int yytype_int16; # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t -# elif ! defined YYSIZE_T && ]b4_c_modern[ +# elif ! defined YYSIZE_T # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else @@ -403,29 +419,19 @@ typedef short int yytype_int16; # if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ -# define YY_(msgid) dgettext ("bison-runtime", msgid) +# define YY_(Msgid) dgettext ("bison-runtime", Msgid) # endif # endif # ifndef YY_ -# define YY_(msgid) msgid +# define YY_(Msgid) Msgid # endif #endif /* Suppress unused-variable warnings by "using" E. */ -#if ! defined lint || defined __GNUC__ -# define YYUSE(e) ((void) (e)) +#ifdef __GNUC__ +# define YYUSE(E) ((void) (E)) #else -# define YYUSE(e) /* empty */ -#endif - -/* Identity function, used to suppress warnings about constant conditions. */ -#ifndef lint -# define YYID(n) (n) -#else -]b4_c_function_def([YYID], [static int], [[int yyi], [yyi]])[ -{ - return yyi; -} +# define YYUSE(E) /* empty */ #endif #if ]b4_lac_if([[1]], [[! defined yyoverflow || YYERROR_VERBOSE]])[ @@ -446,7 +452,7 @@ b4_push_if([], [b4_lac_if([], [[ # define alloca _alloca # else # define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && ]b4_c_modern[ +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS # include /* INFRINGES ON USER NAME SPACE */ /* Use EXIT_SUCCESS as a witness for stdlib.h. */ # ifndef EXIT_SUCCESS @@ -459,7 +465,7 @@ b4_push_if([], [b4_lac_if([], [[ # ifdef YYSTACK_ALLOC /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely @@ -483,13 +489,13 @@ b4_push_if([], [b4_lac_if([], [[ # endif # ifndef YYMALLOC # define YYMALLOC malloc -# if ! defined malloc && ! defined EXIT_SUCCESS && ]b4_c_modern[ +# if ! defined malloc && ! defined EXIT_SUCCESS void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free -# if ! defined free && ! defined EXIT_SUCCESS && ]b4_c_modern[ +# if ! defined free && ! defined EXIT_SUCCESS void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif @@ -540,7 +546,7 @@ union yyalloc yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ - while (YYID (0)) + while (0) #endif @@ -559,7 +565,7 @@ union yyalloc for (yyi = 0; yyi < (Count); yyi++) \ (Dst)[yyi] = (Src)[yyi]; \ } \ - while (YYID (0)) + while (0) # endif # endif #endif /* !YYCOPY_NEEDED */ @@ -618,13 +624,13 @@ static const ]b4_int_type_for([b4_toknum])[ yytoknum[] = #define YYPACT_NINF ]b4_pact_ninf[ -#define yypact_value_is_default(yystate) \ - ]b4_table_value_equals([[pact]], [[yystate]], [b4_pact_ninf])[ +#define yypact_value_is_default(Yystate) \ + ]b4_table_value_equals([[pact]], [[Yystate]], [b4_pact_ninf])[ #define YYTABLE_NINF ]b4_table_ninf[ -#define yytable_value_is_error(yytable_value) \ - ]b4_table_value_equals([[table]], [[yytable_value]], [b4_table_ninf])[ +#define yytable_value_is_error(Yytable_value) \ + ]b4_table_value_equals([[table]], [[Yytable_value]], [b4_table_ninf])[ ]b4_parser_tables_define[ @@ -656,7 +662,7 @@ do \ yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")); \ YYERROR; \ } \ -while (YYID (0)) +while (0) #define YYTERROR 1 @@ -679,22 +685,18 @@ while (YYID (0)) # else # define YY_LOCATION_PRINT(File, Loc) ((void) 0) # endif -#endif]], [[ - - -/* This macro is provided for backward compatibility. */ - +#endif]], +[[/* This macro is provided for backward compatibility. */ #ifndef YY_LOCATION_PRINT # define YY_LOCATION_PRINT(File, Loc) ((void) 0) #endif]])[ /* YYLEX -- calling `yylex' with the right arguments. */ - #ifdef YYLEX_PARAM # define YYLEX yylex (]b4_pure_if([&yylval[]b4_locations_if([, &yylloc]), ])[YYLEX_PARAM) #else -# define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[ +# define YYLEX ]b4_function_call([yylex], [int], b4_lex_param)[ #endif /* Enable debugging if requested. */ @@ -709,7 +711,7 @@ while (YYID (0)) do { \ if (yydebug) \ YYFPRINTF Args; \ -} while (YYID (0)) +} while (0) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ do { \ @@ -720,16 +722,16 @@ do { \ Type, Value]b4_locations_if([, Location])[]b4_user_args[); \ YYFPRINTF (stderr, "\n"); \ } \ -} while (YYID (0)) +} while (0) -]b4_yy_symbol_print_generate([b4_c_function_def])[ +]b4_yy_symbol_print_define[ /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | | TOP (included). | `------------------------------------------------------------------*/ -]b4_c_function_def([yy_stack_print], [static void], +]b4_function_define([yy_stack_print], [static void], [[yytype_int16 *yybottom], [yybottom]], [[yytype_int16 *yytop], [yytop]])[ { @@ -746,14 +748,14 @@ do { \ do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ -} while (YYID (0)) +} while (0) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ -]b4_c_function_def([yy_reduce_print], [static void], +]b4_function_define([yy_reduce_print], [static void], [[yytype_int16 *yyssp], [yyssp]], [[YYSTYPE *yyvsp], [yyvsp]], b4_locations_if([[[YYLTYPE *yylsp], [yylsp]], @@ -782,7 +784,7 @@ do { \ do { \ if (yydebug) \ yy_reduce_print (yyssp, yyvsp, ]b4_locations_if([yylsp, ])[Rule]b4_user_args[); \ -} while (YYID (0)) +} while (0) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ @@ -916,7 +918,7 @@ do { \ goto yyerrlab; \ } \ } \ -} while (YYID (0)) +} while (0) /* Discard any previous initial lookahead context because of Event, which may be a lookahead change or an invalidation of the currently @@ -939,7 +941,7 @@ do { \ Event "\n"); \ yy_lac_established = 0; \ } \ -} while (YYID (0)) +} while (0) #else # define YY_LAC_DISCARD(Event) yy_lac_established = 0 #endif @@ -1055,7 +1057,7 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes, # define yystrlen strlen # else /* Return the length of YYSTR. */ -]b4_c_function_def([yystrlen], [static YYSIZE_T], +]b4_function_define([yystrlen], [static YYSIZE_T], [[const char *yystr], [yystr]])[ { YYSIZE_T yylen; @@ -1072,7 +1074,7 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes, # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ -]b4_c_function_def([yystpcpy], [static char *], +]b4_function_define([yystpcpy], [static char *], [[char *yydest], [yydest]], [[const char *yysrc], [yysrc]])[ { char *yyd = yydest; @@ -1292,7 +1294,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, } #endif /* YYERROR_VERBOSE */ -]b4_yydestruct_generate([b4_c_function_def])[ +]b4_yydestruct_define[ ]b4_pure_if([], [ @@ -1307,13 +1309,13 @@ struct yypstate static char yypstate_allocated = 0;]])b4_pull_if([ -b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[ +b4_function_define([[yyparse]], [[int]], b4_parse_param)[ { return yypull_parse (YY_NULL]m4_ifset([b4_parse_param], - [[, ]b4_c_args(b4_parse_param)])[); + [[, ]b4_args(b4_parse_param)])[); } -]b4_c_function_def([[yypull_parse]], [[int]], +]b4_function_define([[yypull_parse]], [[int]], [[[yypstate *yyps]], [[yyps]]]m4_ifset([b4_parse_param], [, b4_parse_param]))[ { @@ -1338,7 +1340,7 @@ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[ do { yychar = YYLEX; yystatus = - yypush_parse (yyps_local]b4_pure_if([[, yychar, &yylval]b4_locations_if([[, &yylloc]])])m4_ifset([b4_parse_param], [, b4_c_args(b4_parse_param)])[); + yypush_parse (yyps_local]b4_pure_if([[, yychar, &yylval]b4_locations_if([[, &yylloc]])])m4_ifset([b4_parse_param], [, b4_args(b4_parse_param)])[); } while (yystatus == YYPUSH_MORE); if (!yyps) yypstate_delete (yyps_local); @@ -1346,7 +1348,7 @@ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[ }]])[ /* Initialize the parser data structure. */ -]b4_c_function_def([[yypstate_new]], [[yypstate *]])[ +]b4_function_define([[yypstate_new]], [[yypstate *]])[ { yypstate *yyps;]b4_pure_if([], [[ if (yypstate_allocated) @@ -1359,7 +1361,7 @@ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[ return yyps; } -]b4_c_function_def([[yypstate_delete]], [[void]], +]b4_function_define([[yypstate_delete]], [[void]], [[[yypstate *yyps]], [[yyps]]])[ { #ifndef yyoverflow @@ -1397,7 +1399,7 @@ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[ | yypush_parse. | `---------------*/ -]b4_c_function_def([[yypush_parse]], [[int]], +]b4_function_define([[yypush_parse]], [[int]], [[[yypstate *yyps]], [[yyps]]]b4_pure_if([, [[[int yypushed_char]], [[yypushed_char]]], [[[YYSTYPE const *yypushed_val]], [[yypushed_val]]]b4_locations_if([, @@ -1409,12 +1411,7 @@ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[ | yyparse. | `----------*/ -#ifdef YYPARSE_PARAM -]b4_c_function_def([yyparse], [int], - [[void *YYPARSE_PARAM], [YYPARSE_PARAM]])[ -#else /* ! YYPARSE_PARAM */ -]b4_c_function_def([yyparse], [int], b4_parse_param)[ -#endif]])[ +]b4_function_define([yyparse], [int], b4_parse_param)])[ {]b4_pure_if([b4_declare_scanner_communication_variables ])b4_push_if([b4_pure_if([], [[ int yypushed_char = yychar; @@ -1427,7 +1424,7 @@ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[ int yyn; int yyresult; /* Lookahead token as an internal (translated) token number. */ - int yytoken; + int yytoken = 0; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval;]b4_locations_if([[ @@ -1452,7 +1449,6 @@ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[ goto yyread_pushed_token; }]])[ - yytoken = 0; yyss = yyssa; yyvs = yyvsa;]b4_locations_if([[ yyls = yylsa;]])[ @@ -1476,8 +1472,9 @@ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[ The wasted elements are never initialized. */ yyssp = yyss; yyvsp = yyvs;]b4_locations_if([[ - yylsp = yyls; + yylsp = yyls;]])[ + YYLVAL_INITIALIZE ();]b4_locations_if([[ #if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL /* Initialize the default location before parsing starts. */ yylloc.first_line = yylloc.last_line = ]b4_location_initial_line[; @@ -1663,7 +1660,9 @@ yyread_pushed_token:]])[ YY_LAC_DISCARD ("shift");]])[ yystate = yyn; + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END ]b4_locations_if([ *++yylsp = yylloc;])[ goto yynewstate; @@ -1883,7 +1882,9 @@ yyerrlab1: current lookahead token, the shift below will for sure. */ YY_LAC_DISCARD ("error recovery");]])[ + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END ]b4_locations_if([[ yyerror_range[2] = yylloc; /* Using YYLLOC is tempting, but would change the location of @@ -1954,10 +1955,8 @@ yypushreturn:]])[ if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif - /* Make sure YYID is used. */ - return YYID (yyresult); + return yyresult; } - ]b4_epilogue[]dnl b4_defines_if( [@output(b4_spec_defines_file@)@