fail_nested_incomplete.carbon 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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/struct/no_prelude/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/struct/no_prelude/fail_nested_incomplete.carbon
  10. class Incomplete;
  11. // CHECK:STDERR: fail_nested_incomplete.carbon:[[@LINE+6]]:8: ERROR: Variable has incomplete type `{.a: Incomplete}`.
  12. // CHECK:STDERR: var s: {.a: 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 s: {.a: Incomplete};
  18. var p: Incomplete* = &s.a;
  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: %.1: type = struct_type {.a: %Incomplete} [template]
  24. // CHECK:STDOUT: %.2: type = ptr_type %Incomplete [template]
  25. // CHECK:STDOUT: }
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: file {
  28. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  29. // CHECK:STDOUT: .Incomplete = %Incomplete.decl
  30. // CHECK:STDOUT: .s = %s
  31. // CHECK:STDOUT: .p = %p
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT: %Incomplete.decl: type = class_decl @Incomplete [template = constants.%Incomplete] {}
  34. // CHECK:STDOUT: %Incomplete.ref.loc19: type = name_ref Incomplete, %Incomplete.decl [template = constants.%Incomplete]
  35. // CHECK:STDOUT: %.loc19: type = struct_type {.a: %Incomplete} [template = constants.%.1]
  36. // CHECK:STDOUT: %s.var: ref <error> = var s
  37. // CHECK:STDOUT: %s: ref <error> = bind_name s, %s.var
  38. // CHECK:STDOUT: %Incomplete.ref.loc21: type = name_ref Incomplete, %Incomplete.decl [template = constants.%Incomplete]
  39. // CHECK:STDOUT: %.loc21: type = ptr_type %Incomplete [template = constants.%.2]
  40. // CHECK:STDOUT: %p.var: ref %.2 = var p
  41. // CHECK:STDOUT: %p: ref %.2 = bind_name p, %p.var
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: class @Incomplete;
  45. // CHECK:STDOUT:
  46. // CHECK:STDOUT: fn @__global_init() {
  47. // CHECK:STDOUT: !entry:
  48. // CHECK:STDOUT: %s.ref: ref <error> = name_ref s, file.%s
  49. // CHECK:STDOUT: %.loc21: <error> = addr_of <error> [template = <error>]
  50. // CHECK:STDOUT: assign file.%p.var, <error>
  51. // CHECK:STDOUT: return
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT: