fail_not_in_function.carbon 3.2 KB

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