+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,
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;
}
}
test-032.vala \
test-033.vala \
test-034.vala \
+ test-035.vala \
$(NULL)
EXTRA_DIST = \
test-032.vala \
test-033.vala \
test-034.vala \
+ test-035.vala \
test-001.out \
test-002.out \
test-003.out \
test-032.out \
test-033.out \
test-034.out \
+ test-035.out \
\
testenchant.stamp \
testenchant.vala \
--- /dev/null
+before switch: Hello World
+within switch: Hello World
+behind switch: Hello World
--- /dev/null
+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);
+ }
+}
/**
* 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> ();
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);
}
}
* @param section a switch section
*/
public void add_section (SwitchSection! section) {
+ section.parent_node = this;
sections.add (section);
}