From: Ondrej Zajicek (work) Date: Tue, 7 Jan 2020 00:24:30 +0000 (+0100) Subject: Filter: Fix typecheck for AND/OR. X-Git-Tag: v2.0.8~104 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ef8c45749c82e246d477ea4d7f749668a9c7e9ee;p=thirdparty%2Fbird.git Filter: Fix typecheck for AND/OR. Do not apply dynamic type check for second argument of AND/OR, as it is not evaluated immediately like regular argument would be. Thanks to Mikael for the bugreport. --- diff --git a/filter/decl.m4 b/filter/decl.m4 index a78450a35..efecb9a57 100644 --- a/filter/decl.m4 +++ b/filter/decl.m4 @@ -161,11 +161,16 @@ FID_HIC(,[[ # Some arguments need to check their type. After that, ARG_ANY is called. m4_define(ARG, `ARG_ANY($1) ARG_TYPE($1,$2)') -m4_define(ARG_TYPE, ` +m4_define(ARG_TYPE, `ARG_TYPE_STATIC($1,$2) ARG_TYPE_DYNAMIC($1,$2)') + +m4_define(ARG_TYPE_STATIC, ` FID_NEW_BODY()m4_dnl if (f$1->type && (f$1->type != ($2)) && !f_const_promotion(f$1, ($2))) cf_error("Argument $1 of %s must be of type %s, got type %s", f_instruction_name(what->fi_code), f_type_name($2), f_type_name(f$1->type)); +FID_INTERPRET_BODY()') + +m4_define(ARG_TYPE_DYNAMIC, ` FID_INTERPRET_EXEC()m4_dnl if (v$1.type != ($2)) runtime("Argument $1 of %s must be of type %s, got type %s", diff --git a/filter/f-inst.c b/filter/f-inst.c index 51a353509..4b3c627b5 100644 --- a/filter/f-inst.c +++ b/filter/f-inst.c @@ -226,7 +226,7 @@ } INST(FI_AND, 1, 1) { ARG(1,T_BOOL); - ARG_TYPE(2,T_BOOL); + ARG_TYPE_STATIC(2,T_BOOL); RESULT_TYPE(T_BOOL); if (v1.val.i) @@ -236,7 +236,7 @@ } INST(FI_OR, 1, 1) { ARG(1,T_BOOL); - ARG_TYPE(2,T_BOOL); + ARG_TYPE_STATIC(2,T_BOOL); RESULT_TYPE(T_BOOL); if (!v1.val.i)