fail_todo_control_flow_init.carbon 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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/var/fail_todo_control_flow_init.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/var/fail_todo_control_flow_init.carbon
  10. // CHECK:STDERR: fail_todo_control_flow_init.carbon:[[@LINE+12]]:13: error: semantics TODO: `Control flow expressions are currently only supported inside functions.`
  11. // CHECK:STDERR: var x: () = if true then () else ();
  12. // CHECK:STDERR: ^~~~~~~
  13. // CHECK:STDERR:
  14. // CHECK:STDERR: fail_todo_control_flow_init.carbon:[[@LINE+8]]:13: error: semantics TODO: `Control flow expressions are currently only supported inside functions.`
  15. // CHECK:STDERR: var x: () = if true then () else ();
  16. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~
  17. // CHECK:STDERR:
  18. // CHECK:STDERR: fail_todo_control_flow_init.carbon:[[@LINE+4]]:21: error: semantics TODO: `Control flow expressions are currently only supported inside functions.`
  19. // CHECK:STDERR: var x: () = if true then () else ();
  20. // CHECK:STDERR: ^~~~~~~
  21. // CHECK:STDERR:
  22. var x: () = if true then () else ();
  23. // CHECK:STDERR: fail_todo_control_flow_init.carbon:[[@LINE+12]]:14: error: semantics TODO: `Control flow expressions are currently only supported inside functions.`
  24. // CHECK:STDERR: var x2: () = if false then () else ();
  25. // CHECK:STDERR: ^~~~~~~~
  26. // CHECK:STDERR:
  27. // CHECK:STDERR: fail_todo_control_flow_init.carbon:[[@LINE+8]]:14: error: semantics TODO: `Control flow expressions are currently only supported inside functions.`
  28. // CHECK:STDERR: var x2: () = if false then () else ();
  29. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~
  30. // CHECK:STDERR:
  31. // CHECK:STDERR: fail_todo_control_flow_init.carbon:[[@LINE+4]]:23: error: semantics TODO: `Control flow expressions are currently only supported inside functions.`
  32. // CHECK:STDERR: var x2: () = if false then () else ();
  33. // CHECK:STDERR: ^~~~~~~
  34. // CHECK:STDERR:
  35. var x2: () = if false then () else ();
  36. // CHECK:STDERR: fail_todo_control_flow_init.carbon:[[@LINE+8]]:15: error: semantics TODO: `Control flow expressions are currently only supported inside functions.`
  37. // CHECK:STDERR: var y: bool = true or false;
  38. // CHECK:STDERR: ^~~~~~~
  39. // CHECK:STDERR:
  40. // CHECK:STDERR: fail_todo_control_flow_init.carbon:[[@LINE+4]]:15: error: semantics TODO: `Control flow expressions are currently only supported inside functions.`
  41. // CHECK:STDERR: var y: bool = true or false;
  42. // CHECK:STDERR: ^~~~~~~~~~~~~
  43. // CHECK:STDERR:
  44. var y: bool = true or false;
  45. // CHECK:STDERR: fail_todo_control_flow_init.carbon:[[@LINE+7]]:16: error: semantics TODO: `Control flow expressions are currently only supported inside functions.`
  46. // CHECK:STDERR: var y2: bool = false or true;
  47. // CHECK:STDERR: ^~~~~~~~
  48. // CHECK:STDERR:
  49. // CHECK:STDERR: fail_todo_control_flow_init.carbon:[[@LINE+3]]:16: error: semantics TODO: `Control flow expressions are currently only supported inside functions.`
  50. // CHECK:STDERR: var y2: bool = false or true;
  51. // CHECK:STDERR: ^~~~~~~~~~~~~
  52. var y2: bool = false or true;
  53. // CHECK:STDOUT: --- fail_todo_control_flow_init.carbon
  54. // CHECK:STDOUT:
  55. // CHECK:STDOUT: constants {
  56. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  57. // CHECK:STDOUT: %.2: bool = bool_literal true [template]
  58. // CHECK:STDOUT: %tuple: %.1 = tuple_value () [template]
  59. // CHECK:STDOUT: %.3: bool = bool_literal false [template]
  60. // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template]
  61. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template]
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: imports {
  65. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  66. // CHECK:STDOUT: .Bool = %import_ref
  67. // CHECK:STDOUT: import Core//prelude
  68. // CHECK:STDOUT: import Core//prelude/operators
  69. // CHECK:STDOUT: import Core//prelude/types
  70. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  71. // CHECK:STDOUT: import Core//prelude/operators/as
  72. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  73. // CHECK:STDOUT: import Core//prelude/operators/comparison
  74. // CHECK:STDOUT: import Core//prelude/types/bool
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT: %import_ref: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool]
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: file {
  80. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  81. // CHECK:STDOUT: .Core = imports.%Core
  82. // CHECK:STDOUT: .x = %x
  83. // CHECK:STDOUT: .x2 = %x2
  84. // CHECK:STDOUT: .y = %y
  85. // CHECK:STDOUT: .y2 = %y2
  86. // CHECK:STDOUT: }
  87. // CHECK:STDOUT: %Core.import = import Core
  88. // CHECK:STDOUT: %.loc23_9.1: %.1 = tuple_literal ()
  89. // CHECK:STDOUT: %.loc23_9.2: type = converted %.loc23_9.1, constants.%.1 [template = constants.%.1]
  90. // CHECK:STDOUT: %x.var: ref %.1 = var x
  91. // CHECK:STDOUT: %x: ref %.1 = bind_name x, %x.var
  92. // CHECK:STDOUT: %.loc37_10.1: %.1 = tuple_literal ()
  93. // CHECK:STDOUT: %.loc37_10.2: type = converted %.loc37_10.1, constants.%.1 [template = constants.%.1]
  94. // CHECK:STDOUT: %x2.var: ref %.1 = var x2
  95. // CHECK:STDOUT: %x2: ref %.1 = bind_name x2, %x2.var
  96. // CHECK:STDOUT: %bool.make_type.loc47: init type = call constants.%Bool() [template = bool]
  97. // CHECK:STDOUT: %.loc47_8.1: type = value_of_initializer %bool.make_type.loc47 [template = bool]
  98. // CHECK:STDOUT: %.loc47_8.2: type = converted %bool.make_type.loc47, %.loc47_8.1 [template = bool]
  99. // CHECK:STDOUT: %y.var: ref bool = var y
  100. // CHECK:STDOUT: %y: ref bool = bind_name y, %y.var
  101. // CHECK:STDOUT: %bool.make_type.loc56: init type = call constants.%Bool() [template = bool]
  102. // CHECK:STDOUT: %.loc56_9.1: type = value_of_initializer %bool.make_type.loc56 [template = bool]
  103. // CHECK:STDOUT: %.loc56_9.2: type = converted %bool.make_type.loc56, %.loc56_9.1 [template = bool]
  104. // CHECK:STDOUT: %y2.var: ref bool = var y2
  105. // CHECK:STDOUT: %y2: ref bool = bind_name y2, %y2.var
  106. // CHECK:STDOUT: }
  107. // CHECK:STDOUT:
  108. // CHECK:STDOUT: fn @Bool() -> type = "bool.make_type";
  109. // CHECK:STDOUT:
  110. // CHECK:STDOUT: fn @__global_init() {
  111. // CHECK:STDOUT: !entry:
  112. // CHECK:STDOUT: %.loc23: bool = bool_literal true [template = constants.%.2]
  113. // CHECK:STDOUT: if %.loc23 br !if.expr.then else br !if.expr.else
  114. // CHECK:STDOUT: }
  115. // CHECK:STDOUT: