}
}
- public void append_local_free (Symbol sym, bool stop_at_loop = false, CodeNode? stop_at = null) {
+ public void append_local_free (Symbol sym, Statement? jump_stmt = null, CodeNode? stop_at = null) {
var b = (Block) sym;
append_scope_free (sym, stop_at);
- if (stop_at_loop) {
+ if (jump_stmt is BreakStatement) {
if (b.parent_node is Loop ||
b.parent_node is ForeachStatement ||
b.parent_node is SwitchStatement) {
return;
}
+ } else if (jump_stmt is ContinueStatement) {
+ if (b.parent_node is Loop ||
+ b.parent_node is ForeachStatement) {
+ return;
+ }
}
if (stop_at != null && b.parent_node == stop_at) {
}
if (sym.parent_symbol is Block) {
- append_local_free (sym.parent_symbol, stop_at_loop, stop_at);
+ append_local_free (sym.parent_symbol, jump_stmt, stop_at);
} else if (sym.parent_symbol is Method) {
append_param_free ((Method) sym.parent_symbol);
} else if (sym.parent_symbol is PropertyAccessor) {
}
public override void visit_break_statement (BreakStatement stmt) {
- append_local_free (current_symbol, true);
+ append_local_free (current_symbol, stmt);
ccode.add_break ();
}
public override void visit_continue_statement (ContinueStatement stmt) {
- append_local_free (current_symbol, true);
+ append_local_free (current_symbol, stmt);
ccode.add_continue ();
}
set_error.add_argument (error_expr);
ccode.add_expression (set_error);
- append_local_free (current_symbol, false);
+ append_local_free (current_symbol);
if (context.require_glib_version (2, 36)) {
// We already returned the error above, we must not return anything else here.
ccode.add_expression (cpropagate);
// free local variables
- append_local_free (current_symbol, false);
+ append_local_free (current_symbol);
if (current_method is CreationMethod && current_method.parent_symbol is Class) {
var cl = (Class) current_method.parent_symbol;
void uncaught_error_statement (CCodeExpression inner_error, bool unexpected = false) {
// free local variables
- append_local_free (current_symbol, false);
+ append_local_free (current_symbol);
var ccritical = new CCodeFunctionCall (new CCodeIdentifier ("g_critical"));
ccritical.add_argument (new CCodeConstant (unexpected ? "\"file %s: line %d: unexpected error: %s (%s, %d)\"" : "\"file %s: line %d: uncaught error: %s (%s, %d)\""));
// free local variables
if (is_in_catch) {
- append_local_free (current_symbol, false, current_catch);
+ append_local_free (current_symbol, null, current_catch);
} else {
- append_local_free (current_symbol, false, current_try);
+ append_local_free (current_symbol, null, current_try);
}
var error_types = new ArrayList<DataType> ();
control-flow/expressions-conditional.vala \
control-flow/finally-return.test \
control-flow/for.vala \
+ control-flow/for-switch-continue.vala \
control-flow/foreach.vala \
control-flow/missing-break.test \
control-flow/missing-return.test \
--- /dev/null
+bool success = false;
+
+class Foo : Object {
+ ~Foo () {
+ success = true;
+ }
+}
+
+void bar () {
+ assert (!success);
+ for (int i = 0; i < 1; i++) {
+ Foo? foo = null;
+ switch (i) {
+ case 0:
+ foo = new Foo ();
+ continue;
+ }
+ }
+ assert (success);
+}
+
+void main() {
+ bar ();
+}