authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-10-23 22:33:00-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-10-23 22:33:00-04:00
log643ab90ace52d6d752a12ece9d6a8655ca2ca596
tree6aac62b2b1274c272ecd1cbd3bb6f49e9b79471f
parentc1642355f0b05f182c0b6d81d294d12be79ad0a8

add maximum value for @setAlignStack


3 files changed, 13 insertions(+), 1 deletions(-)

src/ir.cpp+5
......@@ -15312,6 +15312,11 @@ static TypeTableEntry *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, Ir
1531215312 if (!ir_resolve_align(ira, align_bytes_inst, &align_bytes))
1531315313 return ira->codegen->builtin_types.entry_invalid;
1531415314
15315 if (align_bytes > 256) {
15316 ir_add_error(ira, &instruction->base, buf_sprintf("attempt to @setAlignStack(%" PRIu32 "); maximum is 256", align_bytes));
15317 return ira->codegen->builtin_types.entry_invalid;
15318 }
15319
1531515320 FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec);
1531615321 if (fn_entry == nullptr) {
1531715322 ir_add_error(ira, &instruction->base, buf_sprintf("@setAlignStack outside function"));
test/cases/align.zig+1-1
......@@ -188,6 +188,6 @@ test "alignstack" {
188188}
189189
190190fn fnWithAlignedStack() -> i32 {
191 @setAlignStack(1024);
191 @setAlignStack(256);
192192 return 1234;
193193}
test/compile_errors.zig+7
......@@ -2187,6 +2187,13 @@ pub fn addCases(cases: &tests.CompileErrorContext) {
21872187 ".tmp_source.zig:3:5: error: alignstack set twice",
21882188 ".tmp_source.zig:2:5: note: first set here");
21892189
2190 cases.add("@setAlignStack too big",
2191 \\export fn entry() {
2192 \\ @setAlignStack(511 + 1);
2193 \\}
2194 ,
2195 ".tmp_source.zig:2:5: error: attempt to @setAlignStack(512); maximum is 256");
2196
21902197 cases.add("storing runtime value in compile time variable then using it",
21912198 \\const Mode = @import("builtin").Mode;
21922199 \\