From 1b02f8bcfe4e49a18f5ddaefc54bf4556424a941 Mon Sep 17 00:00:00 2001 From: kumachan-mis <29433058+kumachan-mis@users.noreply.github.com> Date: Sat, 7 Oct 2023 07:54:16 +0000 Subject: [PATCH] use convert_to_ptr --- src/resolver/expression.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/resolver/expression.c b/src/resolver/expression.c index 2fcc4a1f..8853fe50 100644 --- a/src/resolver/expression.c +++ b/src/resolver/expression.c @@ -1292,39 +1292,36 @@ ResolverReturn* resolve_member_like_expr(Resolver* resolver) { ResolverReturn* resolve_incdec_expr(Resolver* resolver, SrtType srt_type, char* op) { Srt* srt = NULL; DType* dtype = NULL; - Srt* child_srt = NULL; Vector* errs = NULL; Error* err = NULL; Ast* ast = resolver->ast; resolver->ast = vector_at(ast->children, 0); - resolverret_assign(&child_srt, &errs, resolve_expr(resolver)); + resolverret_assign(&srt, &errs, resolve_expr(resolver)); resolver->ast = ast; if (errs != NULL) { return new_resolverret_errors(errs); } - if (!srt_ismodifiable(child_srt)) { + if (!srt_ismodifiable(srt)) { errs = new_vector(&t_error); err = new_error("operand of %s is not modifiable", op); vector_push(errs, err); - delete_srt(child_srt); + delete_srt(srt); return new_resolverret_errors(errs); } - if (!dtype_isinteger(child_srt->dtype) && child_srt->dtype->type != DTYPE_POINTER) { + if (!dtype_isinteger(srt->dtype) && srt->dtype->type != DTYPE_POINTER) { errs = new_vector(&t_error); err = new_error("operand of %s should be either integer or pointer", op); vector_push(errs, err); - delete_srt(child_srt); + delete_srt(srt); return new_resolverret_errors(errs); } - dtype = new_pointer_dtype(dtype_copy(child_srt->dtype)); - child_srt = new_dtyped_srt(SRT_ADDR_EXPR, dtype, 1, child_srt); - - dtype = dtype_copy(dtype->dpointer->to_dtype); - srt = new_dtyped_srt(srt_type, dtype, 1, child_srt); + dtype = dtype_copy(srt->dtype); + srt = convert_to_ptr(srt); + srt = new_dtyped_srt(srt_type, dtype, 1, srt); return new_resolverret(srt); }