Commit 06f872c1 authored by Botond Baranyi's avatar Botond Baranyi
Browse files

Fixes to the '@default' modifier in runtime 2 (bug 564919)


Signed-off-by: Botond Baranyi's avatarBotond Baranyi <botond.baranyi@ericsson.com>
Change-Id: Ia6441f854c32d6a0ff2ecde5c80eee9b21ea5451
parent 4ceefabb
......@@ -4355,7 +4355,7 @@ bool Type::chk_this_refd_value(Value *value, Common::Assignment *lhs, expected_v
default:
if (info.is_subtype_error()) {
value->error("%s", info.get_subtype_error().c_str());
} else if (!info.is_erroneous()) {
} else {
CompField* def_alt_ref = governor->get_default_alternative();
Ttcn::Reference* ttcn_ref = dynamic_cast<Ttcn::Reference*>(ref);
if (def_alt_ref != NULL && ttcn_ref != NULL) {
......@@ -4376,15 +4376,17 @@ bool Type::chk_this_refd_value(Value *value, Common::Assignment *lhs, expected_v
value->use_default_alternative(this);
return self_ref;
}
value->error("Type mismatch: a %s of type `%s' was expected "
if (!info.is_erroneous()) {
value->error("Type mismatch: a %s of type `%s' was expected "
"instead of `%s'", expected_value == EXPECTED_TEMPLATE
? "value or template" : "value",
get_typename().c_str(),
governor->get_typename().c_str());
} else {
// The semantic error was found by the new code. It was better to
// do the assembly inside TypeCompatInfo.
value->error("%s", info.get_error_str_str().c_str());
} else {
// The semantic error was found by the new code. It was better to
// do the assembly inside TypeCompatInfo.
value->error("%s", info.get_error_str_str().c_str());
}
}
break;
}
......
......@@ -4946,29 +4946,29 @@ namespace Common {
bool compat_t1 = t1->is_compatible(t2, &info1, this, &l_chain1, &r_chain1);
bool compat_t2 = t2->is_compatible(t1, &info2, NULL, &l_chain2, &r_chain2);
if (!compat_t1 && !compat_t2) {
if (v1->is_ref()) {
CompField* def_alt = t1->get_default_alternative();
Ttcn::Reference* ttcn_ref = dynamic_cast<Ttcn::Reference*>(v1->get_reference());
if (def_alt != NULL && ttcn_ref != NULL) {
Error_Context cntxt(v1, "Using default alternative `%s' in value of union type `%s'",
def_alt->get_name().get_dispname().c_str(), t1->get_typename().c_str());
ttcn_ref->use_default_alternative(def_alt->get_name());
return chk_expr_operandtypes_compat(exp_val, v1, v2, opnum1, opnum2);
}
}
if (v2->is_ref()) {
CompField* def_alt = t2->get_default_alternative();
Ttcn::Reference* ttcn_ref = dynamic_cast<Ttcn::Reference*>(v2->get_reference());
if (def_alt != NULL && ttcn_ref != NULL) {
Error_Context cntxt(v2, "Using default alternative `%s' in value of union type `%s'",
def_alt->get_name().get_dispname().c_str(), t2->get_typename().c_str());
ttcn_ref->use_default_alternative(def_alt->get_name());
return chk_expr_operandtypes_compat(exp_val, v1, v2, opnum1, opnum2);
}
}
if (!info1.is_erroneous() && !info2.is_erroneous()) {
// the subtypes don't need to be compatible here
if (!info1.is_subtype_error() && !info2.is_subtype_error()) {
if (v1->is_ref()) {
CompField* def_alt = t1->get_default_alternative();
Ttcn::Reference* ttcn_ref = dynamic_cast<Ttcn::Reference*>(v1->get_reference());
if (def_alt != NULL && ttcn_ref != NULL) {
Error_Context cntxt(v1, "Using default alternative `%s' in value of union type `%s'",
def_alt->get_name().get_dispname().c_str(), t1->get_typename().c_str());
ttcn_ref->use_default_alternative(def_alt->get_name());
return chk_expr_operandtypes_compat(exp_val, v1, v2, opnum1, opnum2);
}
}
if (v2->is_ref()) {
CompField* def_alt = t2->get_default_alternative();
Ttcn::Reference* ttcn_ref = dynamic_cast<Ttcn::Reference*>(v2->get_reference());
if (def_alt != NULL && ttcn_ref != NULL) {
Error_Context cntxt(v2, "Using default alternative `%s' in value of union type `%s'",
def_alt->get_name().get_dispname().c_str(), t2->get_typename().c_str());
ttcn_ref->use_default_alternative(def_alt->get_name());
return chk_expr_operandtypes_compat(exp_val, v1, v2, opnum1, opnum2);
}
}
error("The operands of operation `%s' should be of compatible "
"types", get_opname());
set_valuetype(V_ERROR);
......
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