import.carbon 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. // --- foo.carbon
  7. library "foo" api;
  8. class Class(T:! type);
  9. // --- foo.impl.carbon
  10. library "foo" impl;
  11. class Class(T:! type) {
  12. var x: T;
  13. }
  14. // --- fail_bad_foo.impl.carbon
  15. library "foo" impl;
  16. // CHECK:STDERR: fail_bad_foo.impl.carbon:[[@LINE+5]]:13: ERROR: Redeclaration differs at parameter 1.
  17. // CHECK:STDERR: class Class(U:! type) {
  18. // CHECK:STDERR: ^
  19. // CHECK:STDERR: fail_bad_foo.impl.carbon: Previous declaration's corresponding parameter here.
  20. // CHECK:STDERR:
  21. class Class(U:! type) {
  22. // CHECK:STDERR: fail_bad_foo.impl.carbon:[[@LINE+3]]:10: ERROR: Name `T` not found.
  23. // CHECK:STDERR: var x: T;
  24. // CHECK:STDERR: ^
  25. var x: T;
  26. }
  27. // CHECK:STDOUT: --- foo.carbon
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: constants {
  30. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic]
  31. // CHECK:STDOUT: %Class.1: type = generic_class_type @Class [template]
  32. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  33. // CHECK:STDOUT: %struct: Class = struct_value () [template]
  34. // CHECK:STDOUT: %Class.2: type = class_type @Class [template]
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT:
  37. // CHECK:STDOUT: file {
  38. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  39. // CHECK:STDOUT: .Core = %Core
  40. // CHECK:STDOUT: .Class = %Class.decl
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  43. // CHECK:STDOUT: %Class.decl: Class = class_decl @Class [template = constants.%struct] {
  44. // CHECK:STDOUT: %T.loc4_13.1: type = param T
  45. // CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = constants.%T]
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: class @Class;
  50. // CHECK:STDOUT:
  51. // CHECK:STDOUT: --- foo.impl.carbon
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: constants {
  54. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0, <unexpected instref inst+11> [symbolic]
  55. // CHECK:STDOUT: %Class: type = generic_class_type @Class [template]
  56. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  57. // CHECK:STDOUT: %struct.1: Class = struct_value () [template]
  58. // CHECK:STDOUT: %struct.2: type = struct_value () [template]
  59. // CHECK:STDOUT: %.2: type = unbound_element_type <cannot stringify inst+9>, T [symbolic]
  60. // CHECK:STDOUT: %.3: type = struct_type {.x: T} [symbolic]
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT:
  63. // CHECK:STDOUT: file {
  64. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  65. // CHECK:STDOUT: .Core = %Core
  66. // CHECK:STDOUT: .Class = %Class.decl
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT: %import_ref: Class = import_ref ir0, inst+5, loaded [template = constants.%struct.1]
  69. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  70. // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%struct.2] {
  71. // CHECK:STDOUT: %T.loc4_13.1: type = param T
  72. // CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = constants.%T]
  73. // CHECK:STDOUT: }
  74. // CHECK:STDOUT: }
  75. // CHECK:STDOUT:
  76. // CHECK:STDOUT: class @Class {
  77. // CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc4_13.2 [symbolic = constants.%T]
  78. // CHECK:STDOUT: %.loc5: <unbound element of class <cannot stringify inst+9>> = field_decl x, element0 [template]
  79. // CHECK:STDOUT:
  80. // CHECK:STDOUT: !members:
  81. // CHECK:STDOUT: .Self = constants.%struct.1
  82. // CHECK:STDOUT: .x = %.loc5
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT:
  85. // CHECK:STDOUT: --- fail_bad_foo.impl.carbon
  86. // CHECK:STDOUT:
  87. // CHECK:STDOUT: constants {
  88. // CHECK:STDOUT: %U: type = bind_symbolic_name U 0 [symbolic]
  89. // CHECK:STDOUT: %Class: type = generic_class_type @Class [template]
  90. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  91. // CHECK:STDOUT: %struct.1: Class = struct_value () [template]
  92. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0, <unexpected instref inst+12> [symbolic]
  93. // CHECK:STDOUT: %.2: type = generic_class_type @.1 [template]
  94. // CHECK:STDOUT: %struct.2: <invalid> = struct_value () [template]
  95. // CHECK:STDOUT: %.3: type = class_type @.1 [template]
  96. // CHECK:STDOUT: }
  97. // CHECK:STDOUT:
  98. // CHECK:STDOUT: file {
  99. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  100. // CHECK:STDOUT: .Class = %import_ref
  101. // CHECK:STDOUT: .Core = %Core
  102. // CHECK:STDOUT: }
  103. // CHECK:STDOUT: %import_ref: Class = import_ref ir0, inst+5, loaded [template = constants.%struct.1]
  104. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  105. // CHECK:STDOUT: %.decl: <invalid> = class_decl @.1 [template = constants.%struct.2] {
  106. // CHECK:STDOUT: %U.loc9_13.1: type = param U
  107. // CHECK:STDOUT: %U.loc9_13.2: type = bind_symbolic_name U 0, %U.loc9_13.1 [symbolic = constants.%U]
  108. // CHECK:STDOUT: }
  109. // CHECK:STDOUT: }
  110. // CHECK:STDOUT:
  111. // CHECK:STDOUT: class @Class;
  112. // CHECK:STDOUT:
  113. // CHECK:STDOUT: class @.1 {
  114. // CHECK:STDOUT: %T.ref: <error> = name_ref T, <error> [template = <error>]
  115. // CHECK:STDOUT: %.loc13: <error> = field_decl x, element0 [template]
  116. // CHECK:STDOUT:
  117. // CHECK:STDOUT: !members:
  118. // CHECK:STDOUT: .Self = constants.%.3
  119. // CHECK:STDOUT: .x = %.loc13
  120. // CHECK:STDOUT: }
  121. // CHECK:STDOUT: