diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-03-28 15:51:15 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-03-28 15:51:15 -0400 |
| commit | ed6418902c6a9fe444b3c3b242bc7eb3f6c9471e (patch) | |
| tree | 34584dc655a8f8b601219bb0c54aef906fd5619d | |
| parent | 7d80ca48d458beffd75522605b510d209ccb5328 (diff) | |
Don't force inline C code to use ({...})
| -rw-r--r-- | src/compile.c | 7 | ||||
| -rw-r--r-- | src/parse.c | 2 |
2 files changed, 4 insertions, 5 deletions
diff --git a/src/compile.c b/src/compile.c index f9db7849..e939d2b7 100644 --- a/src/compile.c +++ b/src/compile.c @@ -1754,10 +1754,7 @@ static CORD _compile_statement(env_t *env, ast_t *ast) case Extern: return CORD_EMPTY; case InlineCCode: { auto inline_code = Match(ast, InlineCCode); - if (inline_code->type) - return CORD_all("({ ", inline_code->code, "; })"); - else - return inline_code->code; + return inline_code->code; } case Use: { auto use = Match(ast, Use); @@ -3832,7 +3829,7 @@ CORD compile(env_t *env, ast_t *ast) if (t->tag == VoidType) return CORD_all("{\n", Match(ast, InlineCCode)->code, "\n}"); else - return CORD_all("({ ", Match(ast, InlineCCode)->code, "; })"); + return Match(ast, InlineCCode)->code; } case Use: code_err(ast, "Compiling 'use' as expression!"); case Defer: code_err(ast, "Compiling 'defer' as expression!"); diff --git a/src/parse.c b/src/parse.c index de52f765..ff46fd03 100644 --- a/src/parse.c +++ b/src/parse.c @@ -2401,6 +2401,8 @@ PARSER(parse_inline_c) { parser_err(ctx, start, start+1, "I couldn't find the closing '}' for this inline C code"); CORD c_code = GC_strndup(c_code_start, (size_t)((pos-1) - c_code_start)); + if (type) + c_code = CORD_all("({ ", c_code, "; })"); return NewAST(ctx->file, start, pos, InlineCCode, .code=c_code, .type_ast=type); } |
