no_else.carbon 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/if/no_else.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/if/no_else.carbon
  10. fn F() {}
  11. fn G() {}
  12. fn If(b: bool) {
  13. if (b) {
  14. F();
  15. }
  16. G();
  17. }
  18. // CHECK:STDOUT: --- no_else.carbon
  19. // CHECK:STDOUT:
  20. // CHECK:STDOUT: constants {
  21. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  22. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  23. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  24. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  25. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  26. // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template]
  27. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template]
  28. // CHECK:STDOUT: %If.type: type = fn_type @If [template]
  29. // CHECK:STDOUT: %If: %If.type = struct_value () [template]
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: file {
  33. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  34. // CHECK:STDOUT: .Core = %Core
  35. // CHECK:STDOUT: .F = %F.decl
  36. // CHECK:STDOUT: .G = %G.decl
  37. // CHECK:STDOUT: .If = %If.decl
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  40. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {}
  41. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {}
  42. // CHECK:STDOUT: %import_ref: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool]
  43. // CHECK:STDOUT: %If.decl: %If.type = fn_decl @If [template = constants.%If] {
  44. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  45. // CHECK:STDOUT: %.loc14_10.1: type = value_of_initializer %bool.make_type [template = bool]
  46. // CHECK:STDOUT: %.loc14_10.2: type = converted %bool.make_type, %.loc14_10.1 [template = bool]
  47. // CHECK:STDOUT: %b.loc14_7.1: bool = param b
  48. // CHECK:STDOUT: @If.%b: bool = bind_name b, %b.loc14_7.1
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: fn @F() {
  53. // CHECK:STDOUT: !entry:
  54. // CHECK:STDOUT: return
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT:
  57. // CHECK:STDOUT: fn @G() {
  58. // CHECK:STDOUT: !entry:
  59. // CHECK:STDOUT: return
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: fn @Bool() -> type = "bool.make_type";
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: fn @If(%b: bool) {
  65. // CHECK:STDOUT: !entry:
  66. // CHECK:STDOUT: %b.ref: bool = name_ref b, %b
  67. // CHECK:STDOUT: if %b.ref br !if.then else br !if.else
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: !if.then:
  70. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F]
  71. // CHECK:STDOUT: %F.call: init %.1 = call %F.ref()
  72. // CHECK:STDOUT: br !if.else
  73. // CHECK:STDOUT:
  74. // CHECK:STDOUT: !if.else:
  75. // CHECK:STDOUT: %G.ref: %G.type = name_ref G, file.%G.decl [template = constants.%G]
  76. // CHECK:STDOUT: %G.call: init %.1 = call %G.ref()
  77. // CHECK:STDOUT: return
  78. // CHECK:STDOUT: }
  79. // CHECK:STDOUT: