fail_incomplete_element.carbon 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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+7]]:8: error: binding pattern has incomplete type `[Incomplete; 1]` in name binding declaration [IncompleteTypeInBindingDecl]
  12. // CHECK:STDERR: var a: array(Incomplete, 1);
  13. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
  14. // CHECK:STDERR: fail_incomplete_element.carbon:[[@LINE-5]]:1: note: class was forward declared here [ClassForwardDeclaredHere]
  15. // CHECK:STDERR: class Incomplete;
  16. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~
  17. // CHECK:STDERR:
  18. var a: array(Incomplete, 1);
  19. var p: Incomplete* = &a[0];
  20. // CHECK:STDOUT: --- fail_incomplete_element.carbon
  21. // CHECK:STDOUT:
  22. // CHECK:STDOUT: constants {
  23. // CHECK:STDOUT: %Incomplete: type = class_type @Incomplete [concrete]
  24. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete]
  25. // CHECK:STDOUT: %array_type: type = array_type %int_1, %Incomplete [concrete]
  26. // CHECK:STDOUT: %ptr: type = ptr_type %Incomplete [concrete]
  27. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
  28. // CHECK:STDOUT: }
  29. // CHECK:STDOUT:
  30. // CHECK:STDOUT: imports {
  31. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  32. // CHECK:STDOUT: import Core//prelude
  33. // CHECK:STDOUT: import Core//prelude/...
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT:
  37. // CHECK:STDOUT: file {
  38. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  39. // CHECK:STDOUT: .Core = imports.%Core
  40. // CHECK:STDOUT: .Incomplete = %Incomplete.decl
  41. // CHECK:STDOUT: .a = %a
  42. // CHECK:STDOUT: .p = %p
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT: %Core.import = import Core
  45. // CHECK:STDOUT: %Incomplete.decl: type = class_decl @Incomplete [concrete = constants.%Incomplete] {} {}
  46. // CHECK:STDOUT: name_binding_decl {
  47. // CHECK:STDOUT: %a.patt: <error> = binding_pattern a
  48. // CHECK:STDOUT: %.loc20_1: <error> = var_pattern %a.patt
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT: %a.var: ref <error> = var a
  51. // CHECK:STDOUT: %.loc20_27: type = splice_block %array_type [concrete = constants.%array_type] {
  52. // CHECK:STDOUT: %Incomplete.ref.loc20: type = name_ref Incomplete, %Incomplete.decl [concrete = constants.%Incomplete]
  53. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
  54. // CHECK:STDOUT: %array_type: type = array_type %int_1, %Incomplete [concrete = constants.%array_type]
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT: %a: <error> = bind_name a, <error>
  57. // CHECK:STDOUT: name_binding_decl {
  58. // CHECK:STDOUT: %p.patt: %ptr = binding_pattern p
  59. // CHECK:STDOUT: %.loc22_1: %ptr = var_pattern %p.patt
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT: %p.var: ref %ptr = var p
  62. // CHECK:STDOUT: %.loc22_18: type = splice_block %ptr [concrete = constants.%ptr] {
  63. // CHECK:STDOUT: %Incomplete.ref.loc22: type = name_ref Incomplete, %Incomplete.decl [concrete = constants.%Incomplete]
  64. // CHECK:STDOUT: %ptr: type = ptr_type %Incomplete [concrete = constants.%ptr]
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT: %p: ref %ptr = bind_name p, %p.var
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: class @Incomplete;
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: fn @__global_init() {
  72. // CHECK:STDOUT: !entry:
  73. // CHECK:STDOUT: %a.ref: <error> = name_ref a, file.%a
  74. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
  75. // CHECK:STDOUT: %addr: <error> = addr_of <error> [concrete = <error>]
  76. // CHECK:STDOUT: assign file.%p.var, <error>
  77. // CHECK:STDOUT: return
  78. // CHECK:STDOUT: }
  79. // CHECK:STDOUT: