Commit e057df14 authored by Mathias Hasselmann's avatar Mathias Hasselmann Committed by Mathias Hasselmann
Browse files

consider switch statements when releasing local variables, fixes bug

2007-08-21 Mathias Hasselmann <mathias.hasselmann@gmx.de>

	* gobject/valacodegenerator.vala, vala/valaswitchsection.vala,
	vala/valaswitchstatement.vala: consider switch statements
	when releasing local variables, fixes bug 467896
	* tests/Makefile.am, tests/test-035.*: test for that bug

svn path=/trunk/; revision=493
parent cde360aa
2007-08-21 Mathias Hasselmann <mathias.hasselmann@gmx.de>
* gobject/valacodegenerator.vala, vala/valaswitchsection.vala,
vala/valaswitchstatement.vala: consider switch statements
when releasing local variables, fixes bug 467896
* tests/Makefile.am, tests/test-035.*: test for that bug
2007-08-20 Jürg Billeter <j@bitron.ch>
* vala/valasemanticanalyzer.vala, vala/valathrowstatement.vala,
......
......@@ -1634,7 +1634,8 @@ public class Vala.CodeGenerator : CodeVisitor {
if (stop_at_loop) {
if (b.parent_node is DoStatement || b.parent_node is WhileStatement ||
b.parent_node is ForStatement || b.parent_node is ForeachStatement) {
b.parent_node is ForStatement || b.parent_node is ForeachStatement ||
b.parent_node is SwitchStatement) {
return;
}
}
......
......@@ -67,6 +67,7 @@ TESTS = \
test-032.vala \
test-033.vala \
test-034.vala \
test-035.vala \
$(NULL)
EXTRA_DIST = \
......@@ -105,6 +106,7 @@ EXTRA_DIST = \
test-032.vala \
test-033.vala \
test-034.vala \
test-035.vala \
test-001.out \
test-002.out \
test-003.out \
......@@ -139,6 +141,7 @@ EXTRA_DIST = \
test-032.out \
test-033.out \
test-034.out \
test-035.out \
\
testenchant.stamp \
testenchant.vala \
......
before switch: Hello World
within switch: Hello World
behind switch: Hello World
using GLib;
class SwitchTest {
static void main () {
var foo = "Hello World";
var bar = 0;
stdout.printf ("before switch: %s\n", foo);
switch (bar) {
case 0:
stdout.printf ("within switch: %s\n", foo);
break;
}
stdout.printf ("behind switch: %s\n", foo);
}
}
......@@ -26,7 +26,7 @@ using Gee;
/**
* Represents a switch section in the source code.
*/
public class Vala.SwitchSection : CodeNode {
public class Vala.SwitchSection : Block {
private Gee.List<SwitchLabel> labels = new ArrayList<SwitchLabel> ();
private Gee.List<Statement> statement_list = new ArrayList<Statement> ();
......@@ -90,10 +90,13 @@ public class Vala.SwitchSection : CodeNode {
label.accept (visitor);
}
visitor.visit_begin_block (this);
foreach (Statement st in statement_list) {
st.accept (visitor);
}
visitor.visit_switch_section (this);
visitor.visit_end_block (this);
}
}
......@@ -59,6 +59,7 @@ public class Vala.SwitchStatement : CodeNode, Statement {
* @param section a switch section
*/
public void add_section (SwitchSection! section) {
section.parent_node = this;
sections.add (section);
}
......
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