fail_incomplete_element.carbon 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. class Incomplete;
  7. // CHECK:STDERR: fail_incomplete_element.carbon:[[@LINE+6]]:8: ERROR: Variable has incomplete type `[Incomplete; 1]`.
  8. // CHECK:STDERR: var a: [Incomplete; 1];
  9. // CHECK:STDERR: ^~~~~~~~~~~~~~~
  10. // CHECK:STDERR: fail_incomplete_element.carbon:[[@LINE-5]]:1: Class was forward declared here.
  11. // CHECK:STDERR: class Incomplete;
  12. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~
  13. var a: [Incomplete; 1];
  14. // CHECK:STDERR: fail_incomplete_element.carbon:[[@LINE+3]]:1: ERROR: Cannot implicitly convert from `<error>*` to `Incomplete*`.
  15. // CHECK:STDERR: var p: Incomplete* = &a[0];
  16. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  17. var p: Incomplete* = &a[0];
  18. // CHECK:STDOUT: --- fail_incomplete_element.carbon
  19. // CHECK:STDOUT:
  20. // CHECK:STDOUT: constants {
  21. // CHECK:STDOUT: %Incomplete: type = class_type @Incomplete [template]
  22. // CHECK:STDOUT: %.1: i32 = int_literal 1 [template]
  23. // CHECK:STDOUT: %.2: type = array_type %.1, Incomplete [template]
  24. // CHECK:STDOUT: %.3: type = ptr_type Incomplete [template]
  25. // CHECK:STDOUT: %.4: i32 = int_literal 0 [template]
  26. // CHECK:STDOUT: %.5: type = ptr_type <error> [template]
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: file {
  30. // CHECK:STDOUT: package: <namespace> = namespace package, {.Incomplete = %Incomplete.decl, .a = %a, .p = %p} [template]
  31. // CHECK:STDOUT: %Incomplete.decl = class_decl @Incomplete, ()
  32. // CHECK:STDOUT: %Incomplete.ref.loc15: type = name_ref Incomplete, constants.%Incomplete [template = constants.%Incomplete]
  33. // CHECK:STDOUT: %.loc15_21: i32 = int_literal 1 [template = constants.%.1]
  34. // CHECK:STDOUT: %.loc15_22: type = array_type %.loc15_21, Incomplete [template = constants.%.2]
  35. // CHECK:STDOUT: %a.var: ref <error> = var a
  36. // CHECK:STDOUT: %a: ref <error> = bind_name a, %a.var
  37. // CHECK:STDOUT: %Incomplete.ref.loc20: type = name_ref Incomplete, constants.%Incomplete [template = constants.%Incomplete]
  38. // CHECK:STDOUT: %.loc20_18: type = ptr_type Incomplete [template = constants.%.3]
  39. // CHECK:STDOUT: %p.var: ref Incomplete* = var p
  40. // CHECK:STDOUT: %p: ref Incomplete* = bind_name p, %p.var
  41. // CHECK:STDOUT: %a.ref: ref <error> = name_ref a, %a
  42. // CHECK:STDOUT: %.loc20_25: i32 = int_literal 0 [template = constants.%.4]
  43. // CHECK:STDOUT: %.loc20_22: <error>* = addr_of <error> [template = <error>]
  44. // CHECK:STDOUT: assign %p.var, <error>
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: class @Incomplete;
  48. // CHECK:STDOUT: