fail_nested_incomplete.carbon 4.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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/tuple/fail_nested_incomplete.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/tuple/fail_nested_incomplete.carbon
  10. class Incomplete;
  11. // CHECK:STDERR: fail_nested_incomplete.carbon:[[@LINE+7]]:8: error: binding pattern has incomplete type `(i32, Incomplete)` in name binding declaration [IncompleteTypeInBindingDecl]
  12. // CHECK:STDERR: var t: (i32, Incomplete);
  13. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~
  14. // CHECK:STDERR: fail_nested_incomplete.carbon:[[@LINE-5]]:1: note: class was forward declared here [ClassForwardDeclaredHere]
  15. // CHECK:STDERR: class Incomplete;
  16. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~
  17. // CHECK:STDERR:
  18. var t: (i32, Incomplete);
  19. var p: Incomplete* = &t[1];
  20. // CHECK:STDOUT: --- fail_nested_incomplete.carbon
  21. // CHECK:STDOUT:
  22. // CHECK:STDOUT: constants {
  23. // CHECK:STDOUT: %Incomplete: type = class_type @Incomplete [concrete]
  24. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  25. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  26. // CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [concrete]
  27. // CHECK:STDOUT: %tuple.type.8a4: type = tuple_type (%i32, %Incomplete) [concrete]
  28. // CHECK:STDOUT: %ptr: type = ptr_type %Incomplete [concrete]
  29. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete]
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: imports {
  33. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  34. // CHECK:STDOUT: .Int = %Core.Int
  35. // CHECK:STDOUT: import Core//prelude
  36. // CHECK:STDOUT: import Core//prelude/...
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: file {
  41. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  42. // CHECK:STDOUT: .Core = imports.%Core
  43. // CHECK:STDOUT: .Incomplete = %Incomplete.decl
  44. // CHECK:STDOUT: .t = %t
  45. // CHECK:STDOUT: .p = %p
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT: %Core.import = import Core
  48. // CHECK:STDOUT: %Incomplete.decl: type = class_decl @Incomplete [concrete = constants.%Incomplete] {} {}
  49. // CHECK:STDOUT: name_binding_decl {
  50. // CHECK:STDOUT: %t.patt: <error> = binding_pattern t
  51. // CHECK:STDOUT: %.loc20_1: <error> = var_pattern %t.patt
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT: %t.var: ref <error> = var t
  54. // CHECK:STDOUT: %.loc20_24.1: type = splice_block %.loc20_24.3 [concrete = constants.%tuple.type.8a4] {
  55. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  56. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  57. // CHECK:STDOUT: %Incomplete.ref.loc20: type = name_ref Incomplete, %Incomplete.decl [concrete = constants.%Incomplete]
  58. // CHECK:STDOUT: %.loc20_24.2: %tuple.type.24b = tuple_literal (%i32, %Incomplete.ref.loc20)
  59. // CHECK:STDOUT: %.loc20_24.3: type = converted %.loc20_24.2, constants.%tuple.type.8a4 [concrete = constants.%tuple.type.8a4]
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT: %t: <error> = bind_name t, <error>
  62. // CHECK:STDOUT: name_binding_decl {
  63. // CHECK:STDOUT: %p.patt: %ptr = binding_pattern p
  64. // CHECK:STDOUT: %.loc22_1: %ptr = var_pattern %p.patt
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT: %p.var: ref %ptr = var p
  67. // CHECK:STDOUT: %.loc22_18: type = splice_block %ptr [concrete = constants.%ptr] {
  68. // CHECK:STDOUT: %Incomplete.ref.loc22: type = name_ref Incomplete, %Incomplete.decl [concrete = constants.%Incomplete]
  69. // CHECK:STDOUT: %ptr: type = ptr_type %Incomplete [concrete = constants.%ptr]
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT: %p: ref %ptr = bind_name p, %p.var
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT:
  74. // CHECK:STDOUT: class @Incomplete;
  75. // CHECK:STDOUT:
  76. // CHECK:STDOUT: fn @__global_init() {
  77. // CHECK:STDOUT: !entry:
  78. // CHECK:STDOUT: %t.ref: <error> = name_ref t, file.%t
  79. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
  80. // CHECK:STDOUT: %addr: <error> = addr_of <error> [concrete = <error>]
  81. // CHECK:STDOUT: assign file.%p.var, <error>
  82. // CHECK:STDOUT: return
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT: