mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-20 21:16:43 +00:00
This removes the filename from the file-scoped block, and places it above to make it clear where the full SemIR begins (with multifile, providing a barrier between).
86 lines
2.4 KiB
Plaintext
86 lines
2.4 KiB
Plaintext
// 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 If1(b: bool) -> i32 {
|
|
if (b) {
|
|
return 1;
|
|
} else {
|
|
}
|
|
// CHECK:STDERR: fail_reachable_fallthrough.carbon:[[@LINE+3]]:1: ERROR: Missing `return` at end of function with declared return type.
|
|
// CHECK:STDERR: }
|
|
// CHECK:STDERR: ^
|
|
}
|
|
|
|
fn If2(b: bool) -> i32 {
|
|
if (b) {
|
|
} else {
|
|
return 2;
|
|
}
|
|
// CHECK:STDERR: fail_reachable_fallthrough.carbon:[[@LINE+3]]:1: ERROR: Missing `return` at end of function with declared return type.
|
|
// CHECK:STDERR: }
|
|
// CHECK:STDERR: ^
|
|
}
|
|
|
|
fn If3(b: bool) -> i32 {
|
|
if (b) {
|
|
return 1;
|
|
}
|
|
// CHECK:STDERR: fail_reachable_fallthrough.carbon:[[@LINE+3]]:1: ERROR: Missing `return` at end of function with declared return type.
|
|
// CHECK:STDERR: }
|
|
// CHECK:STDERR: ^
|
|
}
|
|
|
|
// CHECK:STDOUT: --- fail_reachable_fallthrough.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: %If1: <function> = fn_decl @If1
|
|
// CHECK:STDOUT: %If2: <function> = fn_decl @If2
|
|
// CHECK:STDOUT: %If3: <function> = fn_decl @If3
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @If1(%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
|
|
// CHECK:STDOUT: return %.loc9
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !if.else:
|
|
// CHECK:STDOUT: br !if.done
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !if.done:
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @If2(%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: br !if.done
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !if.else:
|
|
// CHECK:STDOUT: %.loc20: i32 = int_literal 2
|
|
// CHECK:STDOUT: return %.loc20
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !if.done:
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @If3(%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: %.loc29: i32 = int_literal 1
|
|
// CHECK:STDOUT: return %.loc29
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !if.else:
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|