[K/N] Added FileCheck for noreturn attribute absence for suspend functions

This commit is contained in:
Elena Lepilkina
2021-10-25 16:56:56 +03:00
committed by Space
parent 48e3df5224
commit 751f1a3b91
2 changed files with 46 additions and 0 deletions
@@ -5894,6 +5894,10 @@ fileCheckTest("filecheck_escape_analysis_disabled") {
checkPrefix = "CHECK-DEBUG"
}
fileCheckTest("filecheck_suspend_returnNothing") {
annotatedSource = project.file('filecheck/suspend_returnNothing.kt')
}
fileCheckTest("filecheck_bce") {
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")
}