duskos

dusk os fork
git clone git://git.alexwennerberg.com/duskos
Log | Files | Refs | README | LICENSE

commit 3556a8d786a9e2c5ff23e0fe36023b096c313794
parent 32affb5f76e5c0388dcf1fb22d0b06cac334d4a2
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Sun,  2 Apr 2023 10:23:41 -0400

halcc: fix assign+dereference bug

Diffstat:
Mfs/comp/c/egen.fs | 2+-
Mfs/tests/comp/c/cc.fs | 1+
Mfs/tests/comp/c/test.c | 6++++++
3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/fs/comp/c/egen.fs b/fs/comp/c/egen.fs @@ -75,7 +75,7 @@ UOPSCNT wordtbl uoptbl ( res -- res ) _prep -, r> ?dup if over Result :/n then dup Result :toint ; : _prep ( left right -- res halop ) - Result :?freeCurrentW over Result :hal# swap Result :?>W$ <>) ; + Result :?freeCurrentW Result :?>W$ dup Result :hal# <>) ; : _=, _prep @, ; : _-=, _prep -, ; : _*=, _prep *, ; : _/=, _prep /, ; : _%=, _prep %, ; : _&=, _prep and, ; : _^=, _prep xor, ; : _|=, _prep or, ; diff --git a/fs/tests/comp/c/cc.fs b/fs/tests/comp/c/cc.fs @@ -117,6 +117,7 @@ to' myval ptrari4 # to' myval unaryop2 to' myval #eq myval 42 #eq ptrari5 6 + @ 42 #eq +123 456 ptrari6 123 456 + #eq funcall1 138 #eq 42 funcall2 85 #eq 41 switch1 41 #eq diff --git a/fs/tests/comp/c/test.c b/fs/tests/comp/c/test.c @@ -498,6 +498,12 @@ SixBytes* ptrari5() { globstructarray[1].foo = 42; return globstructarray; } +// Assignment of a derfeferenced pointer into another dereferenced pointer +int ptrari6(int a, int b) { + int *pa = &a, *pb = &b; + *pa += *pb; + return *pa; +} // unary op, apart from ++ and --, *don't* modify their target. int unaryop1(int n) { !n;