scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 6c203246f0b7e3fa9ac8748b14e50e4381928d1a
parent 9ab6169607b9f33078f602fba25f3fa8de6aa762
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 26 Dec 2024 22:05:39 +0100

cc2: Fix prog when deleting at the beginning

Prog was assigned to NULL but we have to use the value of
next, otherwise we lose the remaining nodes.

Diffstat:
Msrc/cmd/scc-cc/cc2/cc2.h | 1+
Msrc/cmd/scc-cc/cc2/code.c | 3+--
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/cmd/scc-cc/cc2/cc2.h b/src/cmd/scc-cc/cc2/cc2.h @@ -237,6 +237,7 @@ extern Node *label2node(Node *np, Symbol *sym); extern Node *constnode(Node *np, TUINT n, Type *tp); extern Node *tmpnode(Type *); extern Node *idxnode(Node *, long); +extern void delcode(void); extern Symbol *newlabel(void); extern void pprint(char *s); extern void deftype(Type *); diff --git a/src/cmd/scc-cc/cc2/code.c b/src/cmd/scc-cc/cc2/code.c @@ -211,8 +211,7 @@ delcode(void) free(pc); if (!prev) { - pc = next; - prog = NULL; + prog = pc = next; } else { pc = prev; prev->next = next;