summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2022-02-02 23:05:33 -0500
committerpommicket <pommicket@gmail.com>2022-02-02 23:05:33 -0500
commit04c5e1af8a03cb943acbebcb7460193c8bd37a26 (patch)
tree3bf8bbf8859d35726f3464f70f471f565b651809
parentbe9a3b4bd5f7e9a44c16d942e2f7050927d0e277 (diff)
fixed cast parsing bug
i hope casts weren't at a different precedence level for a reason
-rw-r--r--05/constants.b3
-rw-r--r--05/main.c2
-rw-r--r--05/parse.b6
3 files changed, 3 insertions, 8 deletions
diff --git a/05/constants.b b/05/constants.b
index 1ba49fb..3d0e30a 100644
--- a/05/constants.b
+++ b/05/constants.b
@@ -25,8 +25,7 @@
; b << >>
; c + -
; d * / %
-; d8 cast
-; e sizeof, unary prefixes ++ -- & * + - ~ !
+; e casts, sizeof, unary prefixes ++ -- & * + - ~ !
; f . -> () [] postfix ++ --
; highest
; NB: for equal precedence, operators are applied left-to-right except for assignment operators (precedence 2)
diff --git a/05/main.c b/05/main.c
index 008efd1..34be337 100644
--- a/05/main.c
+++ b/05/main.c
@@ -46,7 +46,7 @@
/* long b; */
/* } x1[] = {0x1234567890, 1ul<<60|1ul<<3, 77}; */
/* int y1 = 0x12345678; */
-typedef int R[*(int*)3];
+typedef int R[sizeof *(int*)"hello"];
/* struct { */
/* int x[2], y; */
diff --git a/05/parse.b b/05/parse.b
index 41ee6fd..18dbcb6 100644
--- a/05/parse.b
+++ b/05/parse.b
@@ -1619,11 +1619,7 @@ function parse_expression
*4type = type_create_pointer(*4a)
return out
:unary_dereference
- print_type(*4a)
- putc(10)
type_decay_array_to_pointer(*4a)
- print_type(*4a)
- putc(10)
; @TODO : dereferencing a function (annoyingly, p is the same as *p for function pointers)
if *1p != TYPE_POINTER goto unary_bad_type
*4type = *4a + 1
@@ -2574,7 +2570,7 @@ function operator_precedence
token += 16
b = token_is_type(token)
if b == 0 goto return_0xffff
- goto return_0xd8 ; it's a cast
+ goto return_0xe0 ; it's a cast
:figre_out_rparen_arity
; given that the token before this one is a right-parenthesis, figure out if