diff --git a/compiler2/ttcn3/Statement.cc b/compiler2/ttcn3/Statement.cc index 54c0bec7d4f6b68ab62d6bc944b642495e581b2c..28418078b80eaabfe82bb69e08ac6c7a61da5613 100644 --- a/compiler2/ttcn3/Statement.cc +++ b/compiler2/ttcn3/Statement.cc @@ -6334,7 +6334,9 @@ error: char *expr_name=select.expr->generate_code_tmp(0, expr_init); if (expr_init[0]) { // some init code was generated str = update_location_object(str); - str = mputstr(str, "{\n"); + } + str = mputstr(str, "{\n"); + if (expr_init[0]) { str = mputstr(str, expr_init); } @@ -6357,7 +6359,7 @@ error: str=select.scs->generate_code(str, tmp_prefix.c_str(), tmp_id.c_str()); } Free(expr_name); - if (expr_init[0]) str=mputstr(str, "}\n"); + str=mputstr(str, "}\n"); Free(expr_init); return str; } diff --git a/regression_test/compileonly/selectCase/selectCase.ttcn b/regression_test/compileonly/selectCase/selectCase.ttcn index 7db3788b1fcdc644c4b11ca7d0f501c0862b56a9..ae0f4f42db15cb16ba072267b4eb77c19646cc09 100644 --- a/regression_test/compileonly/selectCase/selectCase.ttcn +++ b/regression_test/compileonly/selectCase/selectCase.ttcn @@ -8,6 +8,7 @@ * Contributors: * Balasko, Jeno * Baranyi, Botond + * Szabo, Bence Janos * ******************************************************************************/ @@ -78,4 +79,34 @@ function f_embeddedEmptyRecord() { } } +function f_with_goto() { + var boolean v_result; + var charstring pl_messageType := "s"; + v_result := true; + if (not v_result) { goto END_EXECUTION }; + + select (pl_messageType) { + case ("SAR") { + v_result := false; + } + } + label END_EXECUTION; + log(v_result); +} + +function f_with_goto_int() { + var integer v_result; + var charstring pl_messageType := "s"; + v_result := 3; + if (v_result == 2) { goto END_EXECUTION }; + + select (v_result) { + case (4) { + v_result := 3; + } + } + label END_EXECUTION; + log(v_result); +} + }