diff --git a/backend.native/tests/build.gradle b/backend.native/tests/build.gradle index c9fbfe1e4c8..61ff9fa4583 100644 --- a/backend.native/tests/build.gradle +++ b/backend.native/tests/build.gradle @@ -153,6 +153,10 @@ task sum_3const(type: UnitKonanTest) { source = "codegen/function/sum_3const.kt" } +task local_variable(type: UnitKonanTest) { + source = "codegen/basics/local_variable.kt" +} + //task hello0(type: RunKonanTest) { // source = "runtime/basic/hello0.kt" //} diff --git a/backend.native/tests/codegen/basics/local_variable-test.c b/backend.native/tests/codegen/basics/local_variable-test.c new file mode 100644 index 00000000000..9d0df19af46 --- /dev/null +++ b/backend.native/tests/codegen/basics/local_variable-test.c @@ -0,0 +1,10 @@ +extern void *resolve_symbol(const char*); + +int +run_test() { + int (*local_variable)(int) = resolve_symbol("kfun:local_variable"); + + if (local_variable(3) != 14) return 1; + + return 0; +} diff --git a/backend.native/tests/codegen/basics/local_variable.kt b/backend.native/tests/codegen/basics/local_variable.kt new file mode 100644 index 00000000000..dcdb109be7a --- /dev/null +++ b/backend.native/tests/codegen/basics/local_variable.kt @@ -0,0 +1,5 @@ +fun local_variable(a: Int) : Int { + var b = 0 + b = a + 11 + return b +} \ No newline at end of file