]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Do not generate C code for unreachable Vala code
authorJürg Billeter <j@bitron.ch>
Mon, 22 Mar 2010 21:57:47 +0000 (22:57 +0100)
committerJürg Billeter <j@bitron.ch>
Mon, 22 Mar 2010 21:57:47 +0000 (22:57 +0100)
Fixes bug 598190.

codegen/valaccodebasemodule.vala
vala/valacodenode.vala
vala/valaflowanalyzer.vala

index 83aafae9d84be0bc9b582577b4d17ee07146ce69..cb0cd249be4358f1a03a0cfa4327bd42bf542671 100644 (file)
@@ -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;
                        }
                        
index feaf60ad3e3b11ac2ef4ed925ac502b6bd424a22..f3ae4a4b8b17df4fa462d285660a147176716e5a 100644 (file)
@@ -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.
         */
index af0e946497a2ba5263a21f51b12465e0f70e971e..ff5f255dbd03b76025ce19b23e59e37a6f17cc77 100644 (file)
@@ -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;