From: Rico Tzschichholz Date: Tue, 23 Oct 2018 21:12:06 +0000 (+0200) Subject: vala: Add missing re-check guards for Do/For/WhileStatement and SwitchLabel X-Git-Tag: 0.42.4~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8cfed12b8c3c07fc99cb3022f2420909ca54911a;p=thirdparty%2Fvala.git vala: Add missing re-check guards for Do/For/WhileStatement and SwitchLabel --- diff --git a/vala/valadostatement.vala b/vala/valadostatement.vala index 987facc90..f34e22358 100644 --- a/vala/valadostatement.vala +++ b/vala/valadostatement.vala @@ -93,6 +93,12 @@ public class Vala.DoStatement : CodeNode, Statement { } public override bool check (CodeContext context) { + if (checked) { + return !error; + } + + checked = true; + // convert to simple loop // do not generate variable and if block if condition is always true @@ -102,7 +108,11 @@ public class Vala.DoStatement : CodeNode, Statement { var parent_block = (Block) parent_node; parent_block.replace_statement (this, loop); - return loop.check (context); + if (!loop.check (context)) { + error = true; + } + + return !error; } var block = new Block (source_reference); @@ -127,6 +137,10 @@ public class Vala.DoStatement : CodeNode, Statement { var parent_block = (Block) parent_node; parent_block.replace_statement (this, block); - return block.check (context); + if (!block.check (context)) { + error = true; + } + + return !error; } } diff --git a/vala/valaforstatement.vala b/vala/valaforstatement.vala index bd3229ad5..aa70cee0b 100644 --- a/vala/valaforstatement.vala +++ b/vala/valaforstatement.vala @@ -165,6 +165,12 @@ public class Vala.ForStatement : CodeNode, Statement { } public override bool check (CodeContext context) { + if (checked) { + return !error; + } + + checked = true; + // convert to simple loop var block = new Block (source_reference); @@ -206,6 +212,10 @@ public class Vala.ForStatement : CodeNode, Statement { var parent_block = (Block) parent_node; parent_block.replace_statement (this, block); - return block.check (context); + if (!block.check (context)) { + error = true; + } + + return !error; } } diff --git a/vala/valaswitchlabel.vala b/vala/valaswitchlabel.vala index 8d4444c7f..3626c1e5f 100644 --- a/vala/valaswitchlabel.vala +++ b/vala/valaswitchlabel.vala @@ -79,6 +79,12 @@ public class Vala.SwitchLabel : CodeNode { } public override bool check (CodeContext context) { + if (checked) { + return !error; + } + + checked = true; + if (expression != null) { var switch_statement = (SwitchStatement) section.parent_node; @@ -95,7 +101,10 @@ public class Vala.SwitchLabel : CodeNode { } } - expression.check (context); + if (!expression.check (context)) { + error = true; + return false; + } if (!expression.is_constant ()) { error = true; diff --git a/vala/valawhilestatement.vala b/vala/valawhilestatement.vala index 0b0a1b1bb..a15b1abe8 100644 --- a/vala/valawhilestatement.vala +++ b/vala/valawhilestatement.vala @@ -98,6 +98,12 @@ public class Vala.WhileStatement : CodeNode, Statement { } public override bool check (CodeContext context) { + if (checked) { + return !error; + } + + checked = true; + // convert to simple loop if (always_true (condition)) { @@ -118,7 +124,11 @@ public class Vala.WhileStatement : CodeNode, Statement { var parent_block = (Block) parent_node; parent_block.replace_statement (this, loop); - return loop.check (context); + if (!loop.check (context)) { + error = true; + } + + return !error; } }