[IR][Native] Fix invalid IR return statement generation

^KT-46836
This commit is contained in:
Dmitriy Dolovov
2021-05-28 15:45:34 +03:00
committed by Space
parent 15b6a3c88c
commit e927764aaf
3 changed files with 43 additions and 1 deletions
@@ -533,6 +533,12 @@ standaloneTest("function_nothingN_returning_safe_call") {
source = "codegen/function/nothingNReturningSafeCall.kt"
}
standaloneTest("unreachable_statement_after_return") {
flags = ["-g", "-entry", "codegen.function.unreachable_statement_after_return.main"]
source = "codegen/function/unreachableStatementAfterReturn.kt"
goldValue = "1\n2\n3\n4\n"
}
task codegen_controlflow_for_loops(type: KonanLocalTest) {
source = "codegen/controlflow/for_loops.kt"
goldValue = "01234\n0123\n43210\n\n024\n02\n420\n\n036\n03\n630\n\n024\n02\n420\n\n"
@@ -0,0 +1,34 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package codegen.function.unreachable_statement_after_return
fun test1(): Any? {
return 1
42
}
fun test2(): Int? {
return 2
42
}
fun test3(): Any {
return 3
42
}
fun test4(): Int {
return 4
42
}
fun main() {
println(test1())
println(test2())
println(test3())
println(test4())
}