unreachable_fallthrough.carbon 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  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: --- unreachable_fallthrough.carbon
  15. // CHECK:STDOUT:
  16. // CHECK:STDOUT: file {
  17. // CHECK:STDOUT: package: <namespace> = namespace {.If = %If}
  18. // CHECK:STDOUT: %If: <function> = fn_decl @If
  19. // CHECK:STDOUT: }
  20. // CHECK:STDOUT:
  21. // CHECK:STDOUT: fn @If(%b: bool) -> i32 {
  22. // CHECK:STDOUT: !entry:
  23. // CHECK:STDOUT: %b.ref: bool = name_ref b, %b
  24. // CHECK:STDOUT: if %b.ref br !if.then else br !if.else
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: !if.then:
  27. // CHECK:STDOUT: %.loc9: i32 = int_literal 1
  28. // CHECK:STDOUT: return %.loc9
  29. // CHECK:STDOUT:
  30. // CHECK:STDOUT: !if.else:
  31. // CHECK:STDOUT: %.loc11: i32 = int_literal 2
  32. // CHECK:STDOUT: return %.loc11
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT: