Fix unhandled AST_EXPR_EXT_SIZEOF Error

This commit is contained in:
BrainStackOverFlow 2025-07-17 11:00:59 +03:00
parent f3b6f81ef5
commit 20197ee0bc
3 changed files with 13 additions and 1 deletions

View File

@ -396,6 +396,10 @@ static void ast_usedef_pass(AST *tlc, AST *a, AST *wholestmt) {
if(a->stmtReturn.val) {
ast_usedef_pass(tlc, a->stmtReturn.val, wholestmt);
}
} else if (a->nodeKind == AST_EXPR_EXT_SIZEOF) {
if (a->exprExtSizeOf.ofExpr) {
ast_usedef_pass(tlc, a->exprExtSizeOf.ofExpr, wholestmt);
}
} else {
stahp_node(a, "ast_usedef_pass: unhandled %s", AST_KIND_STR[a->nodeKind]);
}

View File

@ -7,6 +7,7 @@
#include<stdlib.h>
#include<stdarg.h>
#include<stdio.h>
#include <string.h>
inline static size_t djb2(const char *str) {
size_t hash = 5381;
@ -54,4 +55,11 @@ __attribute__((format(printf, 1, 2))) static inline char *malp(const char *fmt,
return str;
}
inline static int is_str_equal_check_null(const char *s1, const char *s2) {
if (!s1 || !s2) {
return 0;
}
return !strcmp(s1, s2);
}
#endif

View File

@ -333,7 +333,7 @@ void cg_chunk(CGState *cg, AST *a) {
} else if(s->nodeKind == AST_STMT_ASSIGN) {
if(s->stmtAssign.to && is_xop(s->stmtAssign.what) == XOP_NOT_MEM && is_xop(s->stmtAssign.to) == XOP_NOT_MEM && !strcmp(xop(cg->tlc, s->stmtAssign.what), xop(cg->tlc, s->stmtAssign.to))) {
if(s->stmtAssign.to && is_xop(s->stmtAssign.what) == XOP_NOT_MEM && is_xop(s->stmtAssign.to) == XOP_NOT_MEM && is_str_equal_check_null(xop(cg->tlc, s->stmtAssign.what), xop(cg->tlc, s->stmtAssign.to))) {
// It's a noop
} else if(s->stmtAssign.to) {
if(x86_imul_supported() && s->stmtAssign.to->nodeKind == AST_EXPR_BINARY_OP && s->stmtAssign.to->exprBinOp.operator == BINOP_MUL) {