fail_not_in_function.carbon 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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+9]]: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: fail_not_in_function.carbon:[[@LINE+6]]: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: fail_not_in_function.carbon:[[@LINE+3]]:22: ERROR: Semantics TODO: `Control flow expressions are currently only supported inside functions.`.
  14. // CHECK:STDERR: let x: i32 = if true then 1 else 0;
  15. // CHECK:STDERR: ^~~~~~
  16. let x: i32 = if true then 1 else 0;
  17. class C {
  18. // TODO: Should work with compile-time evaluation.
  19. // CHECK:STDERR: fail_not_in_function.carbon:[[@LINE+12]]:10: ERROR: Semantics TODO: `Control flow expressions are currently only supported inside functions.`.
  20. // CHECK:STDERR: var n: if true then i32 else f64;
  21. // CHECK:STDERR: ^~~~~~~
  22. // CHECK:STDERR: fail_not_in_function.carbon:[[@LINE+9]]: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: fail_not_in_function.carbon:[[@LINE+6]]:10: ERROR: Cannot evaluate type expression.
  26. // CHECK:STDERR: var n: if true then i32 else f64;
  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: }
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: file {
  43. // CHECK:STDOUT: %.loc17: i32 = block_arg <unexpected instblockref block6>
  44. // CHECK:STDOUT: %x: i32 = bind_name x, %.loc17
  45. // CHECK:STDOUT: %C.decl = class_decl @C, ()
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: class @C {
  49. // CHECK:STDOUT: %.loc33: bool = bool_literal true [template = constants.%.1]
  50. // CHECK:STDOUT: if %.loc33 br !if.expr.then else br !if.expr.else
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: !members:
  53. // CHECK:STDOUT: .n = <unexpected instref inst+21>
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT: