Commit 3338a86d authored by Botond Baranyi's avatar Botond Baranyi
Browse files

OOP: added semantic errors for starting a class method or a function with a...


OOP: added semantic errors for starting a class method or a function with a class type parameter on a parallel component (bug 568748, 568744, 568899)
Signed-off-by: Botond Baranyi's avatarBotond Baranyi <botond.baranyi@ericsson.com>
Change-Id: I51fe7e6e2f26efb2727d34081cf8430b3fc86955
parent 2fd1b961
......@@ -7011,7 +7011,7 @@ namespace Ttcn {
}
// decision of startability
is_startable = runs_on_ref != 0;
is_startable = runs_on_ref != 0 && !my_scope->is_class_scope();
if (is_startable && !fp_list->get_startability()) is_startable = false;
if (is_startable && return_type && return_type->is_component_internal())
is_startable = false;
......@@ -7040,6 +7040,10 @@ namespace Ttcn {
bool Def_Function::chk_startable(Location* caller_location)
{
if (!checked) chk();
if (my_scope->is_class_scope()) {
caller_location->error("A method of a class cannot be started on a parallel test component");
return false;
}
fp_list->chk_startability("Function", get_fullname().c_str(), caller_location);
if (is_startable) return true;
if (!runs_on_ref) error("Function `%s' cannot be started on a parallel "
......@@ -10333,8 +10337,11 @@ namespace Ttcn {
case Common::Assignment::A_PAR_TEMPL_INOUT:
case Common::Assignment::A_PAR_VAL_OUT:
case Common::Assignment::A_PAR_TEMPL_OUT:
if (is_startable && par->get_Type()->is_component_internal())
if (is_startable &&
(par->get_Type()->is_component_internal() ||
(par->get_Type()->get_type_refd_last()->get_typetype() == Common::Type::T_CLASS))) {
is_startable = false;
}
break;
default:
is_startable = false;
......@@ -10383,6 +10390,12 @@ namespace Ttcn {
par->get_Type()->chk_component_internal(type_chain, err_str);
Free(err_str);
}
if (!is_startable &&
par->get_Type()->get_type_refd_last()->get_typetype() == Common::Type::T_CLASS) {
caller_location->error("%s `%s' cannot be started on a parallel test component "
"because parameter `%s' is of a class type",
p_what, p_name, par->get_id().get_dispname().c_str());
}
break;
default:
if (!is_startable) {
......
......@@ -4808,7 +4808,7 @@ error:
{
Error_Context cntxt(this, "In start test component statement");
Type *comp_type = chk_comp_ref(comp_op.compref, false, false);
Common::Assignment *t_ass = comp_op.funcinstref->get_refd_assignment();
Common::Assignment *t_ass = comp_op.funcinstref->get_refd_assignment_last();
if (!t_ass) return;
// checking whether the referred definition is a function
Common::Assignment::asstype_t asstype = t_ass->get_asstype();
......
......@@ -524,6 +524,17 @@ function f_param_test() { //^In function definition//
f_parameters(x.m2(), x.m2(), x.m2()); //^In function instance// //^In actual parameter list of function// //^In parameter #2// //^In parameter #3// //Reference to a variable or value parameter was expected for an \`inout\' value parameter instead of function// //Reference to a variable or value parameter was expected for an \`out\' value parameter instead of function//
}
function f_class_param(in C39 x) runs on Comp { }
function f_start_comp() { //^In function definition//
var Comp ct := Comp.create alive;
var C39 x := C39.create;
ct.start(x.f_def(1)); //^In start test component statement// //A method of a class cannot be started on a parallel test component//
ct.done;
ct.start(f_class_param(x)); //^In start test component statement// //Function `@oop_SE.f_class_param' cannot be started on a parallel test component because parameter `x' is of a class type//
ct.done;
}
control { //^In control part//
var C11 x := C11.create; //^In variable definition// //A definition without `runs on' clause cannot create a value of class type `@oop_SE.C11', which runs on component type `@oop_SE.CT_RunsOn'// //Cannot create value of class type `@oop_SE.C11', which has an `mtc' clause, in the control part.// //Cannot create value of class type `@oop_SE.C11', which has a `system' clause, in the control part.//
......
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