Commit d82bf1e0 authored by Botond Baranyi's avatar Botond Baranyi
Browse files

Fixed code generated for restricted template actual parameter (bug 526526)



Change-Id: I08dd1edd009dcf2d82068da5a05dc75679fe4c70
Signed-off-by: Botond Baranyi's avatarBotond Baranyi <botond.baranyi@ericsson.com>
parent 48006c2f
......@@ -10297,7 +10297,7 @@ namespace Ttcn {
const char *tmp_id_str = tmp_id.c_str();
expression_struct ref_expr;
Code::init_expr(&ref_expr);
ref->generate_code_const_ref(&ref_expr);
ref->generate_code(&ref_expr);
ref_expr.preamble = mputprintf(ref_expr.preamble, "%s& %s = %s;\n",
is_template_par ? actual_par_type->get_genname_template(my_scope).c_str() :
actual_par_type->get_genname_value(my_scope).c_str(), tmp_id_str, ref_expr.expr);
......
......@@ -395,6 +395,40 @@ testcase templateIntParam() runs on templateInt_mycomp {
}
}
type record R {
integer field1,
record {
integer subfield1,
integer subfield2
} field2 optional
}
function f_param_restriction(in template(value) integer p1, inout template(present) integer p2, out template (present) integer p3) {
p2 := 10;
p3 := p1;
}
testcase templateIntParamRestriction() runs on templateInt_mycomp {
var template R vt_test := {
field1 := 1,
field2 := ?
};
f_param_restriction(vt_test.field1, vt_test.field2.subfield1, vt_test.field2.subfield2);
var template R vt_expected := {
field1 := 1,
field2 := {
subfield1 := 10,
subfield2 := 1
}
};
if (log2str(vt_test) == log2str(vt_expected)) {
setverdict(pass);
}
else {
setverdict(fail, "Expected: ", vt_expected, ", got: ", vt_test);
}
}
control {
execute(templateIntSpec());
......@@ -415,5 +449,6 @@ control {
execute(templateIntReverseOrderImported2());
execute(templateIntReverseOrderLocal());
execute(templateIntParam());
execute(templateIntParamRestriction());
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment