sym: allow auto variables to be assigned expressions
authorAlan Cox <alan@linux.intel.com>
Thu, 16 Nov 2017 23:22:10 +0000 (23:22 +0000)
committerAlan Cox <alan@linux.intel.com>
Thu, 16 Nov 2017 23:22:10 +0000 (23:22 +0000)
Nice trivial change. Fixing statics is a different ball game alas.

Applications/SmallC/sym.c

index 50744aa..9b896a6 100644 (file)
@@ -292,7 +292,12 @@ void declare_local(int typ, int stclass, int otag) {
                     break;
                 }
             }
-            stkp = gen_defer_modify_stack(stkp - k);
+            if (match("=")) {
+                gen_modify_stack(stkp);
+                expression(0);
+                gen_push(0);
+            } else
+                stkp = gen_defer_modify_stack(stkp - k);
             add_local(sname, j, typ, stkp, AUTO);
             break;
         }