unreachable_fallthrough.carbon 915 B

1234567891011121314151617181920212223242526272829303132
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. fn If(b: bool) -> i32 {
  7. if (b) {
  8. return 1;
  9. } else {
  10. return 2;
  11. }
  12. // Missing return here is OK.
  13. }
  14. // CHECK:STDOUT: file "unreachable_fallthrough.carbon" {
  15. // CHECK:STDOUT: %If: <function> = fn_decl @If
  16. // CHECK:STDOUT: }
  17. // CHECK:STDOUT:
  18. // CHECK:STDOUT: fn @If(%b: bool) -> i32 {
  19. // CHECK:STDOUT: !entry:
  20. // CHECK:STDOUT: %b.ref: bool = name_reference b, %b
  21. // CHECK:STDOUT: if %b.ref br !if.then else br !if.else
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: !if.then:
  24. // CHECK:STDOUT: %.loc9: i32 = int_literal 1
  25. // CHECK:STDOUT: return %.loc9
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: !if.else:
  28. // CHECK:STDOUT: %.loc11: i32 = int_literal 2
  29. // CHECK:STDOUT: return %.loc11
  30. // CHECK:STDOUT: }