break_continue.carbon 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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 A() -> bool;
  7. fn B() -> bool;
  8. fn C() -> bool;
  9. fn D() -> bool;
  10. fn E() -> bool;
  11. fn F() -> bool;
  12. fn G() -> bool;
  13. fn H() -> bool;
  14. fn While() {
  15. while (A()) {
  16. if (B()) { continue; }
  17. if (C()) { break; }
  18. while (D()) {
  19. if (E()) { continue; }
  20. if (F()) { break; }
  21. }
  22. if (G()) { continue; }
  23. if (H()) { break; }
  24. }
  25. }
  26. // CHECK:STDOUT: --- break_continue.carbon
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: constants {
  29. // CHECK:STDOUT: %A: type = fn_type @A [template]
  30. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  31. // CHECK:STDOUT: %struct.1: A = struct_value () [template]
  32. // CHECK:STDOUT: %B: type = fn_type @B [template]
  33. // CHECK:STDOUT: %struct.2: B = struct_value () [template]
  34. // CHECK:STDOUT: %C: type = fn_type @C [template]
  35. // CHECK:STDOUT: %struct.3: C = struct_value () [template]
  36. // CHECK:STDOUT: %D: type = fn_type @D [template]
  37. // CHECK:STDOUT: %struct.4: D = struct_value () [template]
  38. // CHECK:STDOUT: %E: type = fn_type @E [template]
  39. // CHECK:STDOUT: %struct.5: E = struct_value () [template]
  40. // CHECK:STDOUT: %F: type = fn_type @F [template]
  41. // CHECK:STDOUT: %struct.6: F = struct_value () [template]
  42. // CHECK:STDOUT: %G: type = fn_type @G [template]
  43. // CHECK:STDOUT: %struct.7: G = struct_value () [template]
  44. // CHECK:STDOUT: %H: type = fn_type @H [template]
  45. // CHECK:STDOUT: %struct.8: H = struct_value () [template]
  46. // CHECK:STDOUT: %While: type = fn_type @While [template]
  47. // CHECK:STDOUT: %struct.9: While = struct_value () [template]
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: file {
  51. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  52. // CHECK:STDOUT: .Core = %Core
  53. // CHECK:STDOUT: .A = %A.decl
  54. // CHECK:STDOUT: .B = %B.decl
  55. // CHECK:STDOUT: .C = %C.decl
  56. // CHECK:STDOUT: .D = %D.decl
  57. // CHECK:STDOUT: .E = %E.decl
  58. // CHECK:STDOUT: .F = %F.decl
  59. // CHECK:STDOUT: .G = %G.decl
  60. // CHECK:STDOUT: .H = %H.decl
  61. // CHECK:STDOUT: .While = %While.decl
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  64. // CHECK:STDOUT: %A.decl: A = fn_decl @A [template = constants.%struct.1] {
  65. // CHECK:STDOUT: @A.%return: ref bool = var <return slot>
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT: %B.decl: B = fn_decl @B [template = constants.%struct.2] {
  68. // CHECK:STDOUT: @B.%return: ref bool = var <return slot>
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT: %C.decl: C = fn_decl @C [template = constants.%struct.3] {
  71. // CHECK:STDOUT: @C.%return: ref bool = var <return slot>
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT: %D.decl: D = fn_decl @D [template = constants.%struct.4] {
  74. // CHECK:STDOUT: @D.%return: ref bool = var <return slot>
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT: %E.decl: E = fn_decl @E [template = constants.%struct.5] {
  77. // CHECK:STDOUT: @E.%return: ref bool = var <return slot>
  78. // CHECK:STDOUT: }
  79. // CHECK:STDOUT: %F.decl: F = fn_decl @F [template = constants.%struct.6] {
  80. // CHECK:STDOUT: @F.%return: ref bool = var <return slot>
  81. // CHECK:STDOUT: }
  82. // CHECK:STDOUT: %G.decl: G = fn_decl @G [template = constants.%struct.7] {
  83. // CHECK:STDOUT: @G.%return: ref bool = var <return slot>
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT: %H.decl: H = fn_decl @H [template = constants.%struct.8] {
  86. // CHECK:STDOUT: @H.%return: ref bool = var <return slot>
  87. // CHECK:STDOUT: }
  88. // CHECK:STDOUT: %While.decl: While = fn_decl @While [template = constants.%struct.9] {}
  89. // CHECK:STDOUT: }
  90. // CHECK:STDOUT:
  91. // CHECK:STDOUT: fn @A() -> bool;
  92. // CHECK:STDOUT:
  93. // CHECK:STDOUT: fn @B() -> bool;
  94. // CHECK:STDOUT:
  95. // CHECK:STDOUT: fn @C() -> bool;
  96. // CHECK:STDOUT:
  97. // CHECK:STDOUT: fn @D() -> bool;
  98. // CHECK:STDOUT:
  99. // CHECK:STDOUT: fn @E() -> bool;
  100. // CHECK:STDOUT:
  101. // CHECK:STDOUT: fn @F() -> bool;
  102. // CHECK:STDOUT:
  103. // CHECK:STDOUT: fn @G() -> bool;
  104. // CHECK:STDOUT:
  105. // CHECK:STDOUT: fn @H() -> bool;
  106. // CHECK:STDOUT:
  107. // CHECK:STDOUT: fn @While() {
  108. // CHECK:STDOUT: !entry:
  109. // CHECK:STDOUT: br !while.cond.loc17
  110. // CHECK:STDOUT:
  111. // CHECK:STDOUT: !while.cond.loc17:
  112. // CHECK:STDOUT: %A.ref: A = name_ref A, file.%A.decl [template = constants.%struct.1]
  113. // CHECK:STDOUT: %A.call: init bool = call %A.ref()
  114. // CHECK:STDOUT: %.loc17_13.1: bool = value_of_initializer %A.call
  115. // CHECK:STDOUT: %.loc17_13.2: bool = converted %A.call, %.loc17_13.1
  116. // CHECK:STDOUT: if %.loc17_13.2 br !while.body.loc17 else br !while.done.loc17
  117. // CHECK:STDOUT:
  118. // CHECK:STDOUT: !while.body.loc17:
  119. // CHECK:STDOUT: %B.ref: B = name_ref B, file.%B.decl [template = constants.%struct.2]
  120. // CHECK:STDOUT: %B.call: init bool = call %B.ref()
  121. // CHECK:STDOUT: %.loc18_12.1: bool = value_of_initializer %B.call
  122. // CHECK:STDOUT: %.loc18_12.2: bool = converted %B.call, %.loc18_12.1
  123. // CHECK:STDOUT: if %.loc18_12.2 br !if.then.loc18 else br !if.else.loc18
  124. // CHECK:STDOUT:
  125. // CHECK:STDOUT: !if.then.loc18:
  126. // CHECK:STDOUT: br !while.cond.loc17
  127. // CHECK:STDOUT:
  128. // CHECK:STDOUT: !if.else.loc18:
  129. // CHECK:STDOUT: %C.ref: C = name_ref C, file.%C.decl [template = constants.%struct.3]
  130. // CHECK:STDOUT: %C.call: init bool = call %C.ref()
  131. // CHECK:STDOUT: %.loc19_12.1: bool = value_of_initializer %C.call
  132. // CHECK:STDOUT: %.loc19_12.2: bool = converted %C.call, %.loc19_12.1
  133. // CHECK:STDOUT: if %.loc19_12.2 br !if.then.loc19 else br !if.else.loc19
  134. // CHECK:STDOUT:
  135. // CHECK:STDOUT: !if.then.loc19:
  136. // CHECK:STDOUT: br !while.done.loc17
  137. // CHECK:STDOUT:
  138. // CHECK:STDOUT: !if.else.loc19:
  139. // CHECK:STDOUT: br !while.cond.loc20
  140. // CHECK:STDOUT:
  141. // CHECK:STDOUT: !while.cond.loc20:
  142. // CHECK:STDOUT: %D.ref: D = name_ref D, file.%D.decl [template = constants.%struct.4]
  143. // CHECK:STDOUT: %D.call: init bool = call %D.ref()
  144. // CHECK:STDOUT: %.loc20_15.1: bool = value_of_initializer %D.call
  145. // CHECK:STDOUT: %.loc20_15.2: bool = converted %D.call, %.loc20_15.1
  146. // CHECK:STDOUT: if %.loc20_15.2 br !while.body.loc20 else br !while.done.loc20
  147. // CHECK:STDOUT:
  148. // CHECK:STDOUT: !while.body.loc20:
  149. // CHECK:STDOUT: %E.ref: E = name_ref E, file.%E.decl [template = constants.%struct.5]
  150. // CHECK:STDOUT: %E.call: init bool = call %E.ref()
  151. // CHECK:STDOUT: %.loc21_14.1: bool = value_of_initializer %E.call
  152. // CHECK:STDOUT: %.loc21_14.2: bool = converted %E.call, %.loc21_14.1
  153. // CHECK:STDOUT: if %.loc21_14.2 br !if.then.loc21 else br !if.else.loc21
  154. // CHECK:STDOUT:
  155. // CHECK:STDOUT: !if.then.loc21:
  156. // CHECK:STDOUT: br !while.cond.loc20
  157. // CHECK:STDOUT:
  158. // CHECK:STDOUT: !if.else.loc21:
  159. // CHECK:STDOUT: %F.ref: F = name_ref F, file.%F.decl [template = constants.%struct.6]
  160. // CHECK:STDOUT: %F.call: init bool = call %F.ref()
  161. // CHECK:STDOUT: %.loc22_14.1: bool = value_of_initializer %F.call
  162. // CHECK:STDOUT: %.loc22_14.2: bool = converted %F.call, %.loc22_14.1
  163. // CHECK:STDOUT: if %.loc22_14.2 br !if.then.loc22 else br !if.else.loc22
  164. // CHECK:STDOUT:
  165. // CHECK:STDOUT: !if.then.loc22:
  166. // CHECK:STDOUT: br !while.done.loc20
  167. // CHECK:STDOUT:
  168. // CHECK:STDOUT: !if.else.loc22:
  169. // CHECK:STDOUT: br !while.cond.loc20
  170. // CHECK:STDOUT:
  171. // CHECK:STDOUT: !while.done.loc20:
  172. // CHECK:STDOUT: %G.ref: G = name_ref G, file.%G.decl [template = constants.%struct.7]
  173. // CHECK:STDOUT: %G.call: init bool = call %G.ref()
  174. // CHECK:STDOUT: %.loc24_12.1: bool = value_of_initializer %G.call
  175. // CHECK:STDOUT: %.loc24_12.2: bool = converted %G.call, %.loc24_12.1
  176. // CHECK:STDOUT: if %.loc24_12.2 br !if.then.loc24 else br !if.else.loc24
  177. // CHECK:STDOUT:
  178. // CHECK:STDOUT: !if.then.loc24:
  179. // CHECK:STDOUT: br !while.cond.loc17
  180. // CHECK:STDOUT:
  181. // CHECK:STDOUT: !if.else.loc24:
  182. // CHECK:STDOUT: %H.ref: H = name_ref H, file.%H.decl [template = constants.%struct.8]
  183. // CHECK:STDOUT: %H.call: init bool = call %H.ref()
  184. // CHECK:STDOUT: %.loc25_12.1: bool = value_of_initializer %H.call
  185. // CHECK:STDOUT: %.loc25_12.2: bool = converted %H.call, %.loc25_12.1
  186. // CHECK:STDOUT: if %.loc25_12.2 br !if.then.loc25 else br !if.else.loc25
  187. // CHECK:STDOUT:
  188. // CHECK:STDOUT: !if.then.loc25:
  189. // CHECK:STDOUT: br !while.done.loc17
  190. // CHECK:STDOUT:
  191. // CHECK:STDOUT: !if.else.loc25:
  192. // CHECK:STDOUT: br !while.cond.loc17
  193. // CHECK:STDOUT:
  194. // CHECK:STDOUT: !while.done.loc17:
  195. // CHECK:STDOUT: return
  196. // CHECK:STDOUT: }
  197. // CHECK:STDOUT: