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.
master
Andrew Kelley 2020-02-09 22:40:36 -05:00
parent 5ea79bfc4a
commit acdf4048b4
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
1 changed files with 0 additions and 19 deletions

View File

@ -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 {