| author | |
| committer | |
| log | d5bbd748711abc82272199869cf70faf1ea30f52 |
| tree | a3a15180a22228a4c38ccdcd79815349746aeaa4 |
| parent | cc7060d0d934135d797bd2bc24288ecab095051a |
| signature | Commit is signed but in an unrecognized format. |
clang/gcc support pointer alignment attribute:
https://clang.llvm.org/docs/AttributeReference.html#align-value3 files changed, 2 insertions(+), 11 deletions(-)
src/ir.cpp-5| ... | ... | @@ -5057,11 +5057,6 @@ static IrInstruction *ir_gen_pointer_type(IrBuilder *irb, Scope *scope, AstNode |
| 5057 | 5057 | |
| 5058 | 5058 | IrInstruction *align_value; |
| 5059 | 5059 | if (align_expr != nullptr) { |
| 5060 | if (ptr_len == PtrLenC) { | |
| 5061 | exec_add_error_node(irb->codegen, irb->exec, node, | |
| 5062 | buf_sprintf("[*c] pointers may not have align attribute")); | |
| 5063 | return irb->codegen->invalid_instruction; | |
| 5064 | } | |
| 5065 | 5060 | align_value = ir_gen_node(irb, align_expr, scope); |
| 5066 | 5061 | if (align_value == irb->codegen->invalid_instruction) |
| 5067 | 5062 | return align_value; |
test/compile_errors.zig-4| ... | ... | @@ -123,12 +123,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 123 | 123 | \\export fn a() void { |
| 124 | 124 | \\ const T = [*c]Foo; |
| 125 | 125 | \\} |
| 126 | \\export fn b() void { | |
| 127 | \\ const T = [*c]align(4) u8; | |
| 128 | \\} | |
| 129 | 126 | , |
| 130 | 127 | ".tmp_source.zig:3:15: error: C pointers cannot point to non-C-ABI-compatible type 'Foo'", |
| 131 | ".tmp_source.zig:6:15: error: [*c] pointers may not have align attribute", | |
| 132 | 128 | ); |
| 133 | 129 | |
| 134 | 130 | cases.addTest( |
test/stage1/behavior/type_info.zig+2-2| ... | ... | @@ -67,12 +67,12 @@ test "type info: C pointer type info" { |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | fn testCPtr() void { |
| 70 | const ptr_info = @typeInfo([*c]const i8); | |
| 70 | const ptr_info = @typeInfo([*c]align(4) const i8); | |
| 71 | 71 | expect(TypeId(ptr_info) == TypeId.Pointer); |
| 72 | 72 | expect(ptr_info.Pointer.size == TypeInfo.Pointer.Size.C); |
| 73 | 73 | expect(ptr_info.Pointer.is_const); |
| 74 | 74 | expect(!ptr_info.Pointer.is_volatile); |
| 75 | expect(ptr_info.Pointer.alignment == 1); | |
| 75 | expect(ptr_info.Pointer.alignment == 4); | |
| 76 | 76 | expect(ptr_info.Pointer.child == i8); |
| 77 | 77 | } |
| 78 | 78 |