| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
- // Exceptions. See /LICENSE for license information.
- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
- //
- // AUTOUPDATE
- fn If(b: bool) -> i32 {
- if (b) {
- return 1;
- } else {
- return 2;
- }
- // Missing return here is OK.
- }
- // CHECK:STDOUT: --- unreachable_fallthrough.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %If: type = fn_type @If [template]
- // CHECK:STDOUT: %.1: type = tuple_type () [template]
- // CHECK:STDOUT: %struct: If = struct_value () [template]
- // CHECK:STDOUT: %.2: i32 = int_literal 1 [template]
- // CHECK:STDOUT: %.3: i32 = int_literal 2 [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .Core = %Core
- // CHECK:STDOUT: .If = %If.decl
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
- // CHECK:STDOUT: %If.decl: If = fn_decl @If [template = constants.%struct] {
- // CHECK:STDOUT: %b.loc7_7.1: bool = param b
- // CHECK:STDOUT: @If.%b: bool = bind_name b, %b.loc7_7.1
- // CHECK:STDOUT: @If.%return: ref i32 = var <return slot>
- // CHECK:STDOUT: }
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @If(%b: bool) -> i32 {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: %b.ref: bool = name_ref b, %b
- // CHECK:STDOUT: if %b.ref br !if.then else br !if.else
- // CHECK:STDOUT:
- // CHECK:STDOUT: !if.then:
- // CHECK:STDOUT: %.loc9: i32 = int_literal 1 [template = constants.%.2]
- // CHECK:STDOUT: return %.loc9
- // CHECK:STDOUT:
- // CHECK:STDOUT: !if.else:
- // CHECK:STDOUT: %.loc11: i32 = int_literal 2 [template = constants.%.3]
- // CHECK:STDOUT: return %.loc11
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
|