From da51df84b3b3214cb417c2efa145b0521fe67f97 Mon Sep 17 00:00:00 2001 From: fuhsnn <66062782+fuhsnn@users.noreply.github.com> Date: Mon, 30 Dec 2024 01:57:56 +0800 Subject: [PATCH] test --- codegen.c | 3 ++- parse.c | 3 ++- preprocess.c | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/codegen.c b/codegen.c index 30ac108..c4dae9e 100644 --- a/codegen.c +++ b/codegen.c @@ -1180,11 +1180,12 @@ static int calling_convention(Obj *var, int *gp_count, int *fp_count, int *stack int gp = *gp_count, fp = *fp_count; for (; var; var = var->param_next) { Type *ty = var->ty; - assert(ty->size != 0); switch (ty->kind) { case TY_STRUCT: case TY_UNION: + if (ty->size == 0) + continue; if (ty->size <= 16) { int fp_inc = has_flonum1(ty) + (ty->size > 8 && has_flonum2(ty)); int gp_inc = !has_flonum1(ty) + (ty->size > 8 && !has_flonum2(ty)); diff --git a/parse.c b/parse.c index 3da1900..9ba9870 100644 --- a/parse.c +++ b/parse.c @@ -4085,7 +4085,8 @@ static Node *primary(Token **rest, Token *tok) { if (equal(tok, "sizeof")) { Type *ty; - if (equal(tok->next, "(") && is_typename(tok->next->next)) { + if (equal(tok->next, "(") && is_typename(tok->next->next) && + !equal(skip_paren(tok->next->next), "{")) { ty = typename(&tok, tok->next->next); *rest = skip(tok, ")"); } else { diff --git a/preprocess.c b/preprocess.c index f32677b..4e0f2c8 100644 --- a/preprocess.c +++ b/preprocess.c @@ -1191,7 +1191,9 @@ static Token *directives(Token **cur, Token *start, bool is_root) { char *filename = read_include_filename(split_line(&tok, tok->next), &is_dquote); int incl_no = -1; char *path = search_include_paths2(filename, start, is_dquote, &incl_no); - return include_file(tok, path ? path : filename, start->next->next, &incl_no); + if (!path) + error_tok(start->next->next, "%s: cannot open file: %s", filename, strerror(errno)); + return include_file(tok, path, start->next->next, &incl_no); } if (equal(tok, "include_next")) {