translate-c: don't export inline functions
This commit is contained in:
parent
5ba143e7e3
commit
88c5e2a96e
@ -832,6 +832,8 @@ pub extern fn ZigClangFunctionDecl_hasBody(self: *const ZigClangFunctionDecl) bo
|
||||
pub extern fn ZigClangFunctionDecl_getStorageClass(self: *const ZigClangFunctionDecl) ZigClangStorageClass;
|
||||
pub extern fn ZigClangFunctionDecl_getParamDecl(self: *const ZigClangFunctionDecl, i: c_uint) *const struct_ZigClangParmVarDecl;
|
||||
pub extern fn ZigClangFunctionDecl_getBody(self: *const ZigClangFunctionDecl) *const struct_ZigClangStmt;
|
||||
pub extern fn ZigClangFunctionDecl_doesDeclarationForceExternallyVisibleDefinition(self: *const ZigClangFunctionDecl) bool;
|
||||
pub extern fn ZigClangFunctionDecl_isInlineSpecified(self: *const ZigClangFunctionDecl) bool;
|
||||
|
||||
pub extern fn ZigClangBuiltinType_getKind(self: *const struct_ZigClangBuiltinType) ZigClangBuiltinTypeKind;
|
||||
|
||||
|
@ -423,7 +423,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const ZigClangFunctionDecl) Error!void {
|
||||
.has_body = has_body,
|
||||
.storage_class = storage_class,
|
||||
.is_export = switch (storage_class) {
|
||||
.None => has_body,
|
||||
.None => has_body and !ZigClangFunctionDecl_isInlineSpecified(fn_decl),
|
||||
.Extern, .Static => false,
|
||||
.PrivateExtern => return failDecl(c, fn_decl_loc, fn_name, "unsupported storage class: private extern", .{}),
|
||||
.Auto => unreachable, // Not legal on functions
|
||||
|
@ -1686,6 +1686,16 @@ const struct ZigClangStmt *ZigClangFunctionDecl_getBody(const struct ZigClangFun
|
||||
return reinterpret_cast<const ZigClangStmt *>(stmt);
|
||||
}
|
||||
|
||||
bool ZigClangFunctionDecl_doesDeclarationForceExternallyVisibleDefinition(const struct ZigClangFunctionDecl *self) {
|
||||
auto casted = reinterpret_cast<const clang::FunctionDecl *>(self);
|
||||
return casted->doesDeclarationForceExternallyVisibleDefinition();
|
||||
}
|
||||
|
||||
bool ZigClangFunctionDecl_isInlineSpecified(const struct ZigClangFunctionDecl *self) {
|
||||
auto casted = reinterpret_cast<const clang::FunctionDecl *>(self);
|
||||
return casted->isInlineSpecified();
|
||||
}
|
||||
|
||||
const ZigClangTypedefNameDecl *ZigClangTypedefType_getDecl(const ZigClangTypedefType *self) {
|
||||
auto casted = reinterpret_cast<const clang::TypedefType *>(self);
|
||||
const clang::TypedefNameDecl *name_decl = casted->getDecl();
|
||||
|
@ -873,6 +873,8 @@ ZIG_EXTERN_C bool ZigClangFunctionDecl_hasBody(const struct ZigClangFunctionDecl
|
||||
ZIG_EXTERN_C enum ZigClangStorageClass ZigClangFunctionDecl_getStorageClass(const struct ZigClangFunctionDecl *);
|
||||
ZIG_EXTERN_C const struct ZigClangParmVarDecl *ZigClangFunctionDecl_getParamDecl(const struct ZigClangFunctionDecl *, unsigned i);
|
||||
ZIG_EXTERN_C const struct ZigClangStmt *ZigClangFunctionDecl_getBody(const struct ZigClangFunctionDecl *);
|
||||
ZIG_EXTERN_C bool ZigClangFunctionDecl_doesDeclarationForceExternallyVisibleDefinition(const struct ZigClangFunctionDecl *);
|
||||
ZIG_EXTERN_C bool ZigClangFunctionDecl_isInlineSpecified(const struct ZigClangFunctionDecl *);
|
||||
|
||||
ZIG_EXTERN_C bool ZigClangRecordDecl_isUnion(const struct ZigClangRecordDecl *record_decl);
|
||||
ZIG_EXTERN_C bool ZigClangRecordDecl_isStruct(const struct ZigClangRecordDecl *record_decl);
|
||||
|
@ -2302,4 +2302,14 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
|
||||
,
|
||||
\\pub const bar = 4;
|
||||
});
|
||||
|
||||
cases.add("don't export inline functions",
|
||||
\\inline void a(void) {}
|
||||
\\static void b(void) {}
|
||||
\\void c(void) {}
|
||||
, &[_][]const u8{
|
||||
\\pub fn a() void {}
|
||||
\\pub fn b() void {}
|
||||
\\pub export fn c() void {}
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user