fail_control_flow.carbon 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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/alias/fail_control_flow.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/alias/fail_control_flow.carbon
  10. // --- fail_simple.carbon
  11. library "[[@TEST_NAME]]";
  12. // CHECK:STDERR: fail_simple.carbon:[[@LINE+8]]:11: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo]
  13. // CHECK:STDERR: alias a = true or false;
  14. // CHECK:STDERR: ^~~~~~~
  15. // CHECK:STDERR:
  16. // CHECK:STDERR: fail_simple.carbon:[[@LINE+4]]:11: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo]
  17. // CHECK:STDERR: alias a = true or false;
  18. // CHECK:STDERR: ^~~~~~~~~~~~~
  19. // CHECK:STDERR:
  20. alias a = true or false;
  21. // --- fail_nested.carbon
  22. library "[[@TEST_NAME]]";
  23. base class C(B:! bool) {}
  24. fn F() {
  25. class B {
  26. // CHECK:STDERR: fail_nested.carbon:[[@LINE+4]]:20: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo]
  27. // CHECK:STDERR: extend base: C(true or false);
  28. // CHECK:STDERR: ^~~~~~~~~~~~~
  29. // CHECK:STDERR:
  30. extend base: C(true or false);
  31. }
  32. }
  33. // CHECK:STDOUT: --- fail_simple.carbon
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: constants {
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: file {}
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: --- fail_nested.carbon
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: constants {
  43. // CHECK:STDOUT: %B.7dd: bool = bind_symbolic_name B, 0 [symbolic]
  44. // CHECK:STDOUT: %C.type: type = generic_class_type @C [concrete]
  45. // CHECK:STDOUT: %C.generic: %C.type = struct_value () [concrete]
  46. // CHECK:STDOUT: %C: type = class_type @C, @C(%B.7dd) [symbolic]
  47. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  48. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  49. // CHECK:STDOUT: %B.d97: type = class_type @B [concrete]
  50. // CHECK:STDOUT: %true: bool = bool_literal true [concrete]
  51. // CHECK:STDOUT: %false: bool = bool_literal false [concrete]
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT:
  54. // CHECK:STDOUT: file {}
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: generic class @C(<unexpected>.inst28.loc4_14: bool) {
  57. // CHECK:STDOUT: %B: bool = bind_symbolic_name B, 0 [symbolic = %B (constants.%B.7dd)]
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: !definition:
  60. // CHECK:STDOUT:
  61. // CHECK:STDOUT: class {
  62. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  63. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  64. // CHECK:STDOUT: complete_type_witness = %complete_type
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: !members:
  67. // CHECK:STDOUT: .Self = constants.%C
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: class @B {
  72. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, <unexpected>.inst34.loc4_24 [concrete = constants.%C.generic]
  73. // CHECK:STDOUT: %true.loc12_20: bool = bool_literal true [concrete = constants.%true]
  74. // CHECK:STDOUT: %.loc12: bool = not %true.loc12_20 [concrete = constants.%false]
  75. // CHECK:STDOUT: %true.loc12_25: bool = bool_literal true [concrete = constants.%true]
  76. // CHECK:STDOUT: if %.loc12 br !or.rhs else br !or.result(%true.loc12_25)
  77. // CHECK:STDOUT: complete_type_witness = invalid
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: !members:
  80. // CHECK:STDOUT: .Self = constants.%B.d97
  81. // CHECK:STDOUT: .C = <poisoned>
  82. // CHECK:STDOUT: }
  83. // CHECK:STDOUT:
  84. // CHECK:STDOUT: fn @F();
  85. // CHECK:STDOUT:
  86. // CHECK:STDOUT: specific @C(constants.%B.7dd) {
  87. // CHECK:STDOUT: %B => constants.%B.7dd
  88. // CHECK:STDOUT: }
  89. // CHECK:STDOUT: