Files
carbon-lang/toolchain/check/testdata/if/fail_reachable_fallthrough.carbon
T
Jon Ross-Perkins b8ceb8dd8b Print a blank line after a diagnostic. (#3806)
The purpose of the newline is to make it clearer where a given
diagnostic begins and ends, particularly as the first message of a
diagnostic may not be the error.

This is a trivial code change, but ripples edits through test files.
2024-03-22 18:10:49 +00:00

110 lines
3.5 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+4]]:1: ERROR: Missing `return` at end of function with declared return type.
// CHECK:STDERR: }
// CHECK:STDERR: ^
// CHECK:STDERR:
}
fn If2(b: bool) -> i32 {
if (b) {
} else {
return 2;
}
// CHECK:STDERR: fail_reachable_fallthrough.carbon:[[@LINE+4]]:1: ERROR: Missing `return` at end of function with declared return type.
// CHECK:STDERR: }
// 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: constants {
// CHECK:STDOUT: %.1: i32 = int_literal 1 [template]
// CHECK:STDOUT: %.2: i32 = int_literal 2 [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [template] {
// CHECK:STDOUT: .If1 = %If1
// CHECK:STDOUT: .If2 = %If2
// CHECK:STDOUT: .If3 = %If3
// CHECK:STDOUT: }
// CHECK:STDOUT: %If1: <function> = fn_decl @If1 [template] {
// CHECK:STDOUT: %b.loc7_8.1: bool = param b
// CHECK:STDOUT: @If1.%b: bool = bind_name b, %b.loc7_8.1
// CHECK:STDOUT: %return.var.loc7: ref i32 = var <return slot>
// CHECK:STDOUT: }
// CHECK:STDOUT: %If2: <function> = fn_decl @If2 [template] {
// CHECK:STDOUT: %b.loc18_8.1: bool = param b
// CHECK:STDOUT: @If2.%b: bool = bind_name b, %b.loc18_8.1
// CHECK:STDOUT: %return.var.loc18: ref i32 = var <return slot>
// CHECK:STDOUT: }
// CHECK:STDOUT: %If3: <function> = fn_decl @If3 [template] {
// CHECK:STDOUT: %b.loc29_8.1: bool = param b
// CHECK:STDOUT: @If3.%b: bool = bind_name b, %b.loc29_8.1
// CHECK:STDOUT: %return.var.loc29: ref i32 = var <return slot>
// CHECK:STDOUT: }
// 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 [template = constants.%.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: %.loc21: i32 = int_literal 2 [template = constants.%.2]
// CHECK:STDOUT: return %.loc21
// 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: %.loc31: i32 = int_literal 1 [template = constants.%.1]
// CHECK:STDOUT: return %.loc31
// CHECK:STDOUT:
// CHECK:STDOUT: !if.else:
// CHECK:STDOUT: }
// CHECK:STDOUT: