Files
swift-mirror/test/Backtracing/Inputs/Inlining.swift
Ian Anderson 288f37b2c1 [Concurrency] [shims] Don't declare exit in the concurrency shims
Don't delete the OS declaration of `exit` because the concurrency shims aren't always imported, and so the shim declaration might not always be available.
Don't override the OS declaration of `exit` in the concurrency shims since we can't just delete the OS one. Instead, set up internal shims just for building Concurrency that forward declares `exit`.
2024-01-29 16:25:46 -08:00

40 lines
774 B
Swift

#if canImport(Darwin)
import Darwin
#elseif canImport(SwiftWASILibc)
import SwiftWASILibc
#elseif canImport(ucrt)
import ucrt
#elseif canImport(SwiftGlibc)
import SwiftGlibc
#endif
func square(_ x: Int) -> Int {
return x * x
}
func euclid2(_ a: Int, _ b: Int) -> Int {
return square(a) + square(b)
}
@main
struct Inlining {
static func main() {
if CommandLine.argc != 3 {
print("usage: Inlining <a> <b>")
exit(1)
}
guard let a = Int(CommandLine.arguments[1]) else {
print("Argument <a> must be a number")
exit(1)
}
guard let b = Int(CommandLine.arguments[2]) else {
print("Argument <b> must be a number")
exit(1)
}
let result = euclid2(a, b)
print("\(a) * \(a) + \(b) * \(b) = \(result)")
}
}