Commit 4d73b798 authored by Botond Baranyi's avatar Botond Baranyi
Browse files

Fixed immutability check for 'inout' and 'out' parameters (bug 538465)



Change-Id: I6b3905472fbe77b6b1022cd0e791f4a94b5800a6
Signed-off-by: Botond Baranyi's avatarBotond Baranyi <botond.baranyi@ericsson.com>
parent 15e06a7f
......@@ -414,55 +414,9 @@ namespace Common {
void Value::chk_expr_immutability() {
switch (valuetype) {
case V_REFD: {/**< referenced */
int asstype = get_reference()->get_refd_assignment()->get_asstype();
switch (asstype) {
case Assignment::A_TYPE: /**< type */
case Assignment::A_CONST: /**< value (const) */
case Assignment::A_UNDEF: /**< undefined/undecided (ASN.1) */
case Assignment::A_ERROR: /**< erroneous; the kind cannot be deduced (ASN.1) */
case Assignment::A_OC: /**< information object class (ASN.1) */
case Assignment::A_OBJECT: /**< information object (ASN.1) */
case Assignment::A_OS: /**< information object set (ASN.1) */
case Assignment::A_VS: /**< value set (ASN.1) */
case Assignment::A_EXT_CONST: /**< external constant (TTCN-3) */
case Assignment::A_MODULEPAR: /**< module parameter (TTCN-3) */
case Assignment::A_MODULEPAR_TEMP: /**< template module parameter */
case Assignment::A_VAR: /**< variable (TTCN-3) */
case Assignment::A_VAR_TEMPLATE: /**< template variable: dynamic template (TTCN-3) */
case Assignment::A_TIMER: /**< timer (TTCN-3) */
case Assignment::A_PORT: /**< port (TTCN-3) */
case Assignment::A_ALTSTEP: /**< altstep (TTCN-3) */
case Assignment::A_TESTCASE: /**< testcase Assignment::(TTCN-3) */
case Assignment::A_PAR_TIMER: /**< formal parameter (timer) (TTCN-3) */
case Assignment::A_PAR_PORT: /**< formal parameter (port) (TTCN-3) */
break;
case Assignment::A_TEMPLATE:
if(get_reference()->get_parlist())
get_reference()->get_parlist()->chk_immutability();
break;
case Assignment::A_FUNCTION: /**< function without return type (TTCN-3) */
case Assignment::A_FUNCTION_RVAL: /**< function that returns a value (TTCN-3) */
case Assignment::A_FUNCTION_RTEMP: /**< function that returns a template (TTCN-3) */
case Assignment::A_EXT_FUNCTION: /**< external function without return type (TTCN-3) */
case Assignment::A_EXT_FUNCTION_RVAL: /**< ext. func that returns a value (TTCN-3) */
case Assignment::A_EXT_FUNCTION_RTEMP: /**< ext. func that returns a template (TTCN-3) */
warning("Function invocation '%s' may change the actual snapshot.",
get_reference()->get_dispname().c_str());
break;
case Assignment::A_PAR_VAL: /**< formal parameter (value) (TTCN-3) */
case Assignment::A_PAR_VAL_IN: /**< formal parameter (in value) (TTCN-3) */
case Assignment::A_PAR_VAL_OUT: /**< formal parameter (out value) (TTCN-3) */
// TODO: @fuzzy INOUT parameter is not valid
case Assignment::A_PAR_VAL_INOUT: /**< formal parameter (inout value) (TTCN-3) */
case Assignment::A_PAR_TEMPL_IN: /**< formal parameter ([in] template) (TTCN-3) */
case Assignment::A_PAR_TEMPL_OUT: /**< formal parameter (out template) (TTCN-3) */
case Assignment::A_PAR_TEMPL_INOUT:/**< formal parameter (inout template) (TTCN-3) */
if (get_reference()->get_refd_assignment()->get_eval_type() == FUZZY_EVAL)
warning("Fuzzy parameter '%s' may change (during) the actual snapshot.",
get_reference()->get_dispname().c_str());
break;
default:
FATAL_ERROR("Value::chk_expr_immutability()");
Ttcn::Ref_base* ttcn_ref = dynamic_cast<Ttcn::Ref_base*>(u.ref.ref);
if (ttcn_ref != NULL) {
ttcn_ref->chk_immutability();
}
break;}
case V_EXPR: /**< expressions */
......
......@@ -490,6 +490,62 @@ namespace Ttcn {
}
}
void Ref_base::chk_immutability()
{
Common::Assignment* ass = get_refd_assignment();
switch (ass->get_asstype()) {
case Common::Assignment::A_TYPE: /**< type */
case Common::Assignment::A_CONST: /**< value (const) */
case Common::Assignment::A_UNDEF: /**< undefined/undecided (ASN.1) */
case Common::Assignment::A_ERROR: /**< erroneous; the kind cannot be deduced (ASN.1) */
case Common::Assignment::A_OC: /**< information object class (ASN.1) */
case Common::Assignment::A_OBJECT: /**< information object (ASN.1) */
case Common::Assignment::A_OS: /**< information object set (ASN.1) */
case Common::Assignment::A_VS: /**< value set (ASN.1) */
case Common::Assignment::A_EXT_CONST: /**< external constant (TTCN-3) */
case Common::Assignment::A_MODULEPAR: /**< module parameter (TTCN-3) */
case Common::Assignment::A_MODULEPAR_TEMP: /**< template module parameter */
case Common::Assignment::A_VAR: /**< variable (TTCN-3) */
case Common::Assignment::A_VAR_TEMPLATE: /**< template variable: dynamic template (TTCN-3) */
case Common::Assignment::A_TIMER: /**< timer (TTCN-3) */
case Common::Assignment::A_PORT: /**< port (TTCN-3) */
case Common::Assignment::A_ALTSTEP: /**< altstep (TTCN-3) */
case Common::Assignment::A_TESTCASE: /**< testcase Assignment::(TTCN-3) */
case Common::Assignment::A_PAR_TIMER: /**< formal parameter (timer) (TTCN-3) */
case Common::Assignment::A_PAR_PORT: /**< formal parameter (port) (TTCN-3) */
break;
case Common::Assignment::A_TEMPLATE:
if (get_parlist() != NULL) {
get_parlist()->chk_immutability();
}
break;
case Common::Assignment::A_FUNCTION: /**< function without return type (TTCN-3) */
case Common::Assignment::A_FUNCTION_RVAL: /**< function that returns a value (TTCN-3) */
case Common::Assignment::A_FUNCTION_RTEMP: /**< function that returns a template (TTCN-3) */
case Common::Assignment::A_EXT_FUNCTION: /**< external function without return type (TTCN-3) */
case Common::Assignment::A_EXT_FUNCTION_RVAL: /**< ext. func that returns a value (TTCN-3) */
case Common::Assignment::A_EXT_FUNCTION_RTEMP: /**< ext. func that returns a template (TTCN-3) */
warning("Function invocation '%s' may change the actual snapshot.",
get_dispname().c_str());
break;
case Common::Assignment::A_PAR_VAL: /**< formal parameter (value) (TTCN-3) */
case Common::Assignment::A_PAR_VAL_IN: /**< formal parameter (in value) (TTCN-3) */
case Common::Assignment::A_PAR_VAL_OUT: /**< formal parameter (out value) (TTCN-3) */
// TODO: @fuzzy INOUT parameter is not valid
case Common::Assignment::A_PAR_VAL_INOUT: /**< formal parameter (inout value) (TTCN-3) */
case Common::Assignment::A_PAR_TEMPL_IN: /**< formal parameter ([in] template) (TTCN-3) */
case Common::Assignment::A_PAR_TEMPL_OUT: /**< formal parameter (out template) (TTCN-3) */
case Common::Assignment::A_PAR_TEMPL_INOUT:/**< formal parameter (inout template) (TTCN-3) */
if (ass->get_eval_type() == FUZZY_EVAL) {
warning("Fuzzy parameter '%s' may change (during) the actual snapshot.",
get_dispname().c_str());
}
break;
default:
FATAL_ERROR("Ref_base::chk_immutability()");
}
}
void Ref_base::generate_code_const_ref(expression_struct_t */*expr*/)
{
FATAL_ERROR("Ref_base::generate_code_const_ref()");
......@@ -10629,11 +10685,7 @@ namespace Ttcn {
ap->get_TemplateInstance()->chk_immutability();
break;
case ActualPar::AP_REF: ///< out/inout value or template parameter
// TODO: test!
if(ap->get_Value())
ap->get_Value()->chk_expr_immutability();
if(ap->get_TemplateInstance())
ap->get_TemplateInstance()->chk_immutability();
ap->get_Ref()->chk_immutability();
break;
case ActualPar::AP_DEFAULT: { ///< created from the default value of a formal parameter
// TODO: test!
......
......@@ -310,6 +310,7 @@ namespace Ttcn {
virtual bool has_single_expr();
virtual void set_code_section(
GovernedSimple::code_section_t p_code_section);
void chk_immutability();
/** Generates the C++ equivalent of the reference (including the parameter
* list and sub-references) as an access to a constant resource.
*/
......
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