fail_import_misuses.carbon 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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+4]]:8: ERROR: Variable has incomplete type `Incomplete`.
  27. // CHECK:STDERR: var a: Incomplete;
  28. // CHECK:STDERR: ^~~~~~~~~~
  29. // CHECK:STDERR: fail_b.carbon: Class was forward declared here.
  30. var a: Incomplete;
  31. // CHECK:STDOUT: --- a.carbon
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: constants {
  34. // CHECK:STDOUT: %Empty: type = class_type @Empty [template]
  35. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  36. // CHECK:STDOUT: %Incomplete: type = class_type @Incomplete [template]
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: file {
  40. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  41. // CHECK:STDOUT: .Empty = %Empty.decl
  42. // CHECK:STDOUT: .Incomplete = %Incomplete.decl
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT: %Empty.decl: type = class_decl @Empty [template = constants.%Empty] {}
  45. // CHECK:STDOUT: %Incomplete.decl: type = class_decl @Incomplete [template = constants.%Incomplete] {}
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: class @Empty {
  49. // CHECK:STDOUT: !members:
  50. // CHECK:STDOUT: .Self = constants.%Empty
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: class @Incomplete;
  54. // CHECK:STDOUT:
  55. // CHECK:STDOUT: --- fail_b.carbon
  56. // CHECK:STDOUT:
  57. // CHECK:STDOUT: constants {
  58. // CHECK:STDOUT: %Empty: type = class_type @Empty [template]
  59. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  60. // CHECK:STDOUT: %.2: type = class_type @.1 [template]
  61. // CHECK:STDOUT: %Incomplete: type = class_type @Incomplete [template]
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: file {
  65. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  66. // CHECK:STDOUT: .Empty = %import_ref.1
  67. // CHECK:STDOUT: .Incomplete = %import_ref.2
  68. // CHECK:STDOUT: .a = %a
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+1, used [template = constants.%Empty]
  71. // CHECK:STDOUT: %import_ref.2: type = import_ref ir1, inst+4, used [template = constants.%Incomplete]
  72. // CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+2, unused
  73. // CHECK:STDOUT: %.decl: type = class_decl @.1 [template = constants.%.2] {
  74. // CHECK:STDOUT: %Empty.decl: invalid = class_decl @Empty [template = constants.%Empty] {}
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT: %Incomplete.decl: invalid = class_decl @Incomplete [template = constants.%Incomplete] {}
  77. // CHECK:STDOUT: %Incomplete.ref: type = name_ref Incomplete, %import_ref.2 [template = constants.%Incomplete]
  78. // CHECK:STDOUT: %a.var: ref <error> = var a
  79. // CHECK:STDOUT: %a: ref <error> = bind_name a, %a.var
  80. // CHECK:STDOUT: }
  81. // CHECK:STDOUT:
  82. // CHECK:STDOUT: class @Empty {
  83. // CHECK:STDOUT: !members:
  84. // CHECK:STDOUT: .Self = file.%import_ref.3
  85. // CHECK:STDOUT: }
  86. // CHECK:STDOUT:
  87. // CHECK:STDOUT: class @.1 {
  88. // CHECK:STDOUT: !members:
  89. // CHECK:STDOUT: .Self = constants.%.2
  90. // CHECK:STDOUT: }
  91. // CHECK:STDOUT:
  92. // CHECK:STDOUT: class @Incomplete;
  93. // CHECK:STDOUT: