[K/N] Added FileCheck for noreturn attribute absence for suspend functions
This commit is contained in:
@@ -5894,6 +5894,10 @@ fileCheckTest("filecheck_escape_analysis_disabled") {
|
|||||||
checkPrefix = "CHECK-DEBUG"
|
checkPrefix = "CHECK-DEBUG"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fileCheckTest("filecheck_suspend_returnNothing") {
|
||||||
|
annotatedSource = project.file('filecheck/suspend_returnNothing.kt')
|
||||||
|
}
|
||||||
|
|
||||||
fileCheckTest("filecheck_bce") {
|
fileCheckTest("filecheck_bce") {
|
||||||
annotatedSource = project.file('filecheck/bce.kt')
|
annotatedSource = project.file('filecheck/bce.kt')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import kotlin.test.*
|
||||||
|
|
||||||
|
import kotlin.coroutines.*
|
||||||
|
import kotlin.coroutines.intrinsics.*
|
||||||
|
|
||||||
|
open class EmptyContinuation(override val context: CoroutineContext = EmptyCoroutineContext) : Continuation<Any?> {
|
||||||
|
companion object : EmptyContinuation()
|
||||||
|
override fun resumeWith(result: Result<Any?>) { result.getOrThrow() }
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun suspendForever(): Int = suspendCoroutineUninterceptedOrReturn {
|
||||||
|
COROUTINE_SUSPENDED
|
||||||
|
}
|
||||||
|
// CHECK-LABEL: define %struct.ObjHeader* @"kfun:$fooCOROUTINE
|
||||||
|
|
||||||
|
// CHECK-NOT: ; Function Attrs: noreturn
|
||||||
|
// CHECK-LABEL: define %struct.ObjHeader* @"kfun:#foo(){}kotlin.Nothing"
|
||||||
|
suspend fun foo(): Nothing {
|
||||||
|
suspendForever()
|
||||||
|
throw Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun bar() {
|
||||||
|
foo()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun builder(c: suspend () -> Unit) {
|
||||||
|
c.startCoroutine(EmptyContinuation)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
builder {
|
||||||
|
bar()
|
||||||
|
}
|
||||||
|
println("OK")
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user