aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.cpp
diff options
context:
space:
mode:
authorTetralux <tetralux@teknik.io>2019-08-22 20:41:33 +0000
committerTetralux <tetralux@teknik.io>2019-08-22 22:58:02 +0000
commit3ec10ea174d5738098e9bd1ef709b552603cc3b4 (patch)
tree54718d6ad8bfa40ef8bf8450b816cffe3abeab38 /src/analyze.cpp
parentec7d7a5b14540ea3b2bab9f11318630338467965 (diff)
downloadzig-3ec10ea174d5738098e9bd1ef709b552603cc3b4.tar.gz
zig-3ec10ea174d5738098e9bd1ef709b552603cc3b4.zip
parsing of align(N) on struct fields
Diffstat (limited to 'src/analyze.cpp')
-rw-r--r--src/analyze.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp
index a06bba3f2a..aa625b6e22 100644
--- a/src/analyze.cpp
+++ b/src/analyze.cpp
@@ -2255,9 +2255,21 @@ static Error resolve_struct_alignment(CodeGen *g, ZigType *struct_type) {
if (field->gen_index == SIZE_MAX)
continue;
- size_t this_field_align;
- if (packed) {
+ uint32_t this_field_align;
+
+ // TODO: Sets the field alignment in the type, but doesn't do anything
+ // to actually make that happen yet.
+ AstNode *align_expr = field->decl_node->data.struct_field.align_expr;
+ if (align_expr != nullptr) {
+ if (!analyze_const_align(g, &struct_type->data.structure.decls_scope->base, align_expr, &this_field_align)) {
+ field->type_entry = g->builtin_types.entry_invalid;
+ } else {
+ field->align = this_field_align;
+ }
+ } else if (packed) {
// TODO: https://github.com/ziglang/zig/issues/1512
+ // TODO: Validate requested alignment is possible, given packed,
+ // and given other field alignments.
this_field_align = 1;
// TODO If we have no type_entry for the field, we've already failed to
// compile the program correctly. This stage1 compiler needs a deeper