fail_not_in_function.carbon 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. // CHECK:STDERR: fail_not_in_function.carbon:[[@LINE+12]]:14: ERROR: Semantics TODO: `Control flow expressions are currently only supported inside functions.`.
  7. // CHECK:STDERR: let x: i32 = if true then 1 else 0;
  8. // CHECK:STDERR: ^~~~~~~
  9. // CHECK:STDERR:
  10. // CHECK:STDERR: fail_not_in_function.carbon:[[@LINE+8]]:14: ERROR: Semantics TODO: `Control flow expressions are currently only supported inside functions.`.
  11. // CHECK:STDERR: let x: i32 = if true then 1 else 0;
  12. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~
  13. // CHECK:STDERR:
  14. // CHECK:STDERR: fail_not_in_function.carbon:[[@LINE+4]]:22: ERROR: Semantics TODO: `Control flow expressions are currently only supported inside functions.`.
  15. // CHECK:STDERR: let x: i32 = if true then 1 else 0;
  16. // CHECK:STDERR: ^~~~~~
  17. // CHECK:STDERR:
  18. let x: i32 = if true then 1 else 0;
  19. class C {
  20. // CHECK:STDERR: fail_not_in_function.carbon:[[@LINE+11]]:10: ERROR: Semantics TODO: `Control flow expressions are currently only supported inside functions.`.
  21. // CHECK:STDERR: var n: if true then i32 else f64;
  22. // CHECK:STDERR: ^~~~~~~
  23. // CHECK:STDERR:
  24. // CHECK:STDERR: fail_not_in_function.carbon:[[@LINE+7]]:10: ERROR: Semantics TODO: `Control flow expressions are currently only supported inside functions.`.
  25. // CHECK:STDERR: var n: if true then i32 else f64;
  26. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~
  27. // CHECK:STDERR:
  28. // CHECK:STDERR: fail_not_in_function.carbon:[[@LINE+3]]:18: ERROR: Semantics TODO: `Control flow expressions are currently only supported inside functions.`.
  29. // CHECK:STDERR: var n: if true then i32 else f64;
  30. // CHECK:STDERR: ^~~~~~~~
  31. var n: if true then i32 else f64;
  32. }
  33. // CHECK:STDOUT: --- fail_not_in_function.carbon
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: constants {
  36. // CHECK:STDOUT: %.1: bool = bool_literal true [template]
  37. // CHECK:STDOUT: %.2: i32 = int_literal 1 [template]
  38. // CHECK:STDOUT: %.3: i32 = int_literal 0 [template]
  39. // CHECK:STDOUT: %C: type = class_type @C [template]
  40. // CHECK:STDOUT: %.4: type = unbound_element_type C, i32 [template]
  41. // CHECK:STDOUT: %.5: type = struct_type {.n: i32} [template]
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: file {
  45. // CHECK:STDOUT: %.loc19: i32 = block_arg <unexpected instblockref block6> [template = constants.%.2]
  46. // CHECK:STDOUT: %x: i32 = bind_name x, %.loc19
  47. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: class @C {
  51. // CHECK:STDOUT: %.loc33: bool = bool_literal true [template = constants.%.1]
  52. // CHECK:STDOUT: if %.loc33 br !if.expr.then else br !if.expr.else
  53. // CHECK:STDOUT:
  54. // CHECK:STDOUT: !members:
  55. // CHECK:STDOUT: .Self = constants.%C
  56. // CHECK:STDOUT: .n = <unexpected instref inst+23>
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT: