fail_redeclaration_scope.carbon 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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/class/fail_redeclaration_scope.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/fail_redeclaration_scope.carbon
  10. class A;
  11. class X {
  12. // OK, a different A.
  13. class A { class B; }
  14. class A.B {}
  15. }
  16. class A { class B; }
  17. class Y {
  18. // CHECK:STDERR: fail_redeclaration_scope.carbon:[[@LINE+4]]:9: error: name `A` not found [NameNotFound]
  19. // CHECK:STDERR: class A.B {}
  20. // CHECK:STDERR: ^
  21. // CHECK:STDERR:
  22. class A.B {}
  23. }
  24. // CHECK:STDOUT: --- fail_redeclaration_scope.carbon
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: constants {
  27. // CHECK:STDOUT: %A.466: type = class_type @A.1 [template]
  28. // CHECK:STDOUT: %X: type = class_type @X [template]
  29. // CHECK:STDOUT: %A.197: type = class_type @A.2 [template]
  30. // CHECK:STDOUT: %B.d5b: type = class_type @B.1 [template]
  31. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  32. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  33. // CHECK:STDOUT: %B.29a: type = class_type @B.2 [template]
  34. // CHECK:STDOUT: %Y: type = class_type @Y [template]
  35. // CHECK:STDOUT: %.65d: type = class_type @.1 [template]
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: imports {
  39. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  40. // CHECK:STDOUT: import Core//prelude
  41. // CHECK:STDOUT: import Core//prelude/...
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT:
  45. // CHECK:STDOUT: file {
  46. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  47. // CHECK:STDOUT: .Core = imports.%Core
  48. // CHECK:STDOUT: .A = %A.decl.loc11
  49. // CHECK:STDOUT: .X = %X.decl
  50. // CHECK:STDOUT: .Y = %Y.decl
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT: %Core.import = import Core
  53. // CHECK:STDOUT: %A.decl.loc11: type = class_decl @A.1 [template = constants.%A.466] {} {}
  54. // CHECK:STDOUT: %X.decl: type = class_decl @X [template = constants.%X] {} {}
  55. // CHECK:STDOUT: %A.decl.loc19: type = class_decl @A.1 [template = constants.%A.466] {} {}
  56. // CHECK:STDOUT: %Y.decl: type = class_decl @Y [template = constants.%Y] {} {}
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: class @A.1 {
  60. // CHECK:STDOUT: %B.decl: type = class_decl @B.2 [template = constants.%B.29a] {} {}
  61. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  62. // CHECK:STDOUT: complete_type_witness = %complete_type
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: !members:
  65. // CHECK:STDOUT: .Self = constants.%A.466
  66. // CHECK:STDOUT: .B = %B.decl
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: class @X {
  70. // CHECK:STDOUT: %A.decl: type = class_decl @A.2 [template = constants.%A.197] {} {}
  71. // CHECK:STDOUT: %B.decl: type = class_decl @B.1 [template = constants.%B.d5b] {} {}
  72. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  73. // CHECK:STDOUT: complete_type_witness = %complete_type
  74. // CHECK:STDOUT:
  75. // CHECK:STDOUT: !members:
  76. // CHECK:STDOUT: .Self = constants.%X
  77. // CHECK:STDOUT: .A = %A.decl
  78. // CHECK:STDOUT: }
  79. // CHECK:STDOUT:
  80. // CHECK:STDOUT: class @A.2 {
  81. // CHECK:STDOUT: %B.decl: type = class_decl @B.1 [template = constants.%B.d5b] {} {}
  82. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  83. // CHECK:STDOUT: complete_type_witness = %complete_type
  84. // CHECK:STDOUT:
  85. // CHECK:STDOUT: !members:
  86. // CHECK:STDOUT: .Self = constants.%A.197
  87. // CHECK:STDOUT: .B = %B.decl
  88. // CHECK:STDOUT: }
  89. // CHECK:STDOUT:
  90. // CHECK:STDOUT: class @B.1 {
  91. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  92. // CHECK:STDOUT: complete_type_witness = %complete_type
  93. // CHECK:STDOUT:
  94. // CHECK:STDOUT: !members:
  95. // CHECK:STDOUT: .Self = constants.%B.d5b
  96. // CHECK:STDOUT: }
  97. // CHECK:STDOUT:
  98. // CHECK:STDOUT: class @B.2;
  99. // CHECK:STDOUT:
  100. // CHECK:STDOUT: class @Y {
  101. // CHECK:STDOUT: %.decl: type = class_decl @.1 [template = constants.%.65d] {} {}
  102. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  103. // CHECK:STDOUT: complete_type_witness = %complete_type
  104. // CHECK:STDOUT:
  105. // CHECK:STDOUT: !members:
  106. // CHECK:STDOUT: .Self = constants.%Y
  107. // CHECK:STDOUT: }
  108. // CHECK:STDOUT:
  109. // CHECK:STDOUT: class @.1 {
  110. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  111. // CHECK:STDOUT: complete_type_witness = %complete_type
  112. // CHECK:STDOUT:
  113. // CHECK:STDOUT: !members:
  114. // CHECK:STDOUT: .Self = constants.%.65d
  115. // CHECK:STDOUT: }
  116. // CHECK:STDOUT: