| ... | ... | @@ -1908,28 +1908,16 @@ static Error resolve_union_type(CodeGen *g, ZigType *union_type) { |
| 1908 | 1908 | return ErrorNone; |
| 1909 | 1909 | } |
| 1910 | 1910 | |
| 1911 | | static bool type_is_int_compatible(ZigType *t1, ZigType *t2) { |
| 1912 | | assert(t1->id == ZigTypeIdInt); |
| 1913 | | assert(t2->id == ZigTypeIdInt); |
| 1914 | | |
| 1915 | | if (t1 == t2) |
| 1916 | | return true; |
| 1917 | | |
| 1918 | | return (t1->data.integral.bit_count == t2->data.integral.bit_count && |
| 1919 | | t1->data.integral.is_signed == t2->data.integral.is_signed); |
| 1920 | | } |
| 1921 | | |
| 1922 | 1911 | static bool type_is_valid_extern_enum_tag(CodeGen *g, ZigType *ty) { |
| 1923 | | // According to the ANSI C standard: |
| 1924 | | // Each enumerated type shall be compatible with char, a signed integer |
| 1925 | | // type, or an unsigned integer type. |
| 1926 | | ZigType *c_uint_type = get_c_int_type(g, CIntTypeInt); |
| 1927 | | ZigType *c_int_type = get_c_int_type(g, CIntTypeInt); |
| 1928 | | ZigType *c_schar_type = g->builtin_types.entry_i8; |
| 1929 | | |
| 1930 | | return (type_is_int_compatible(ty, c_schar_type) || |
| 1931 | | type_is_int_compatible(ty, c_int_type) || |
| 1932 | | type_is_int_compatible(ty, c_uint_type)); |
| 1912 | // Only integer types are allowed by the C ABI |
| 1913 | if(ty->id != ZigTypeIdInt) |
| 1914 | return false; |
| 1915 | |
| 1916 | // According to the ANSI C standard the enumeration type should be either a |
| 1917 | // signed char, a signed integer or an unsigned one. But GCC/Clang allow |
| 1918 | // other integral types as a compiler extension so let's accomodate them |
| 1919 | // aswell. |
| 1920 | return type_allowed_in_extern(g, ty); |
| 1933 | 1921 | } |
| 1934 | 1922 | |
| 1935 | 1923 | static Error resolve_enum_zero_bits(CodeGen *g, ZigType *enum_type) { |