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
parent
5ea79bfc4a
commit
acdf4048b4
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue