mirror of
https://github.com/ziglang/zig.git
synced 2026-02-14 21:38:33 +00:00
parent
b94525c45b
commit
a284be3f69
@ -809,6 +809,7 @@ pub extern fn ZigClangQualType_isRestrictQualified(self: struct_ZigClangQualType
|
||||
pub extern fn ZigClangType_getTypeClass(self: ?*const struct_ZigClangType) ZigClangTypeClass;
|
||||
pub extern fn ZigClangType_getPointeeType(self: ?*const struct_ZigClangType) struct_ZigClangQualType;
|
||||
pub extern fn ZigClangType_isVoidType(self: ?*const struct_ZigClangType) bool;
|
||||
pub extern fn ZigClangType_isConstantArrayType(self: ?*const struct_ZigClangType) bool;
|
||||
pub extern fn ZigClangType_isRecordType(self: ?*const struct_ZigClangType) bool;
|
||||
pub extern fn ZigClangType_isArrayType(self: ?*const struct_ZigClangType) bool;
|
||||
pub extern fn ZigClangType_isBooleanType(self: ?*const struct_ZigClangType) bool;
|
||||
|
||||
@ -1982,7 +1982,8 @@ fn transInitListExprArray(
|
||||
const arr_type = ZigClangType_getAsArrayTypeUnsafe(ty);
|
||||
const child_qt = ZigClangArrayType_getElementType(arr_type);
|
||||
const init_count = ZigClangInitListExpr_getNumInits(expr);
|
||||
const const_arr_ty = @ptrCast(*const ZigClangConstantArrayType, ty);
|
||||
assert(ZigClangType_isConstantArrayType(@ptrCast(*const ZigClangType, arr_type)));
|
||||
const const_arr_ty = @ptrCast(*const ZigClangConstantArrayType, arr_type);
|
||||
const size_ap_int = ZigClangConstantArrayType_getSize(const_arr_ty);
|
||||
const all_count = ZigClangAPInt_getLimitedValue(size_ap_int, math.maxInt(usize));
|
||||
const leftover_count = all_count - init_count;
|
||||
|
||||
@ -1877,6 +1877,11 @@ bool ZigClangType_isRecordType(const ZigClangType *self) {
|
||||
return casted->isRecordType();
|
||||
}
|
||||
|
||||
bool ZigClangType_isConstantArrayType(const ZigClangType *self) {
|
||||
auto casted = reinterpret_cast<const clang::Type *>(self);
|
||||
return casted->isConstantArrayType();
|
||||
}
|
||||
|
||||
const char *ZigClangType_getTypeClassName(const ZigClangType *self) {
|
||||
auto casted = reinterpret_cast<const clang::Type *>(self);
|
||||
return casted->getTypeClassName();
|
||||
|
||||
@ -945,6 +945,7 @@ ZIG_EXTERN_C bool ZigClangType_isBooleanType(const struct ZigClangType *self);
|
||||
ZIG_EXTERN_C bool ZigClangType_isVoidType(const struct ZigClangType *self);
|
||||
ZIG_EXTERN_C bool ZigClangType_isArrayType(const struct ZigClangType *self);
|
||||
ZIG_EXTERN_C bool ZigClangType_isRecordType(const struct ZigClangType *self);
|
||||
ZIG_EXTERN_C bool ZigClangType_isConstantArrayType(const ZigClangType *self);
|
||||
ZIG_EXTERN_C const char *ZigClangType_getTypeClassName(const struct ZigClangType *self);
|
||||
ZIG_EXTERN_C const struct ZigClangArrayType *ZigClangType_getAsArrayTypeUnsafe(const struct ZigClangType *self);
|
||||
ZIG_EXTERN_C const ZigClangRecordType *ZigClangType_getAsRecordType(const ZigClangType *self);
|
||||
|
||||
@ -2,6 +2,31 @@ const tests = @import("tests.zig");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub fn addCases(cases: *tests.TranslateCContext) void {
|
||||
cases.add("array initializer w/ typedef",
|
||||
\\typedef unsigned char uuid_t[16];
|
||||
\\static const uuid_t UUID_NULL __attribute__ ((unused)) = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
, &[_][]const u8{
|
||||
\\pub const uuid_t = [16]u8;
|
||||
\\pub const UUID_NULL: uuid_t = .{
|
||||
\\ @bitCast(u8, @truncate(i8, @as(c_int, 0))),
|
||||
\\ @bitCast(u8, @truncate(i8, @as(c_int, 0))),
|
||||
\\ @bitCast(u8, @truncate(i8, @as(c_int, 0))),
|
||||
\\ @bitCast(u8, @truncate(i8, @as(c_int, 0))),
|
||||
\\ @bitCast(u8, @truncate(i8, @as(c_int, 0))),
|
||||
\\ @bitCast(u8, @truncate(i8, @as(c_int, 0))),
|
||||
\\ @bitCast(u8, @truncate(i8, @as(c_int, 0))),
|
||||
\\ @bitCast(u8, @truncate(i8, @as(c_int, 0))),
|
||||
\\ @bitCast(u8, @truncate(i8, @as(c_int, 0))),
|
||||
\\ @bitCast(u8, @truncate(i8, @as(c_int, 0))),
|
||||
\\ @bitCast(u8, @truncate(i8, @as(c_int, 0))),
|
||||
\\ @bitCast(u8, @truncate(i8, @as(c_int, 0))),
|
||||
\\ @bitCast(u8, @truncate(i8, @as(c_int, 0))),
|
||||
\\ @bitCast(u8, @truncate(i8, @as(c_int, 0))),
|
||||
\\ @bitCast(u8, @truncate(i8, @as(c_int, 0))),
|
||||
\\ @bitCast(u8, @truncate(i8, @as(c_int, 0))),
|
||||
\\};
|
||||
});
|
||||
|
||||
cases.add("empty declaration",
|
||||
\\;
|
||||
, &[_][]const u8{""});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user