diff options
| author | Jimmi HC <jhc@liab.dk> | 2018-06-29 10:21:43 +0200 |
|---|---|---|
| committer | Jimmi HC <jhc@liab.dk> | 2018-06-29 10:21:43 +0200 |
| commit | 4c3f27ce1ea17b5236a022971ebace73a02b7c2b (patch) | |
| tree | 9950a381f4803b3124e687bd897451d1a8304b31 /src/ir.cpp | |
| parent | b1128b18d5395d85f1c483d8b35e33c57be80722 (diff) | |
| download | zig-4c3f27ce1ea17b5236a022971ebace73a02b7c2b.tar.gz zig-4c3f27ce1ea17b5236a022971ebace73a02b7c2b.zip | |
ir_resolve_const now checks recursivly for undef values
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index c6078e755d..2cce4a5044 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -9148,8 +9148,15 @@ enum UndefAllowed { static ConstExprValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, UndefAllowed undef_allowed) { switch (value->value.special) { - case ConstValSpecialStatic: - return &value->value; + case ConstValSpecialStatic: { + ConstExprValue *res = &value->value; + if (undef_allowed == UndefBad && contains_comptime_undefined_value(res)) { + ir_add_error(ira, value, buf_sprintf("use of undefined value")); + return nullptr; + } + + return res; + } case ConstValSpecialRuntime: ir_add_error(ira, value, buf_sprintf("unable to evaluate constant expression")); return nullptr; |
