zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 72443fb88cfddad8a58868c150eaf5818826cb21 (tree)
parent 0909f47f86f05ded749f1382a37b148e0d157ae2
Author: Veikka Tuominen <git@vexu.eu>
Date:   Thu,  2 Mar 2023 12:48:13 +0200

translate-c: handle more wrapper types in `isAnyopaque`

Diffstat:
Msrc/translate_c.zig | 16++++++++++++++++
Mtest/translate_c.zig | 2+-
2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/translate_c.zig b/src/translate_c.zig @@ -4926,6 +4926,22 @@ fn isAnyopaque(qt: clang.QualType) bool { const typedef_decl = typedef_ty.getDecl(); return isAnyopaque(typedef_decl.getUnderlyingType()); }, + .Elaborated => { + const elaborated_ty = @ptrCast(*const clang.ElaboratedType, ty); + return isAnyopaque(elaborated_ty.getNamedType().getCanonicalType()); + }, + .Decayed => { + const decayed_ty = @ptrCast(*const clang.DecayedType, ty); + return isAnyopaque(decayed_ty.getDecayedType().getCanonicalType()); + }, + .Attributed => { + const attributed_ty = @ptrCast(*const clang.AttributedType, ty); + return isAnyopaque(attributed_ty.getEquivalentType().getCanonicalType()); + }, + .MacroQualified => { + const macroqualified_ty = @ptrCast(*const clang.MacroQualifiedType, ty); + return isAnyopaque(macroqualified_ty.getModifiedType().getCanonicalType()); + }, else => return false, } } diff --git a/test/translate_c.zig b/test/translate_c.zig @@ -3026,7 +3026,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\pub export fn log2(arg_a: u32) c_int { \\ var a = arg_a; \\ var i: c_int = 0; - \\ while (a > @bitCast(c_uint, @as(c_int, 0))) { + \\ while (a > @bitCast(u32, @as(c_int, 0))) { \\ a >>= @intCast(@import("std").math.Log2Int(c_int), @as(c_int, 1)); \\ } \\ return i;