aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-11-12 21:34:06 -0500
committerAndrew Kelley <andrew@ziglang.org>2019-11-12 21:57:25 -0500
commit32b37e695aa0581b863a395e0a28b7b4aa76c07d (patch)
tree6c942241282c9c1163bb22b75f91efda49712291 /src/analyze.cpp
parent37318bf15138d0a7b158b32ca43cbcdcf5382942 (diff)
downloadzig-32b37e695aa0581b863a395e0a28b7b4aa76c07d.tar.gz
zig-32b37e695aa0581b863a395e0a28b7b4aa76c07d.zip
fix anonymous struct literal assigned to variable
closes #3667
Diffstat (limited to 'src/analyze.cpp')
-rw-r--r--src/analyze.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp
index 4c63c566e9..1232cebe8b 100644
--- a/src/analyze.cpp
+++ b/src/analyze.cpp
@@ -5432,7 +5432,7 @@ bool fn_eval_eql(Scope *a, Scope *b) {
return false;
}
-// Whether the type has bits at runtime.
+// Deprecated. Use type_has_bits2.
bool type_has_bits(ZigType *type_entry) {
assert(type_entry != nullptr);
assert(!type_is_invalid(type_entry));
@@ -5440,6 +5440,27 @@ bool type_has_bits(ZigType *type_entry) {
return type_entry->abi_size != 0;
}
+// Whether the type has bits at runtime.
+Error type_has_bits2(CodeGen *g, ZigType *type_entry, bool *result) {
+ Error err;
+
+ if (type_is_invalid(type_entry))
+ return ErrorSemanticAnalyzeFail;
+
+ if (type_entry->id == ZigTypeIdStruct &&
+ type_entry->data.structure.resolve_status == ResolveStatusBeingInferred)
+ {
+ *result = true;
+ return ErrorNone;
+ }
+
+ if ((err = type_resolve(g, type_entry, ResolveStatusZeroBitsKnown)))
+ return err;
+
+ *result = type_entry->abi_size != 0;
+ return ErrorNone;
+}
+
// Whether you can infer the value based solely on the type.
OnePossibleValue type_has_one_possible_value(CodeGen *g, ZigType *type_entry) {
assert(type_entry != nullptr);