diff options
| author | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-27 12:33:58 +0000 |
|---|---|---|
| committer | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-27 12:33:58 +0000 |
| commit | a3b85c9737b509fd2a792b65aa2365b9bcc9fe6a (patch) | |
| tree | 829577514fc4f0436e61c523eb1082afe891bcbf /src/codegen | |
| parent | b40fc44f799b4810981d37d9030ca69d768cc0b2 (diff) | |
Support for more attributes
Diffstat (limited to 'src/codegen')
| -rw-r--r-- | src/codegen/codegen_decl.c | 6 | ||||
| -rw-r--r-- | src/codegen/codegen_stmt.c | 3 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/codegen/codegen_decl.c b/src/codegen/codegen_decl.c index aecf45e..eb53911 100644 --- a/src/codegen/codegen_decl.c +++ b/src/codegen/codegen_decl.c @@ -380,10 +380,14 @@ void emit_struct_defs(ParserContext *ctx, ASTNode *node, FILE *out) { fprintf(out, " __attribute__((packed))"); } - else if (node->strct.align) + if (node->strct.align) { fprintf(out, " __attribute__((aligned(%d)))", node->strct.align); } + if (node->strct.is_export) + { + fprintf(out, " __attribute__((visibility(\"default\")))"); + } fprintf(out, ";\n\n"); } else if (node->type == NODE_ENUM) diff --git a/src/codegen/codegen_stmt.c b/src/codegen/codegen_stmt.c index 1679d97..c823b13 100644 --- a/src/codegen/codegen_stmt.c +++ b/src/codegen/codegen_stmt.c @@ -653,7 +653,7 @@ void codegen_node_single(ParserContext *ctx, ASTNode *node, FILE *out) int has_attrs = node->func.constructor || node->func.destructor || node->func.noinline || node->func.unused || node->func.weak || node->func.cold || node->func.hot || node->func.noreturn || - node->func.pure || node->func.section; + node->func.pure || node->func.section || node->func.is_export; if (has_attrs) { fprintf(out, "__attribute__(("); @@ -675,6 +675,7 @@ void codegen_node_single(ParserContext *ctx, ASTNode *node, FILE *out) EMIT_ATTR(node->func.hot, "hot"); EMIT_ATTR(node->func.noreturn, "noreturn"); EMIT_ATTR(node->func.pure, "pure"); + EMIT_ATTR(node->func.is_export, "visibility(\"default\")"); if (node->func.section) { if (!first) |
