| author | |
| committer | |
| log | 88c5e2a96e09270a2ec3045639e7cab3712f5291 |
| tree | 2027db8ab217cf5063719e1536dda49884c1621f |
| parent | 5ba143e7e3418719cc3c4acba9c9bfeea9803e57 |
| signature | Commit is signed but in an unrecognized format. |
5 files changed, 25 insertions(+), 1 deletions(-)
src-self-hosted/clang.zig+2| ... | @@ -832,6 +832,8 @@ pub extern fn ZigClangFunctionDecl_hasBody(self: *const ZigClangFunctionDecl) bo | ... | @@ -832,6 +832,8 @@ pub extern fn ZigClangFunctionDecl_hasBody(self: *const ZigClangFunctionDecl) bo |
| 832 | pub extern fn ZigClangFunctionDecl_getStorageClass(self: *const ZigClangFunctionDecl) ZigClangStorageClass; | 832 | pub extern fn ZigClangFunctionDecl_getStorageClass(self: *const ZigClangFunctionDecl) ZigClangStorageClass; |
| 833 | pub extern fn ZigClangFunctionDecl_getParamDecl(self: *const ZigClangFunctionDecl, i: c_uint) *const struct_ZigClangParmVarDecl; | 833 | pub extern fn ZigClangFunctionDecl_getParamDecl(self: *const ZigClangFunctionDecl, i: c_uint) *const struct_ZigClangParmVarDecl; |
| 834 | pub extern fn ZigClangFunctionDecl_getBody(self: *const ZigClangFunctionDecl) *const struct_ZigClangStmt; | 834 | pub extern fn ZigClangFunctionDecl_getBody(self: *const ZigClangFunctionDecl) *const struct_ZigClangStmt; |
| 835 | pub extern fn ZigClangFunctionDecl_doesDeclarationForceExternallyVisibleDefinition(self: *const ZigClangFunctionDecl) bool; | ||
| 836 | pub extern fn ZigClangFunctionDecl_isInlineSpecified(self: *const ZigClangFunctionDecl) bool; | ||
| 835 | 837 | ||
| 836 | pub extern fn ZigClangBuiltinType_getKind(self: *const struct_ZigClangBuiltinType) ZigClangBuiltinTypeKind; | 838 | pub extern fn ZigClangBuiltinType_getKind(self: *const struct_ZigClangBuiltinType) ZigClangBuiltinTypeKind; |
| 837 | 839 |
src-self-hosted/translate_c.zig+1-1| ... | @@ -423,7 +423,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const ZigClangFunctionDecl) Error!void { | ... | @@ -423,7 +423,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const ZigClangFunctionDecl) Error!void { |
| 423 | .has_body = has_body, | 423 | .has_body = has_body, |
| 424 | .storage_class = storage_class, | 424 | .storage_class = storage_class, |
| 425 | .is_export = switch (storage_class) { | 425 | .is_export = switch (storage_class) { |
| 426 | .None => has_body, | 426 | .None => has_body and !ZigClangFunctionDecl_isInlineSpecified(fn_decl), |
| 427 | .Extern, .Static => false, | 427 | .Extern, .Static => false, |
| 428 | .PrivateExtern => return failDecl(c, fn_decl_loc, fn_name, "unsupported storage class: private extern", .{}), | 428 | .PrivateExtern => return failDecl(c, fn_decl_loc, fn_name, "unsupported storage class: private extern", .{}), |
| 429 | .Auto => unreachable, // Not legal on functions | 429 | .Auto => unreachable, // Not legal on functions |
src/zig_clang.cpp+10| ... | @@ -1686,6 +1686,16 @@ const struct ZigClangStmt *ZigClangFunctionDecl_getBody(const struct ZigClangFun | ... | @@ -1686,6 +1686,16 @@ const struct ZigClangStmt *ZigClangFunctionDecl_getBody(const struct ZigClangFun |
| 1686 | return reinterpret_cast<const ZigClangStmt *>(stmt); | 1686 | return reinterpret_cast<const ZigClangStmt *>(stmt); |
| 1687 | } | 1687 | } |
| 1688 | 1688 | ||
| 1689 | bool ZigClangFunctionDecl_doesDeclarationForceExternallyVisibleDefinition(const struct ZigClangFunctionDecl *self) { | ||
| 1690 | auto casted = reinterpret_cast<const clang::FunctionDecl *>(self); | ||
| 1691 | return casted->doesDeclarationForceExternallyVisibleDefinition(); | ||
| 1692 | } | ||
| 1693 | |||
| 1694 | bool ZigClangFunctionDecl_isInlineSpecified(const struct ZigClangFunctionDecl *self) { | ||
| 1695 | auto casted = reinterpret_cast<const clang::FunctionDecl *>(self); | ||
| 1696 | return casted->isInlineSpecified(); | ||
| 1697 | } | ||
| 1698 | |||
| 1689 | const ZigClangTypedefNameDecl *ZigClangTypedefType_getDecl(const ZigClangTypedefType *self) { | 1699 | const ZigClangTypedefNameDecl *ZigClangTypedefType_getDecl(const ZigClangTypedefType *self) { |
| 1690 | auto casted = reinterpret_cast<const clang::TypedefType *>(self); | 1700 | auto casted = reinterpret_cast<const clang::TypedefType *>(self); |
| 1691 | const clang::TypedefNameDecl *name_decl = casted->getDecl(); | 1701 | const clang::TypedefNameDecl *name_decl = casted->getDecl(); |
src/zig_clang.h+2| ... | @@ -873,6 +873,8 @@ ZIG_EXTERN_C bool ZigClangFunctionDecl_hasBody(const struct ZigClangFunctionDecl | ... | @@ -873,6 +873,8 @@ ZIG_EXTERN_C bool ZigClangFunctionDecl_hasBody(const struct ZigClangFunctionDecl |
| 873 | ZIG_EXTERN_C enum ZigClangStorageClass ZigClangFunctionDecl_getStorageClass(const struct ZigClangFunctionDecl *); | 873 | ZIG_EXTERN_C enum ZigClangStorageClass ZigClangFunctionDecl_getStorageClass(const struct ZigClangFunctionDecl *); |
| 874 | ZIG_EXTERN_C const struct ZigClangParmVarDecl *ZigClangFunctionDecl_getParamDecl(const struct ZigClangFunctionDecl *, unsigned i); | 874 | ZIG_EXTERN_C const struct ZigClangParmVarDecl *ZigClangFunctionDecl_getParamDecl(const struct ZigClangFunctionDecl *, unsigned i); |
| 875 | ZIG_EXTERN_C const struct ZigClangStmt *ZigClangFunctionDecl_getBody(const struct ZigClangFunctionDecl *); | 875 | ZIG_EXTERN_C const struct ZigClangStmt *ZigClangFunctionDecl_getBody(const struct ZigClangFunctionDecl *); |
| 876 | ZIG_EXTERN_C bool ZigClangFunctionDecl_doesDeclarationForceExternallyVisibleDefinition(const struct ZigClangFunctionDecl *); | ||
| 877 | ZIG_EXTERN_C bool ZigClangFunctionDecl_isInlineSpecified(const struct ZigClangFunctionDecl *); | ||
| 876 | 878 | ||
| 877 | ZIG_EXTERN_C bool ZigClangRecordDecl_isUnion(const struct ZigClangRecordDecl *record_decl); | 879 | ZIG_EXTERN_C bool ZigClangRecordDecl_isUnion(const struct ZigClangRecordDecl *record_decl); |
| 878 | ZIG_EXTERN_C bool ZigClangRecordDecl_isStruct(const struct ZigClangRecordDecl *record_decl); | 880 | ZIG_EXTERN_C bool ZigClangRecordDecl_isStruct(const struct ZigClangRecordDecl *record_decl); |
test/translate_c.zig+10| ... | @@ -2302,4 +2302,14 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2302,4 +2302,14 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2302 | , | 2302 | , |
| 2303 | \\pub const bar = 4; | 2303 | \\pub const bar = 4; |
| 2304 | }); | 2304 | }); |
| 2305 | |||
| 2306 | cases.add("don't export inline functions", | ||
| 2307 | \\inline void a(void) {} | ||
| 2308 | \\static void b(void) {} | ||
| 2309 | \\void c(void) {} | ||
| 2310 | , &[_][]const u8{ | ||
| 2311 | \\pub fn a() void {} | ||
| 2312 | \\pub fn b() void {} | ||
| 2313 | \\pub export fn c() void {} | ||
| 2314 | }); | ||
| 2305 | } | 2315 | } |