mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 17:51:53 +00:00
Filter: Add separate instruction for uninitialized variable declaration
The previous approach (use VOID constant for variable initialization) failed due to dynamic type check failure. Thanks to Alexander Zubkov <green@qrator.net> for the bugreport.
This commit is contained in:
parent
116285f2b0
commit
cce48c6cdd
@ -324,7 +324,7 @@ CF_KEYWORDS(FUNCTION, PRINT, PRINTN, UNSET, RETURN,
|
||||
%nonassoc ELSE
|
||||
|
||||
%type <xp> cmds_int cmd_prep
|
||||
%type <x> term term_bs cmd cmd_var cmds cmds_scoped constant constructor print_list var var_init var_list function_call symbol_value bgp_path_expr bgp_path bgp_path_tail
|
||||
%type <x> term term_bs cmd cmd_var cmds cmds_scoped constant constructor print_list var var_list function_call symbol_value bgp_path_expr bgp_path bgp_path_tail
|
||||
%type <fda> dynamic_attr
|
||||
%type <fsa> static_attr
|
||||
%type <f> filter where_filter
|
||||
@ -895,16 +895,16 @@ print_list: /* EMPTY */ { $$ = NULL; }
|
||||
}
|
||||
;
|
||||
|
||||
var_init:
|
||||
/* empty */ { $$ = f_new_inst(FI_CONSTANT, (struct f_val) { }); }
|
||||
| '=' term { $$ = $2; }
|
||||
;
|
||||
|
||||
var:
|
||||
type symbol var_init ';' {
|
||||
type symbol '=' term ';' {
|
||||
struct symbol *sym = cf_define_symbol($2, SYM_VARIABLE | $1, offset, f_new_var(sym_->scope));
|
||||
$$ = f_new_inst(FI_VAR_INIT, $3, sym);
|
||||
$$ = f_new_inst(FI_VAR_INIT, $4, sym);
|
||||
}
|
||||
| type symbol ';' {
|
||||
struct symbol *sym = cf_define_symbol($2, SYM_VARIABLE | $1, offset, f_new_var(sym_->scope));
|
||||
$$ = f_new_inst(FI_VAR_INIT0, sym);
|
||||
}
|
||||
;
|
||||
|
||||
for_var:
|
||||
type symbol { $$ = cf_define_symbol($2, SYM_VARIABLE | $1, offset, f_new_var(sym_->scope)); }
|
||||
|
@ -506,6 +506,7 @@
|
||||
RESULT(T_BOOL, i, ipa_is_ip4(v1.val.ip));
|
||||
}
|
||||
|
||||
/* Add initialized variable */
|
||||
INST(FI_VAR_INIT, 1, 0) {
|
||||
NEVER_CONSTANT;
|
||||
ARG_ANY(1);
|
||||
@ -518,6 +519,17 @@
|
||||
fstk->vcnt = pos + 1;
|
||||
}
|
||||
|
||||
/* Add uninitialized variable */
|
||||
INST(FI_VAR_INIT0, 0, 0) {
|
||||
NEVER_CONSTANT;
|
||||
SYMBOL;
|
||||
|
||||
/* New variable is always the last on stack */
|
||||
uint pos = curline.vbase + sym->offset;
|
||||
fstk->vstk[pos] = (struct f_val) { };
|
||||
fstk->vcnt = pos + 1;
|
||||
}
|
||||
|
||||
/* Set to indirect value prepared in v1 */
|
||||
INST(FI_VAR_SET, 1, 0) {
|
||||
NEVER_CONSTANT;
|
||||
|
@ -630,8 +630,8 @@ bt_test_suite(t_prefix_set, "Testing prefix sets");
|
||||
*/
|
||||
|
||||
function t_prefix6()
|
||||
prefix px;
|
||||
{
|
||||
prefix px;
|
||||
px = 1020::/18;
|
||||
bt_assert(format(px) = "1020::/18");
|
||||
bt_assert(1020:3040:5060:: ~ 1020:3040:5000::/40);
|
||||
@ -976,8 +976,8 @@ bt_test_suite(t_clist, "Testing lists of communities");
|
||||
*/
|
||||
|
||||
function t_ec()
|
||||
ec cc;
|
||||
{
|
||||
ec cc;
|
||||
cc = (rt, 12345, 200000);
|
||||
bt_assert(format(cc) = "(rt, 12345, 200000)");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user