fail_incomplete_element.carbon 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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/array/fail_incomplete_element.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/fail_incomplete_element.carbon
  10. class Incomplete;
  11. // CHECK:STDERR: fail_incomplete_element.carbon:[[@LINE+6]]:8: error: Variable has incomplete type `[Incomplete; 1]`
  12. // CHECK:STDERR: var a: [Incomplete; 1];
  13. // CHECK:STDERR: ^~~~~~~~~~~~~~~
  14. // CHECK:STDERR: fail_incomplete_element.carbon:[[@LINE-5]]:1: note: class was forward declared here
  15. // CHECK:STDERR: class Incomplete;
  16. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~
  17. var a: [Incomplete; 1];
  18. var p: Incomplete* = &a[0];
  19. // CHECK:STDOUT: --- fail_incomplete_element.carbon
  20. // CHECK:STDOUT:
  21. // CHECK:STDOUT: constants {
  22. // CHECK:STDOUT: %Incomplete: type = class_type @Incomplete [template]
  23. // CHECK:STDOUT: %.1: i32 = int_literal 1 [template]
  24. // CHECK:STDOUT: %.2: type = array_type %.1, %Incomplete [template]
  25. // CHECK:STDOUT: %.3: type = ptr_type %Incomplete [template]
  26. // CHECK:STDOUT: %.4: i32 = int_literal 0 [template]
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: imports {
  30. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  31. // CHECK:STDOUT: import Core//prelude
  32. // CHECK:STDOUT: import Core//prelude/operators
  33. // CHECK:STDOUT: import Core//prelude/types
  34. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  35. // CHECK:STDOUT: import Core//prelude/operators/as
  36. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  37. // CHECK:STDOUT: import Core//prelude/operators/comparison
  38. // CHECK:STDOUT: import Core//prelude/types/bool
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: file {
  43. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  44. // CHECK:STDOUT: .Core = imports.%Core
  45. // CHECK:STDOUT: .Incomplete = %Incomplete.decl
  46. // CHECK:STDOUT: .a = %a
  47. // CHECK:STDOUT: .p = %p
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: %Core.import = import Core
  50. // CHECK:STDOUT: %Incomplete.decl: type = class_decl @Incomplete [template = constants.%Incomplete] {} {}
  51. // CHECK:STDOUT: %Incomplete.ref.loc19: type = name_ref Incomplete, %Incomplete.decl [template = constants.%Incomplete]
  52. // CHECK:STDOUT: %.loc19_21: i32 = int_literal 1 [template = constants.%.1]
  53. // CHECK:STDOUT: %.loc19_22: type = array_type %.loc19_21, %Incomplete [template = constants.%.2]
  54. // CHECK:STDOUT: %a.var: ref <error> = var a
  55. // CHECK:STDOUT: %a: ref <error> = bind_name a, %a.var
  56. // CHECK:STDOUT: %Incomplete.ref.loc21: type = name_ref Incomplete, %Incomplete.decl [template = constants.%Incomplete]
  57. // CHECK:STDOUT: %.loc21: type = ptr_type %Incomplete [template = constants.%.3]
  58. // CHECK:STDOUT: %p.var: ref %.3 = var p
  59. // CHECK:STDOUT: %p: ref %.3 = bind_name p, %p.var
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: class @Incomplete;
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: fn @__global_init() {
  65. // CHECK:STDOUT: !entry:
  66. // CHECK:STDOUT: %a.ref: ref <error> = name_ref a, file.%a
  67. // CHECK:STDOUT: %.loc21_25: i32 = int_literal 0 [template = constants.%.4]
  68. // CHECK:STDOUT: %.loc21_22: <error> = addr_of <error> [template = <error>]
  69. // CHECK:STDOUT: assign file.%p.var, <error>
  70. // CHECK:STDOUT: return
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT: