aboutsummaryrefslogtreecommitdiff
path: root/src/translate_c.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/translate_c.cpp')
-rw-r--r--src/translate_c.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/translate_c.cpp b/src/translate_c.cpp
index 77afc38a51..eba594e085 100644
--- a/src/translate_c.cpp
+++ b/src/translate_c.cpp
@@ -73,6 +73,7 @@ struct Context {
ImportTableEntry *import;
ZigList<ErrorMsg *> *errors;
VisibMod visib_mod;
+ bool want_export;
AstNode *root;
HashMap<const void *, AstNode *, ptr_hash, ptr_eq> decl_table;
HashMap<Buf *, AstNode *, buf_hash, buf_eql_buf> macro_table;
@@ -3250,8 +3251,8 @@ static void visit_fn_decl(Context *c, const FunctionDecl *fn_decl) {
StorageClass sc = fn_decl->getStorageClass();
if (sc == SC_None) {
- // TODO add export decl
proto_node->data.fn_proto.visib_mod = c->visib_mod;
+ proto_node->data.fn_proto.is_export = fn_decl->hasBody() ? c->want_export : false;
} else if (sc == SC_Extern || sc == SC_Static) {
proto_node->data.fn_proto.visib_mod = c->visib_mod;
} else if (sc == SC_PrivateExtern) {
@@ -4274,8 +4275,10 @@ int parse_h_file(ImportTableEntry *import, ZigList<ErrorMsg *> *errors, const ch
c->errors = errors;
if (buf_ends_with_str(buf_create_from_str(target_file), ".h")) {
c->visib_mod = VisibModPub;
+ c->want_export = false;
} else {
c->visib_mod = VisibModPub;
+ c->want_export = true;
}
c->decl_table.init(8);
c->macro_table.init(8);