| author | |
| committer | |
| log | ed956b581283824da1f7d39b953f4d716928eee2 |
| tree | 0379cf03da67cec831bb3b0bd16ebf4cfc385e71 |
| parent | 0c33ebb38eeb383da62a8af8aa368e8f6cac63a2 |
5 files changed, 26 insertions(+), 1 deletions(-)
src-self-hosted/clang.zig+4| ... | @@ -42,6 +42,7 @@ pub const struct_ZigClangImplicitCastExpr = @OpaqueType(); | ... | @@ -42,6 +42,7 @@ pub const struct_ZigClangImplicitCastExpr = @OpaqueType(); |
| 42 | pub const struct_ZigClangIncompleteArrayType = @OpaqueType(); | 42 | pub const struct_ZigClangIncompleteArrayType = @OpaqueType(); |
| 43 | pub const struct_ZigClangIntegerLiteral = @OpaqueType(); | 43 | pub const struct_ZigClangIntegerLiteral = @OpaqueType(); |
| 44 | pub const struct_ZigClangMacroDefinitionRecord = @OpaqueType(); | 44 | pub const struct_ZigClangMacroDefinitionRecord = @OpaqueType(); |
| 45 | pub const struct_ZigClangMacroQualifiedType = @OpaqueType(); | ||
| 45 | pub const struct_ZigClangMemberExpr = @OpaqueType(); | 46 | pub const struct_ZigClangMemberExpr = @OpaqueType(); |
| 46 | pub const struct_ZigClangNamedDecl = @OpaqueType(); | 47 | pub const struct_ZigClangNamedDecl = @OpaqueType(); |
| 47 | pub const struct_ZigClangNone = @OpaqueType(); | 48 | pub const struct_ZigClangNone = @OpaqueType(); |
| ... | @@ -831,6 +832,7 @@ pub const ZigClangImplicitCastExpr = struct_ZigClangImplicitCastExpr; | ... | @@ -831,6 +832,7 @@ pub const ZigClangImplicitCastExpr = struct_ZigClangImplicitCastExpr; |
| 831 | pub const ZigClangIncompleteArrayType = struct_ZigClangIncompleteArrayType; | 832 | pub const ZigClangIncompleteArrayType = struct_ZigClangIncompleteArrayType; |
| 832 | pub const ZigClangIntegerLiteral = struct_ZigClangIntegerLiteral; | 833 | pub const ZigClangIntegerLiteral = struct_ZigClangIntegerLiteral; |
| 833 | pub const ZigClangMacroDefinitionRecord = struct_ZigClangMacroDefinitionRecord; | 834 | pub const ZigClangMacroDefinitionRecord = struct_ZigClangMacroDefinitionRecord; |
| 835 | pub const ZigClangMacroQualifiedType = struct_ZigClangMacroQualifiedType; | ||
| 834 | pub const ZigClangMemberExpr = struct_ZigClangMemberExpr; | 836 | pub const ZigClangMemberExpr = struct_ZigClangMemberExpr; |
| 835 | pub const ZigClangNamedDecl = struct_ZigClangNamedDecl; | 837 | pub const ZigClangNamedDecl = struct_ZigClangNamedDecl; |
| 836 | pub const ZigClangNone = struct_ZigClangNone; | 838 | pub const ZigClangNone = struct_ZigClangNone; |
| ... | @@ -937,6 +939,8 @@ pub extern fn ZigClangElaboratedType_getNamedType(*const ZigClangElaboratedType) | ... | @@ -937,6 +939,8 @@ pub extern fn ZigClangElaboratedType_getNamedType(*const ZigClangElaboratedType) |
| 937 | 939 | ||
| 938 | pub extern fn ZigClangAttributedType_getEquivalentType(*const ZigClangAttributedType) ZigClangQualType; | 940 | pub extern fn ZigClangAttributedType_getEquivalentType(*const ZigClangAttributedType) ZigClangQualType; |
| 939 | 941 | ||
| 942 | pub extern fn ZigClangMacroQualifiedType_getModifiedType(*const ZigClangMacroQualifiedType) ZigClangQualType; | ||
| 943 | |||
| 940 | pub extern fn ZigClangCStyleCastExpr_getBeginLoc(*const ZigClangCStyleCastExpr) ZigClangSourceLocation; | 944 | pub extern fn ZigClangCStyleCastExpr_getBeginLoc(*const ZigClangCStyleCastExpr) ZigClangSourceLocation; |
| 941 | pub extern fn ZigClangCStyleCastExpr_getSubExpr(*const ZigClangCStyleCastExpr) *const ZigClangExpr; | 945 | pub extern fn ZigClangCStyleCastExpr_getSubExpr(*const ZigClangCStyleCastExpr) *const ZigClangExpr; |
| 942 | pub extern fn ZigClangCStyleCastExpr_getType(*const ZigClangCStyleCastExpr) ZigClangQualType; | 946 | pub extern fn ZigClangCStyleCastExpr_getType(*const ZigClangCStyleCastExpr) ZigClangQualType; |
src/translate_c.cpp+5-1| ... | @@ -1213,6 +1213,11 @@ static AstNode *trans_type(Context *c, const ZigClangType *ty, ZigClangSourceLoc | ... | @@ -1213,6 +1213,11 @@ static AstNode *trans_type(Context *c, const ZigClangType *ty, ZigClangSourceLoc |
| 1213 | const ZigClangAttributedType *attributed_ty = reinterpret_cast<const ZigClangAttributedType *>(ty); | 1213 | const ZigClangAttributedType *attributed_ty = reinterpret_cast<const ZigClangAttributedType *>(ty); |
| 1214 | return trans_qual_type(c, ZigClangAttributedType_getEquivalentType(attributed_ty), source_loc); | 1214 | return trans_qual_type(c, ZigClangAttributedType_getEquivalentType(attributed_ty), source_loc); |
| 1215 | } | 1215 | } |
| 1216 | case ZigClangType_MacroQualified: | ||
| 1217 | { | ||
| 1218 | const ZigClangMacroQualifiedType *macroqualified_ty = reinterpret_cast<const ZigClangMacroQualifiedType *>(ty); | ||
| 1219 | return trans_qual_type(c, ZigClangMacroQualifiedType_getModifiedType(macroqualified_ty), source_loc); | ||
| 1220 | } | ||
| 1216 | case ZigClangType_IncompleteArray: | 1221 | case ZigClangType_IncompleteArray: |
| 1217 | { | 1222 | { |
| 1218 | const ZigClangIncompleteArrayType *incomplete_array_ty = reinterpret_cast<const ZigClangIncompleteArrayType *>(ty); | 1223 | const ZigClangIncompleteArrayType *incomplete_array_ty = reinterpret_cast<const ZigClangIncompleteArrayType *>(ty); |
| ... | @@ -1262,7 +1267,6 @@ static AstNode *trans_type(Context *c, const ZigClangType *ty, ZigClangSourceLoc | ... | @@ -1262,7 +1267,6 @@ static AstNode *trans_type(Context *c, const ZigClangType *ty, ZigClangSourceLoc |
| 1262 | case ZigClangType_DeducedTemplateSpecialization: | 1267 | case ZigClangType_DeducedTemplateSpecialization: |
| 1263 | case ZigClangType_DependentAddressSpace: | 1268 | case ZigClangType_DependentAddressSpace: |
| 1264 | case ZigClangType_DependentVector: | 1269 | case ZigClangType_DependentVector: |
| 1265 | case ZigClangType_MacroQualified: | ||
| 1266 | emit_warning(c, source_loc, "unsupported type: '%s'", ZigClangType_getTypeClassName(ty)); | 1270 | emit_warning(c, source_loc, "unsupported type: '%s'", ZigClangType_getTypeClassName(ty)); |
| 1267 | return nullptr; | 1271 | return nullptr; |
| 1268 | } | 1272 | } |
src/zig_clang.cpp+5| ... | @@ -2214,6 +2214,11 @@ struct ZigClangQualType ZigClangAttributedType_getEquivalentType(const struct Zi | ... | @@ -2214,6 +2214,11 @@ struct ZigClangQualType ZigClangAttributedType_getEquivalentType(const struct Zi |
| 2214 | return bitcast(casted->getEquivalentType()); | 2214 | return bitcast(casted->getEquivalentType()); |
| 2215 | } | 2215 | } |
| 2216 | 2216 | ||
| 2217 | struct ZigClangQualType ZigClangMacroQualifiedType_getModifiedType(const struct ZigClangMacroQualifiedType *self) { | ||
| 2218 | auto casted = reinterpret_cast<const clang::MacroQualifiedType *>(self); | ||
| 2219 | return bitcast(casted->getModifiedType()); | ||
| 2220 | } | ||
| 2221 | |||
| 2217 | struct ZigClangQualType ZigClangElaboratedType_getNamedType(const struct ZigClangElaboratedType *self) { | 2222 | struct ZigClangQualType ZigClangElaboratedType_getNamedType(const struct ZigClangElaboratedType *self) { |
| 2218 | auto casted = reinterpret_cast<const clang::ElaboratedType *>(self); | 2223 | auto casted = reinterpret_cast<const clang::ElaboratedType *>(self); |
| 2219 | return bitcast(casted->getNamedType()); | 2224 | return bitcast(casted->getNamedType()); |
src/zig_clang.h+3| ... | @@ -112,6 +112,7 @@ struct ZigClangImplicitCastExpr; | ... | @@ -112,6 +112,7 @@ struct ZigClangImplicitCastExpr; |
| 112 | struct ZigClangIncompleteArrayType; | 112 | struct ZigClangIncompleteArrayType; |
| 113 | struct ZigClangIntegerLiteral; | 113 | struct ZigClangIntegerLiteral; |
| 114 | struct ZigClangMacroDefinitionRecord; | 114 | struct ZigClangMacroDefinitionRecord; |
| 115 | struct ZigClangMacroQualifiedType; | ||
| 115 | struct ZigClangMemberExpr; | 116 | struct ZigClangMemberExpr; |
| 116 | struct ZigClangNamedDecl; | 117 | struct ZigClangNamedDecl; |
| 117 | struct ZigClangNone; | 118 | struct ZigClangNone; |
| ... | @@ -1004,6 +1005,8 @@ ZIG_EXTERN_C struct ZigClangQualType ZigClangParenType_getInnerType(const struct | ... | @@ -1004,6 +1005,8 @@ ZIG_EXTERN_C struct ZigClangQualType ZigClangParenType_getInnerType(const struct |
| 1004 | 1005 | ||
| 1005 | ZIG_EXTERN_C struct ZigClangQualType ZigClangAttributedType_getEquivalentType(const struct ZigClangAttributedType *); | 1006 | ZIG_EXTERN_C struct ZigClangQualType ZigClangAttributedType_getEquivalentType(const struct ZigClangAttributedType *); |
| 1006 | 1007 | ||
| 1008 | ZIG_EXTERN_C struct ZigClangQualType ZigClangMacroQualifiedType_getModifiedType(const struct ZigClangMacroQualifiedType *); | ||
| 1009 | |||
| 1007 | ZIG_EXTERN_C struct ZigClangQualType ZigClangElaboratedType_getNamedType(const struct ZigClangElaboratedType *); | 1010 | ZIG_EXTERN_C struct ZigClangQualType ZigClangElaboratedType_getNamedType(const struct ZigClangElaboratedType *); |
| 1008 | ZIG_EXTERN_C enum ZigClangElaboratedTypeKeyword ZigClangElaboratedType_getKeyword(const struct ZigClangElaboratedType *); | 1011 | ZIG_EXTERN_C enum ZigClangElaboratedTypeKeyword ZigClangElaboratedType_getKeyword(const struct ZigClangElaboratedType *); |
| 1009 | 1012 |
test/translate_c.zig+9| ... | @@ -1814,6 +1814,15 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -1814,6 +1814,15 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1814 | \\ | 1814 | \\ |
| 1815 | ); | 1815 | ); |
| 1816 | 1816 | ||
| 1817 | if (builtin.os != builtin.Os.windows) { | ||
| 1818 | // sysv_abi not currently supported on windows | ||
| 1819 | cases.add("Macro qualified functions", | ||
| 1820 | \\void __attribute__((sysv_abi)) foo(void); | ||
| 1821 | , | ||
| 1822 | \\pub extern fn foo() void; | ||
| 1823 | ); | ||
| 1824 | } | ||
| 1825 | |||
| 1817 | /////////////// Cases for only stage1 because stage2 behavior is better //////////////// | 1826 | /////////////// Cases for only stage1 because stage2 behavior is better //////////////// |
| 1818 | cases.addC("Parameterless function prototypes", | 1827 | cases.addC("Parameterless function prototypes", |
| 1819 | \\void foo() {} | 1828 | \\void foo() {} |