fixed cast parsing bug

i hope casts weren't at a different precedence level for a reason
This commit is contained in:
pommicket 2022-02-02 23:05:33 -05:00
parent be9a3b4bd5
commit 04c5e1af8a
3 changed files with 3 additions and 8 deletions

View file

@ -25,8 +25,7 @@
; b << >> ; b << >>
; c + - ; c + -
; d * / % ; d * / %
; d8 cast ; e casts, sizeof, unary prefixes ++ -- & * + - ~ !
; e sizeof, unary prefixes ++ -- & * + - ~ !
; f . -> () [] postfix ++ -- ; f . -> () [] postfix ++ --
; highest ; highest
; NB: for equal precedence, operators are applied left-to-right except for assignment operators (precedence 2) ; NB: for equal precedence, operators are applied left-to-right except for assignment operators (precedence 2)

View file

@ -46,7 +46,7 @@
/* long b; */ /* long b; */
/* } x1[] = {0x1234567890, 1ul<<60|1ul<<3, 77}; */ /* } x1[] = {0x1234567890, 1ul<<60|1ul<<3, 77}; */
/* int y1 = 0x12345678; */ /* int y1 = 0x12345678; */
typedef int R[*(int*)3]; typedef int R[sizeof *(int*)"hello"];
/* struct { */ /* struct { */
/* int x[2], y; */ /* int x[2], y; */

View file

@ -1619,11 +1619,7 @@ function parse_expression
*4type = type_create_pointer(*4a) *4type = type_create_pointer(*4a)
return out return out
:unary_dereference :unary_dereference
print_type(*4a)
putc(10)
type_decay_array_to_pointer(*4a) 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) ; @TODO : dereferencing a function (annoyingly, p is the same as *p for function pointers)
if *1p != TYPE_POINTER goto unary_bad_type if *1p != TYPE_POINTER goto unary_bad_type
*4type = *4a + 1 *4type = *4a + 1
@ -2574,7 +2570,7 @@ function operator_precedence
token += 16 token += 16
b = token_is_type(token) b = token_is_type(token)
if b == 0 goto return_0xffff if b == 0 goto return_0xffff
goto return_0xd8 ; it's a cast goto return_0xe0 ; it's a cast
:figre_out_rparen_arity :figre_out_rparen_arity
; given that the token before this one is a right-parenthesis, figure out if ; given that the token before this one is a right-parenthesis, figure out if