mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-14 14:53:03 +00:00
simplify the handling of <> and <*>'s code_props.
Currently they are treated in separated variables, contrary to other <TYPE> code_props. This duplicates code (and messages for translators) uselessly, as demonstrated by the fact that thanks to this patch, now useless <*> and <> code_props are reported like the others. * src/parse-gram.y (generic_symlist_item): Treat "<*>" and "<>" as regular type tags. * src/symlist.h, src/symlist.c (symbol_list_default_tagged_new) (symbol_list_default_tagless_new,SYMLIST_DEFAULT_TAGGED) (SYMLIST_DEFAULT_TAGLESS): Remove. * src/symtab.h, src/symtab.c (default_tagged_code_props) (default_tagless_code_props, default_tagged_code_props_set) (default_tagless_code_props_set): Remove. (symbol_code_props_get): Default to <*> or <>'s code_props. * tests/actions.at: Complete expected errors: there are new warnings. * tests/input.at: Likewise. (Useless printers or destructors): Extend.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Executing Actions. -*- Autotest -*-
|
||||
e# Executing Actions. -*- Autotest -*-
|
||||
|
||||
# Copyright (C) 2001-2012 Free Software Foundation, Inc.
|
||||
|
||||
@@ -646,7 +646,10 @@ main (void)
|
||||
}
|
||||
]])
|
||||
|
||||
AT_BISON_CHECK([-o input.c input.y])
|
||||
AT_BISON_CHECK([-o input.c input.y], [], [],
|
||||
[[input.y:27.3-5: warning: useless %destructor for type <*> [-Wother]
|
||||
input.y:27.3-5: warning: useless %printer for type <*> [-Wother]
|
||||
]])
|
||||
AT_COMPILE([input])
|
||||
AT_PARSER_CHECK([./input], 1,
|
||||
[[<> destructor for 'd' @ 4.
|
||||
@@ -758,7 +761,10 @@ main (void)
|
||||
}
|
||||
]])
|
||||
|
||||
AT_BISON_CHECK([-o input.c input.y])
|
||||
AT_BISON_CHECK([-o input.c input.y], [], [],
|
||||
[[input.y:22.3-4: warning: useless %destructor for type <> [-Wother]
|
||||
input.y:22.3-4: warning: useless %printer for type <> [-Wother]
|
||||
]])
|
||||
AT_COMPILE([input])
|
||||
AT_PARSER_CHECK([./input], 1,
|
||||
[[<*>/<field2>/e destructor.
|
||||
@@ -817,9 +823,9 @@ AT_CLEANUP
|
||||
|
||||
AT_SETUP([Default %printer and %destructor for user-defined end token])
|
||||
|
||||
# _AT_CHECK_DEFAULT_PRINTER_AND_DESTRUCTOR_FOR_END_TOKEN(TYPED)
|
||||
# -------------------------------------------------------------
|
||||
m4_define([_AT_CHECK_DEFAULT_PRINTER_AND_DESTRUCTOR_FOR_END_TOKEN],
|
||||
# AT_TEST(TYPED)
|
||||
# --------------
|
||||
m4_pushdef([AT_TEST],
|
||||
[m4_if($1, 0,
|
||||
[m4_pushdef([kind], []) m4_pushdef([not_kind], [*])],
|
||||
[m4_pushdef([kind], [*]) m4_pushdef([not_kind], [])])
|
||||
@@ -891,8 +897,17 @@ main (void)
|
||||
]])
|
||||
AT_BISON_OPTION_POPDEFS
|
||||
|
||||
AT_BISON_CHECK([-o input$1.c input$1.y])
|
||||
AT_BISON_CHECK([-o input$1.c input$1.y], [], [],
|
||||
[m4_if([$1], [0],
|
||||
[[input0.y:27.3-5: warning: useless %destructor for type <*> [-Wother]
|
||||
input0.y:27.3-5: warning: useless %printer for type <*> [-Wother]
|
||||
]],
|
||||
[[input1.y:27.3-4: warning: useless %destructor for type <> [-Wother]
|
||||
input1.y:27.3-4: warning: useless %printer for type <> [-Wother]
|
||||
]])])
|
||||
|
||||
AT_COMPILE([input$1])
|
||||
|
||||
AT_PARSER_CHECK([./input$1], 0,
|
||||
[[<]]kind[[> for 'E' @ 1.
|
||||
<]]kind[[> for 'S' @ 1.
|
||||
@@ -915,8 +930,10 @@ m4_popdef([kind])
|
||||
m4_popdef([not_kind])
|
||||
])
|
||||
|
||||
_AT_CHECK_DEFAULT_PRINTER_AND_DESTRUCTOR_FOR_END_TOKEN(0)
|
||||
_AT_CHECK_DEFAULT_PRINTER_AND_DESTRUCTOR_FOR_END_TOKEN(1)
|
||||
AT_TEST(0)
|
||||
AT_TEST(1)
|
||||
|
||||
m4_popdef([AT_TEST])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
@@ -976,7 +993,10 @@ main (void)
|
||||
]])
|
||||
AT_BISON_OPTION_POPDEFS
|
||||
|
||||
AT_BISON_CHECK([-o input.c input.y])
|
||||
AT_BISON_CHECK([-o input.c input.y], [], [],
|
||||
[[input.y:21.6-8: warning: useless %destructor for type <*> [-Wother]
|
||||
input.y:21.6-8: warning: useless %printer for type <*> [-Wother]
|
||||
]])
|
||||
AT_COMPILE([input])
|
||||
AT_PARSER_CHECK([./input], [1], [],
|
||||
[[Starting parse
|
||||
@@ -1075,7 +1095,10 @@ main (void)
|
||||
]])
|
||||
AT_BISON_OPTION_POPDEFS
|
||||
|
||||
AT_BISON_CHECK([-o input.c input.y])
|
||||
AT_BISON_CHECK([-o input.c input.y], [], [],
|
||||
[[input.y:22.3-4: warning: useless %destructor for type <> [-Wother]
|
||||
input.y:22.3-4: warning: useless %printer for type <> [-Wother]
|
||||
]])
|
||||
AT_COMPILE([input])
|
||||
|
||||
AT_CLEANUP
|
||||
@@ -1132,7 +1155,9 @@ main (void)
|
||||
AT_BISON_OPTION_POPDEFS
|
||||
|
||||
AT_BISON_CHECK([-o input.c input.y], 0,,
|
||||
[[input.y:33.3-23: warning: unset value: $$ [-Wother]
|
||||
[[input.y:24.70-72: warning: useless %destructor for type <*> [-Wother]
|
||||
input.y:24.70-72: warning: useless %printer for type <*> [-Wother]
|
||||
input.y:33.3-23: warning: unset value: $$ [-Wother]
|
||||
input.y:30.3-35.37: warning: unused value: $3 [-Wother]
|
||||
]])
|
||||
|
||||
|
||||
@@ -200,29 +200,29 @@ start: ;
|
||||
]])
|
||||
|
||||
AT_BISON_CHECK([input.y], [1], [],
|
||||
[[input.y:1.13-29: redeclaration for default tagged %destructor
|
||||
[[input.y:1.13-29: %destructor redeclaration for <*>
|
||||
input.y:1.13-29: previous declaration
|
||||
input.y:2.10-24: redeclaration for default tagged %printer
|
||||
input.y:2.10-24: %printer redeclaration for <*>
|
||||
input.y:2.10-24: previous declaration
|
||||
input.y:4.13-29: redeclaration for default tagged %destructor
|
||||
input.y:4.13-29: %destructor redeclaration for <*>
|
||||
input.y:1.13-29: previous declaration
|
||||
input.y:5.10-24: redeclaration for default tagged %printer
|
||||
input.y:5.10-24: %printer redeclaration for <*>
|
||||
input.y:2.10-24: previous declaration
|
||||
input.y:7.13-29: redeclaration for default tagless %destructor
|
||||
input.y:7.13-29: %destructor redeclaration for <>
|
||||
input.y:7.13-29: previous declaration
|
||||
input.y:8.10-24: redeclaration for default tagless %printer
|
||||
input.y:8.10-24: %printer redeclaration for <>
|
||||
input.y:8.10-24: previous declaration
|
||||
input.y:10.13-29: redeclaration for default tagless %destructor
|
||||
input.y:10.13-29: %destructor redeclaration for <>
|
||||
input.y:7.13-29: previous declaration
|
||||
input.y:11.10-24: redeclaration for default tagless %printer
|
||||
input.y:11.10-24: %printer redeclaration for <>
|
||||
input.y:8.10-24: previous declaration
|
||||
input.y:17.13-29: redeclaration for default tagged %destructor
|
||||
input.y:17.13-29: %destructor redeclaration for <*>
|
||||
input.y:4.13-29: previous declaration
|
||||
input.y:18.10-24: redeclaration for default tagged %printer
|
||||
input.y:18.10-24: %printer redeclaration for <*>
|
||||
input.y:5.10-24: previous declaration
|
||||
input.y:20.13-29: redeclaration for default tagless %destructor
|
||||
input.y:20.13-29: %destructor redeclaration for <>
|
||||
input.y:10.13-29: previous declaration
|
||||
input.y:21.10-24: redeclaration for default tagless %printer
|
||||
input.y:21.10-24: %printer redeclaration for <>
|
||||
input.y:11.10-24: previous declaration
|
||||
]])
|
||||
|
||||
@@ -329,8 +329,16 @@ AT_CLEANUP
|
||||
|
||||
AT_SETUP([Useless printers or destructors])
|
||||
|
||||
AT_DATA([[input.y]],
|
||||
[[%token <type1> token1
|
||||
# AT_TEST([INPUT], [STDERR])
|
||||
# --------------------------
|
||||
m4_pushdef([AT_TEST],
|
||||
[AT_DATA([[input.y]],
|
||||
[$1
|
||||
])
|
||||
AT_BISON_CHECK([input.y], [0], [], [$2
|
||||
])])
|
||||
|
||||
AT_TEST([[%token <type1> token1
|
||||
%token <type2> token2
|
||||
%token <type3> token3
|
||||
%token <type4> token4
|
||||
@@ -356,14 +364,26 @@ AT_DATA([[input.y]],
|
||||
%destructor {} <type7>
|
||||
|
||||
%%
|
||||
exp: "a";
|
||||
]])
|
||||
|
||||
AT_BISON_CHECK([input.y], [0], [],
|
||||
exp: "a";]],
|
||||
[[input.y:16.13-19: warning: useless %printer for type <type1> [-Wother]
|
||||
input.y:17.16-22: warning: useless %destructor for type <type2> [-Wother]
|
||||
]])
|
||||
input.y:17.16-22: warning: useless %destructor for type <type2> [-Wother]]])
|
||||
|
||||
# If everybody is typed, <> is useless.
|
||||
AT_TEST([[%type <type> exp
|
||||
%token <type> a
|
||||
%printer {} <> <*>
|
||||
%%
|
||||
exp: a;]],
|
||||
[[input.y:3.13-14: warning: useless %printer for type <> [-Wother]]])
|
||||
|
||||
# If nobody is is typed, <*> is useless.
|
||||
AT_TEST([[%token a
|
||||
%printer {} <> <*>
|
||||
%%
|
||||
exp: a;]],
|
||||
[[input.y:2.16-18: warning: useless %printer for type <*> [-Wother]]])
|
||||
|
||||
m4_popdef([AT_TEST])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
Reference in New Issue
Block a user