aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-02-14 13:07:51 -0500
committerAndrew Kelley <andrew@ziglang.org>2019-02-14 13:07:51 -0500
commit52c03de5c2495b369ae730ff203e5342e4f33a36 (patch)
tree6e9431418a20422112836190eaabd42eacd5c84d /src/analyze.cpp
parente03c770145b5dc7b428d53b3cac97c2733fb84d8 (diff)
downloadzig-52c03de5c2495b369ae730ff203e5342e4f33a36.tar.gz
zig-52c03de5c2495b369ae730ff203e5342e4f33a36.zip
add missing compile error for OpaqueType inside structs/unions
closes #1862
Diffstat (limited to 'src/analyze.cpp')
-rw-r--r--src/analyze.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp
index 6a8090a843..90ce3d3371 100644
--- a/src/analyze.cpp
+++ b/src/analyze.cpp
@@ -2679,6 +2679,13 @@ static Error resolve_struct_zero_bits(CodeGen *g, ZigType *struct_type) {
buf_sprintf("enums, not structs, support field assignment"));
}
+ if (field_type->id == ZigTypeIdOpaque) {
+ add_node_error(g, field_node->data.struct_field.type,
+ buf_sprintf("opaque types have unknown size and therefore cannot be directly embedded in structs"));
+ struct_type->data.structure.resolve_status = ResolveStatusInvalid;
+ continue;
+ }
+
switch (type_requires_comptime(g, field_type)) {
case ReqCompTimeYes:
struct_type->data.structure.requires_comptime = true;
@@ -2963,6 +2970,13 @@ static Error resolve_union_zero_bits(CodeGen *g, ZigType *union_type) {
}
union_field->type_entry = field_type;
+ if (field_type->id == ZigTypeIdOpaque) {
+ add_node_error(g, field_node->data.struct_field.type,
+ buf_sprintf("opaque types have unknown size and therefore cannot be directly embedded in unions"));
+ union_type->data.unionation.is_invalid = true;
+ continue;
+ }
+
switch (type_requires_comptime(g, field_type)) {
case ReqCompTimeInvalid:
union_type->data.unionation.is_invalid = true;