fail_todo_control_flow_init.carbon 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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: file {
  65. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  66. // CHECK:STDOUT: .Core = %Core
  67. // CHECK:STDOUT: .x = %x
  68. // CHECK:STDOUT: .x2 = %x2
  69. // CHECK:STDOUT: .y = %y
  70. // CHECK:STDOUT: .y2 = %y2
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  73. // CHECK:STDOUT: %.loc23_9.1: %.1 = tuple_literal ()
  74. // CHECK:STDOUT: %.loc23_9.2: type = converted %.loc23_9.1, constants.%.1 [template = constants.%.1]
  75. // CHECK:STDOUT: %x.var: ref %.1 = var x
  76. // CHECK:STDOUT: %x: ref %.1 = bind_name x, %x.var
  77. // CHECK:STDOUT: %.loc37_10.1: %.1 = tuple_literal ()
  78. // CHECK:STDOUT: %.loc37_10.2: type = converted %.loc37_10.1, constants.%.1 [template = constants.%.1]
  79. // CHECK:STDOUT: %x2.var: ref %.1 = var x2
  80. // CHECK:STDOUT: %x2: ref %.1 = bind_name x2, %x2.var
  81. // CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool]
  82. // CHECK:STDOUT: %bool.make_type.loc47: init type = call constants.%Bool() [template = bool]
  83. // CHECK:STDOUT: %.loc47_8.1: type = value_of_initializer %bool.make_type.loc47 [template = bool]
  84. // CHECK:STDOUT: %.loc47_8.2: type = converted %bool.make_type.loc47, %.loc47_8.1 [template = bool]
  85. // CHECK:STDOUT: %y.var: ref bool = var y
  86. // CHECK:STDOUT: %y: ref bool = bind_name y, %y.var
  87. // CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool]
  88. // CHECK:STDOUT: %bool.make_type.loc56: init type = call constants.%Bool() [template = bool]
  89. // CHECK:STDOUT: %.loc56_9.1: type = value_of_initializer %bool.make_type.loc56 [template = bool]
  90. // CHECK:STDOUT: %.loc56_9.2: type = converted %bool.make_type.loc56, %.loc56_9.1 [template = bool]
  91. // CHECK:STDOUT: %y2.var: ref bool = var y2
  92. // CHECK:STDOUT: %y2: ref bool = bind_name y2, %y2.var
  93. // CHECK:STDOUT: }
  94. // CHECK:STDOUT:
  95. // CHECK:STDOUT: fn @Bool() -> type = "bool.make_type";
  96. // CHECK:STDOUT:
  97. // CHECK:STDOUT: fn @__global_init() {
  98. // CHECK:STDOUT: !entry:
  99. // CHECK:STDOUT: %.loc23: bool = bool_literal true [template = constants.%.2]
  100. // CHECK:STDOUT: if %.loc23 br !if.expr.then else br !if.expr.else
  101. // CHECK:STDOUT: }
  102. // CHECK:STDOUT: