aboutsummaryrefslogtreecommitdiff
path: root/types.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-03-16 13:35:58 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-03-16 13:35:58 -0400
commit469b1e067961e021e7860f70919b574c142d1f40 (patch)
treecd696be4b66550669c883075fd41a6bbd2a26eaa /types.c
parentf51acef40e8297d7bd41b774413aa8331ca946ed (diff)
Fixes for opaque external structs
Diffstat (limited to 'types.c')
-rw-r--r--types.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/types.c b/types.c
index eaecad2f..fde76440 100644
--- a/types.c
+++ b/types.c
@@ -462,6 +462,8 @@ PUREFUNC bool is_packed_data(type_t *t)
PUREFUNC size_t unpadded_struct_size(type_t *t)
{
+ if (Match(t, StructType)->opaque)
+ compiler_err(NULL, NULL, NULL, "The struct type %s is opaque, so I can't get the size of it", Match(t, StructType)->name);
arg_t *fields = Match(t, StructType)->fields;
size_t size = 0;
size_t bit_offset = 0;
@@ -546,6 +548,8 @@ PUREFUNC size_t type_size(type_t *t)
}
}
case StructType: {
+ if (Match(t, StructType)->opaque)
+ compiler_err(NULL, NULL, NULL, "The struct type %s is opaque, so I can't get the size of it", Match(t, StructType)->name);
size_t size = unpadded_struct_size(t);
size_t align = type_align(t);
if (size > 0 && align > 0 && (size % align) > 0)
@@ -625,6 +629,9 @@ PUREFUNC size_t type_align(type_t *t)
}
}
case StructType: {
+ if (Match(t, StructType)->opaque)
+ compiler_err(NULL, NULL, NULL, "The struct type %s is opaque, so I can't get the alignment of it",
+ Match(t, StructType)->name);
arg_t *fields = Match(t, StructType)->fields;
size_t align = t->tag == StructType ? 0 : sizeof(void*);
for (arg_t *field = fields; field; field = field->next) {