fail_import_misuses.carbon 4.0 KB

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