Added support for stack allocation. Check for NULL before calling memory checker.
[repair.git] / Repair / RepairCompiler / MCC / IR / VarExpr.java
index 2a71140550858765a4870eb87a057c66dd5a5c5e..51e916a95e2757c33536d7f4c86911b2f8d23ca6 100755 (executable)
@@ -83,6 +83,8 @@ public class VarExpr extends Expr {
                           " = (" + vd.getType().getGenerateType().getSafeSymbol() + ") " + vd.getSafeSymbol() + "; //varexpr");
        if (vd.isGlobal() && (DOTYPECHECKS||DOMEMCHECKS) && (td instanceof StructureTypeDescriptor)) {
            VarDescriptor typevar=VarDescriptor.makeNew("typechecks");
+           writer.outputline("if ("+dest.getSafeSymbol()+")");
+           writer.startblock();
            if (DOTYPECHECKS)
                writer.outputline("bool "+typevar.getSafeSymbol()+"=assertvalidtype(" + dest.getSafeSymbol() + ", " + td.getId() + ");"); 
            else
@@ -93,6 +95,7 @@ public class VarExpr extends Expr {
            if (DONULL)
                writer.outputline(vd.getSafeSymbol()+"=0;");
            writer.endblock();
+           writer.endblock();
        }
     }