aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorSahnvour <sahnvour@pm.me>2019-09-03 22:29:04 +0200
committerAndrew Kelley <andrew@ziglang.org>2019-09-03 21:14:40 -0400
commitce14c543d165efbd926ea6bd654d999c625b366f (patch)
tree8d4f08b3ff22dee7a98fd09b157f008ba114c035 /src/ir.cpp
parenta4ce10df8087e7051340e14e4acd018092f935f0 (diff)
downloadzig-ce14c543d165efbd926ea6bd654d999c625b366f.tar.gz
zig-ce14c543d165efbd926ea6bd654d999c625b366f.zip
error message and test for alignment of variables of zero-bit types
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index abf4f477a8..7415a2dd6b 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -14839,6 +14839,12 @@ static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_in
if (align != 0) {
if ((err = type_resolve(ira->codegen, var_type, ResolveStatusAlignmentKnown)))
return ira->codegen->invalid_instruction;
+ if (!type_has_bits(var_type)) {
+ ir_add_error(ira, source_inst,
+ buf_sprintf("variable '%s' of zero-bit type '%s' has no in-memory representation, it cannot be aligned",
+ name_hint, buf_ptr(&var_type->name)));
+ return ira->codegen->invalid_instruction;
+ }
}
assert(result->base.value.data.x_ptr.special != ConstPtrSpecialInvalid);