fail_not_in_function.carbon 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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]]:22: 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]]:29: 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]]:18: 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]]:27: ERROR: Semantics TODO: `Control flow expressions are currently only supported inside functions.`.
  26. // CHECK:STDERR: var n: if true then i32 else f64;
  27. // CHECK:STDERR: ^
  28. // CHECK:STDERR: fail_not_in_function.carbon:[[@LINE+3]]:27: ERROR: Cannot evaluate type expression.
  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: constants {
  34. // CHECK:STDOUT: %.loc34: type = struct_type {.n: <error>}
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT:
  37. // CHECK:STDOUT: file "fail_not_in_function.carbon" {
  38. // CHECK:STDOUT: %.loc17: i32 = block_arg <unexpected instblockref block4>
  39. // CHECK:STDOUT: %x: i32 = bind_name x, %.loc17
  40. // CHECK:STDOUT: class_decl @C, ()
  41. // CHECK:STDOUT: %C: type = class_type @C
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: class @C {
  45. // CHECK:STDOUT: %.loc33: bool = bool_literal true
  46. // CHECK:STDOUT: if %.loc33 br !if.expr.then else br !if.expr.else
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: !members:
  49. // CHECK:STDOUT: .n = <unexpected instref inst+20>
  50. // CHECK:STDOUT: }