| ... | ... | @@ -725,11 +725,15 @@ fn transEnumDecl(c: *Context, enum_decl: *const ZigClangEnumDecl) Error!?*ast.No |
| 725 | 725 | }; |
| 726 | 726 | |
| 727 | 727 | const int_type = ZigClangEnumDecl_getIntegerType(enum_decl); |
| 728 | // The underlying type may be null in case of forward-declared enum |
| 729 | // types, while that's not ISO-C compliant many compilers allow this and |
| 730 | // default to the usual integer type used for all the enums. |
| 728 | 731 | |
| 729 | 732 | // TODO only emit this tag type if the enum tag type is not the default. |
| 730 | 733 | // I don't know what the default is, need to figure out how clang is deciding. |
| 731 | 734 | // it appears to at least be different across gcc/msvc |
| 732 | | if (!isCBuiltinType(int_type, .UInt) and |
| 735 | if (int_type.ptr != null and |
| 736 | !isCBuiltinType(int_type, .UInt) and |
| 733 | 737 | !isCBuiltinType(int_type, .Int)) |
| 734 | 738 | { |
| 735 | 739 | _ = try appendToken(c, .LParen, "("); |
| ... | ... | @@ -1555,8 +1559,7 @@ fn transCCast( |
| 1555 | 1559 | const elaborated_ty = @ptrCast(*const ZigClangElaboratedType, ZigClangQualType_getTypePtr(dst_type)); |
| 1556 | 1560 | return transCCast(rp, scope, loc, ZigClangElaboratedType_getNamedType(elaborated_ty), src_type, expr); |
| 1557 | 1561 | } |
| 1558 | | if (ZigClangQualType_getTypeClass(dst_type) == .Enum) |
| 1559 | | { |
| 1562 | if (ZigClangQualType_getTypeClass(dst_type) == .Enum) { |
| 1560 | 1563 | const builtin_node = try transCreateNodeBuiltinFnCall(rp.c, "@intToEnum"); |
| 1561 | 1564 | try builtin_node.params.push(try transQualType(rp, dst_type, loc)); |
| 1562 | 1565 | _ = try appendToken(rp.c, .Comma, ","); |