fail_import_misuses.carbon 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. // --- a.carbon
  7. library "a" api;
  8. class Empty {
  9. }
  10. class Incomplete;
  11. // --- fail_b.carbon
  12. library "b" api;
  13. import library "a";
  14. // CHECK:STDERR: fail_b.carbon:[[@LINE+6]]:1: ERROR: Duplicate name being declared in the same scope.
  15. // CHECK:STDERR: class Empty {
  16. // CHECK:STDERR: ^~~~~~~~~~~~~
  17. // CHECK:STDERR: a.carbon:4:1: Name is previously declared here.
  18. // CHECK:STDERR: class Empty {
  19. // CHECK:STDERR: ^~~~~~~~~~~~~
  20. class Empty {
  21. }
  22. // CHECK:STDERR: fail_b.carbon:[[@LINE+4]]:8: ERROR: Variable has incomplete type `Incomplete`.
  23. // CHECK:STDERR: var a: Incomplete;
  24. // CHECK:STDERR: ^~~~~~~~~~
  25. // CHECK:STDERR: fail_b.carbon: Class was forward declared here.
  26. var a: Incomplete;
  27. // CHECK:STDOUT: --- a.carbon
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: constants {
  30. // CHECK:STDOUT: %Empty: type = class_type @Empty [template]
  31. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  32. // CHECK:STDOUT: %Incomplete: type = class_type @Incomplete [template]
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: file {
  36. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  37. // CHECK:STDOUT: .Empty = %Empty.decl
  38. // CHECK:STDOUT: .Incomplete = %Incomplete.decl
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: %Empty.decl: type = class_decl @Empty [template = constants.%Empty] {}
  41. // CHECK:STDOUT: %Incomplete.decl: type = class_decl @Incomplete [template = constants.%Incomplete] {}
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: class @Empty {
  45. // CHECK:STDOUT: !members:
  46. // CHECK:STDOUT: .Self = constants.%Empty
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: class @Incomplete;
  50. // CHECK:STDOUT:
  51. // CHECK:STDOUT: --- fail_b.carbon
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: constants {
  54. // CHECK:STDOUT: %Empty: type = class_type @Empty [template]
  55. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  56. // CHECK:STDOUT: %.2: type = class_type @.1 [template]
  57. // CHECK:STDOUT: %Incomplete: type = class_type @Incomplete [template]
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: file {
  61. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  62. // CHECK:STDOUT: .Empty = %import_ref.1
  63. // CHECK:STDOUT: .Incomplete = %import_ref.2
  64. // CHECK:STDOUT: .a = %a
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+1, used [template = constants.%Empty]
  67. // CHECK:STDOUT: %import_ref.2: type = import_ref ir1, inst+4, used [template = constants.%Incomplete]
  68. // CHECK:STDOUT: %.decl: type = class_decl @.1 [template = constants.%.2] {
  69. // CHECK:STDOUT: %Empty.decl: invalid = class_decl @Empty [template = constants.%Empty] {}
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT: %Incomplete.decl: invalid = class_decl @Incomplete [template = constants.%Incomplete] {}
  72. // CHECK:STDOUT: %Incomplete.ref: type = name_ref Incomplete, %import_ref.2 [template = constants.%Incomplete]
  73. // CHECK:STDOUT: %a.var: ref <error> = var a
  74. // CHECK:STDOUT: %a: ref <error> = bind_name a, %a.var
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT:
  77. // CHECK:STDOUT: class @Empty {
  78. // CHECK:STDOUT: %import_ref = import_ref ir1, inst+2, unused
  79. // CHECK:STDOUT:
  80. // CHECK:STDOUT: !members:
  81. // CHECK:STDOUT: .Self = %import_ref
  82. // CHECK:STDOUT: }
  83. // CHECK:STDOUT:
  84. // CHECK:STDOUT: class @.1 {
  85. // CHECK:STDOUT: !members:
  86. // CHECK:STDOUT: .Self = constants.%.2
  87. // CHECK:STDOUT: }
  88. // CHECK:STDOUT:
  89. // CHECK:STDOUT: class @Incomplete;
  90. // CHECK:STDOUT: