From da9abf4366d824a23da3d2416856e9a482794eb1 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 2 Oct 2000 10:29:00 +0000 Subject: [PATCH 1/1] * bison.s1 (yyparse): Assign the default value unconditionally, to avoid a GCC warning and make the parser a tad smaller. --- ChangeLog | 6 ++++++ src/bison.s1 | 14 ++++++++++---- src/bison.simple | 14 ++++++++++---- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 460b2479..2b91be7b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2000-10-02 Paul Eggert + + * bison.s1 (yyparse): Assign the default value + unconditionally, to avoid a GCC warning and make the parser a + tad smaller. + 2000-10-02 Akim Demaille * src/getargs.c (getargs): Don't dump `--help' on unrecognized diff --git a/src/bison.s1 b/src/bison.s1 index bc656245..aee33e27 100644 --- a/src/bison.s1 +++ b/src/bison.s1 @@ -558,10 +558,16 @@ yydefault: yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; - /* Implement default value of the action: - `{dollar}{dollar} = {dollar}1'. */ - if (yylen > 0) - yyval = yyvsp[1-yylen]; + + /* If YYLEN is nonzero, implement the default value of the action: + `{dollar}{dollar} = {dollar}1'. + + Otherwise, the following line sets YYVAL to the semantic value of + the lookahead token. This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; #ifdef YYLSP_NEEDED /* Implement default location. If the rhs is empty, extend YYLOC to YYLLOC, which corresponds to the current token, otherwise diff --git a/src/bison.simple b/src/bison.simple index bc656245..aee33e27 100644 --- a/src/bison.simple +++ b/src/bison.simple @@ -558,10 +558,16 @@ yydefault: yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; - /* Implement default value of the action: - `{dollar}{dollar} = {dollar}1'. */ - if (yylen > 0) - yyval = yyvsp[1-yylen]; + + /* If YYLEN is nonzero, implement the default value of the action: + `{dollar}{dollar} = {dollar}1'. + + Otherwise, the following line sets YYVAL to the semantic value of + the lookahead token. This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; #ifdef YYLSP_NEEDED /* Implement default location. If the rhs is empty, extend YYLOC to YYLLOC, which corresponds to the current token, otherwise -- 2.45.2