diff options
| author | xackus <14938807+xackus@users.noreply.github.com> | 2021-03-30 18:28:50 +0200 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2021-06-12 11:55:39 +0300 |
| commit | b5c117d0516d13019fc79b80bc6be1aa31d51d85 (patch) | |
| tree | f6a0a00b36397e7db34405d7507a24afcda6c5a9 /src | |
| parent | 986a71234bf2b40284117cac0537e68071b29b33 (diff) | |
| download | zig-b5c117d0516d13019fc79b80bc6be1aa31d51d85.tar.gz zig-b5c117d0516d13019fc79b80bc6be1aa31d51d85.zip | |
translate-c: fix enums that require c_uint type
Diffstat (limited to 'src')
| -rw-r--r-- | src/translate_c.zig | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/translate_c.zig b/src/translate_c.zig index d1fa2d7222..cd752a4c44 100644 --- a/src/translate_c.zig +++ b/src/translate_c.zig @@ -1117,9 +1117,7 @@ fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: *const clang.EnumDecl) E // default to the usual integer type used for all the enums. // default to c_int since msvc and gcc default to different types - const init_arg_expr = if (int_type.ptr != null and - !isCBuiltinType(int_type, .UInt) and - !isCBuiltinType(int_type, .Int)) + const init_arg_expr = if (int_type.ptr != null) transQualType(c, scope, int_type, enum_loc) catch |err| switch (err) { error.UnsupportedType => { return failDecl(c, enum_loc, name, "unable to translate enum tag type", .{}); @@ -2285,8 +2283,8 @@ fn transCCast( // 1. If src_type is an enum, determine the underlying signed int type // 2. Extend or truncate without changing signed-ness. // 3. Bit-cast to correct signed-ness - const src_type_is_signed = cIsSignedInteger(src_type) or cIsEnum(src_type); const src_int_type = if (cIsInteger(src_type)) src_type else cIntTypeForEnum(src_type); + const src_type_is_signed = cIsSignedInteger(src_int_type); var src_int_expr = if (cIsInteger(src_type)) expr else try Tag.enum_to_int.create(c.arena, expr); if (isBoolRes(src_int_expr)) { |
