aboutsummaryrefslogtreecommitdiff
path: root/test/compile_errors.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-04-27 19:40:35 -0400
committerAndrew Kelley <superjoe30@gmail.com>2017-04-27 19:40:35 -0400
commit2e512a0e6e81532b62ddb7fdafdcd28926690eaa (patch)
treec20acbfa1e99c7d7edef93ac57a86dbe8eee5666 /test/compile_errors.zig
parent1691074b4b1f080b3a1f7ca7dc7426c6ef4c242a (diff)
downloadzig-2e512a0e6e81532b62ddb7fdafdcd28926690eaa.tar.gz
zig-2e512a0e6e81532b62ddb7fdafdcd28926690eaa.zip
add compile error for returning local variable address
closes #344
Diffstat (limited to 'test/compile_errors.zig')
-rw-r--r--test/compile_errors.zig8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index 771972fcf0..9f0b9de232 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -1610,4 +1610,12 @@ pub fn addCases(cases: &tests.CompileErrorContext) {
,
".tmp_source.zig:3:5: error: cannot set section of external function 'foo'",
".tmp_source.zig:1:8: note: declared here");
+
+ cases.add("returning address of local variable",
+ \\export fn foo() -> &i32 {
+ \\ var a: i32 = undefined;
+ \\ return &a;
+ \\}
+ ,
+ ".tmp_source.zig:3:13: error: function returns address of local variable");
}