]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Do not generate unnecessary error check after throw statement
authorJürg Billeter <j@bitron.ch>
Wed, 27 Jan 2010 17:44:36 +0000 (18:44 +0100)
committerJürg Billeter <j@bitron.ch>
Wed, 27 Jan 2010 17:44:36 +0000 (18:44 +0100)
Fixes bug 589942.

codegen/valagerrormodule.vala

index a031616cc7b4a1df755559df9597b2f2d113e245..ef25c067a87e4c4b6fd504fe7ada6470791a638e 100644 (file)
@@ -283,8 +283,14 @@ internal class Vala.GErrorModule : CCodeDelegateModule {
                        cerror_handler = uncaught_error_statement (inner_error);
                }
 
-               var ccond = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, inner_error, new CCodeConstant ("NULL"));
-               cfrag.append (new CCodeIfStatement (ccond, cerror_handler));
+               if (node is ThrowStatement) {
+                       // inner_error is always set, avoid unnecessary if statement
+                       // eliminates C warnings
+                       cfrag.append (cerror_handler);
+               } else {
+                       var ccond = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, inner_error, new CCodeConstant ("NULL"));
+                       cfrag.append (new CCodeIfStatement (ccond, cerror_handler));
+               }
        }
 
        public override void visit_try_statement (TryStatement stmt) {