fail_nested_incomplete.carbon 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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+6]]:8: ERROR: Variable has incomplete type `(i32, Incomplete)`.
  12. // CHECK:STDERR: var t: (i32, Incomplete);
  13. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~
  14. // CHECK:STDERR: fail_nested_incomplete.carbon:[[@LINE-5]]:1: Class was forward declared here.
  15. // CHECK:STDERR: class Incomplete;
  16. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~
  17. var t: (i32, Incomplete);
  18. var p: Incomplete* = &t[1];
  19. // CHECK:STDOUT: --- fail_nested_incomplete.carbon
  20. // CHECK:STDOUT:
  21. // CHECK:STDOUT: constants {
  22. // CHECK:STDOUT: %Incomplete: type = class_type @Incomplete [template]
  23. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  24. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  25. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  26. // CHECK:STDOUT: %.2: type = tuple_type (type, type) [template]
  27. // CHECK:STDOUT: %.3: type = tuple_type (i32, %Incomplete) [template]
  28. // CHECK:STDOUT: %.4: type = ptr_type %Incomplete [template]
  29. // CHECK:STDOUT: %.5: i32 = int_literal 1 [template]
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: imports {
  33. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  34. // CHECK:STDOUT: .Int32 = %import_ref
  35. // CHECK:STDOUT: import Core//prelude
  36. // CHECK:STDOUT: import Core//prelude/operators
  37. // CHECK:STDOUT: import Core//prelude/types
  38. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  39. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  40. // CHECK:STDOUT: import Core//prelude/operators/comparison
  41. // CHECK:STDOUT: import Core//prelude/types/bool
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT:
  46. // CHECK:STDOUT: file {
  47. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  48. // CHECK:STDOUT: .Core = imports.%Core
  49. // CHECK:STDOUT: .Incomplete = %Incomplete.decl
  50. // CHECK:STDOUT: .t = %t
  51. // CHECK:STDOUT: .p = %p
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT: %Core.import = import Core
  54. // CHECK:STDOUT: %Incomplete.decl: type = class_decl @Incomplete [template = constants.%Incomplete] {}
  55. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  56. // CHECK:STDOUT: %Incomplete.ref.loc19: type = name_ref Incomplete, %Incomplete.decl [template = constants.%Incomplete]
  57. // CHECK:STDOUT: %.loc19_24.1: %.2 = tuple_literal (%int.make_type_32, %Incomplete.ref.loc19)
  58. // CHECK:STDOUT: %.loc19_24.2: type = value_of_initializer %int.make_type_32 [template = i32]
  59. // CHECK:STDOUT: %.loc19_24.3: type = converted %int.make_type_32, %.loc19_24.2 [template = i32]
  60. // CHECK:STDOUT: %.loc19_24.4: type = converted %.loc19_24.1, constants.%.3 [template = constants.%.3]
  61. // CHECK:STDOUT: %t.var: ref <error> = var t
  62. // CHECK:STDOUT: %t: ref <error> = bind_name t, %t.var
  63. // CHECK:STDOUT: %Incomplete.ref.loc21: type = name_ref Incomplete, %Incomplete.decl [template = constants.%Incomplete]
  64. // CHECK:STDOUT: %.loc21: type = ptr_type %Incomplete [template = constants.%.4]
  65. // CHECK:STDOUT: %p.var: ref %.4 = var p
  66. // CHECK:STDOUT: %p: ref %.4 = bind_name p, %p.var
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: class @Incomplete;
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: fn @__global_init() {
  74. // CHECK:STDOUT: !entry:
  75. // CHECK:STDOUT: %t.ref: ref <error> = name_ref t, file.%t
  76. // CHECK:STDOUT: %.loc21_25: i32 = int_literal 1 [template = constants.%.5]
  77. // CHECK:STDOUT: %.loc21_22: <error> = addr_of <error> [template = <error>]
  78. // CHECK:STDOUT: assign file.%p.var, <error>
  79. // CHECK:STDOUT: return
  80. // CHECK:STDOUT: }
  81. // CHECK:STDOUT: