zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit acdf4048b478f500edd13c6e50ca52376ce55a12 (tree)
parent 5ea79bfc4a0a1269930d98faee36a8f6cb0b0401
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Sun,  9 Feb 2020 22:40:36 -0500

allow local variable address detection to regress

See #3180 for a more comprehensive plan to catch this problem. More
sophisticated control flow analysis is needed to provide compile errors
for returning local variable addresses from a function.

Diffstat:
Mtest/compile_errors.zig | 19-------------------
1 file changed, 0 insertions(+), 19 deletions(-)

diff --git a/test/compile_errors.zig b/test/compile_errors.zig @@ -5292,25 +5292,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { "tmp.zig:2:30: error: cannot set section of local variable 'foo'", }); - cases.add("returning address of local variable - simple", - \\export fn foo() *i32 { - \\ var a: i32 = undefined; - \\ return &a; - \\} - , &[_][]const u8{ - "tmp.zig:3:13: error: function returns address of local variable", - }); - - cases.add("returning address of local variable - phi", - \\export fn foo(c: bool) *i32 { - \\ var a: i32 = undefined; - \\ var b: i32 = undefined; - \\ return if (c) &a else &b; - \\} - , &[_][]const u8{ - "tmp.zig:4:12: error: function returns address of local variable", - }); - cases.add("inner struct member shadowing outer struct member", \\fn A() type { \\ return struct {