[vala] Do not generate C code for unreachable Vala code
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] Do not generate C code for unreachable Vala code
- Date: Mon, 22 Mar 2010 22:00:44 +0000 (UTC)
commit cd098ddcda9464d2e37562a2117ec49d959ea11f
Author: Jürg Billeter <j bitron ch>
Date: Mon Mar 22 22:57:47 2010 +0100
Do not generate C code for unreachable Vala code
Fixes bug 598190.
codegen/valaccodebasemodule.vala | 2 +-
vala/valacodenode.vala | 6 ++++--
vala/valaflowanalyzer.vala | 1 +
3 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 83aafae..cb0cd24 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -1897,7 +1897,7 @@ internal class Vala.CCodeBaseModule : CCodeModule {
}
foreach (CodeNode stmt in b.get_statements ()) {
- if (stmt.error) {
+ if (stmt.error || stmt.unreachable) {
continue;
}
diff --git a/vala/valacodenode.vala b/vala/valacodenode.vala
index feaf60a..f3ae4a4 100644
--- a/vala/valacodenode.vala
+++ b/vala/valacodenode.vala
@@ -1,6 +1,6 @@
/* valacodenode.vala
*
- * Copyright (C) 2006-2009 Jürg Billeter
+ * Copyright (C) 2006-2010 Jürg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -39,7 +39,9 @@ public abstract class Vala.CodeNode {
* been written.
*/
public SourceReference? source_reference { get; set; }
-
+
+ public bool unreachable { get; set; }
+
/**
* Contains all attributes that have been specified for this code node.
*/
diff --git a/vala/valaflowanalyzer.vala b/vala/valaflowanalyzer.vala
index af0e946..ff5f255 100644
--- a/vala/valaflowanalyzer.vala
+++ b/vala/valaflowanalyzer.vala
@@ -1023,6 +1023,7 @@ public class Vala.FlowAnalyzer : CodeVisitor {
private bool unreachable (CodeNode node) {
if (current_block == null) {
+ node.unreachable = true;
if (!unreachable_reported) {
Report.warning (node.source_reference, "unreachable code detected");
unreachable_reported = true;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]