fail_redefinition.carbon 4.3 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. class Class {
  7. fn F();
  8. fn H();
  9. fn I() {}
  10. }
  11. // CHECK:STDERR: fail_redefinition.carbon:[[@LINE+7]]:1: ERROR: Redefinition of `class Class`.
  12. // CHECK:STDERR: class Class {
  13. // CHECK:STDERR: ^~~~~~~~~~~~~
  14. // CHECK:STDERR: fail_redefinition.carbon:[[@LINE-9]]:1: Previously defined here.
  15. // CHECK:STDERR: class Class {
  16. // CHECK:STDERR: ^~~~~~~~~~~~~
  17. // CHECK:STDERR:
  18. class Class {
  19. fn G();
  20. fn H();
  21. fn I() {}
  22. }
  23. // CHECK:STDERR: fail_redefinition.carbon:[[@LINE+4]]:10: ERROR: Out-of-line declaration requires a declaration in scoped entity.
  24. // CHECK:STDERR: fn Class.F() {}
  25. // CHECK:STDERR: ^
  26. // CHECK:STDERR:
  27. fn Class.F() {}
  28. fn Class.G() {}
  29. fn Class.H() {}
  30. // CHECK:STDERR: fail_redefinition.carbon:[[@LINE+6]]:1: ERROR: Redefinition of `fn I`.
  31. // CHECK:STDERR: fn Class.I() {}
  32. // CHECK:STDERR: ^~~~~~~~~~~~~~
  33. // CHECK:STDERR: fail_redefinition.carbon:[[@LINE-13]]:3: Previously defined here.
  34. // CHECK:STDERR: fn I() {}
  35. // CHECK:STDERR: ^~~~~~~~
  36. fn Class.I() {}
  37. // CHECK:STDOUT: --- fail_redefinition.carbon
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: constants {
  40. // CHECK:STDOUT: %Class: type = class_type @Class [template]
  41. // CHECK:STDOUT: %F.1: type = fn_type @F.1 [template]
  42. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  43. // CHECK:STDOUT: %struct.1: F = struct_value () [template]
  44. // CHECK:STDOUT: %H.1: type = fn_type @H.1 [template]
  45. // CHECK:STDOUT: %struct.2: H = struct_value () [template]
  46. // CHECK:STDOUT: %I.1: type = fn_type @I.1 [template]
  47. // CHECK:STDOUT: %struct.3: I = struct_value () [template]
  48. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  49. // CHECK:STDOUT: %G: type = fn_type @G [template]
  50. // CHECK:STDOUT: %struct.4: G = struct_value () [template]
  51. // CHECK:STDOUT: %H.2: type = fn_type @H.2 [template]
  52. // CHECK:STDOUT: %struct.5: H = struct_value () [template]
  53. // CHECK:STDOUT: %I.2: type = fn_type @I.2 [template]
  54. // CHECK:STDOUT: %struct.6: I = struct_value () [template]
  55. // CHECK:STDOUT: %F.2: type = fn_type @F.2 [template]
  56. // CHECK:STDOUT: %struct.7: F = struct_value () [template]
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: file {
  60. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  61. // CHECK:STDOUT: .Core = %Core
  62. // CHECK:STDOUT: .Class = %Class.decl.loc7
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  65. // CHECK:STDOUT: %Class.decl.loc7: type = class_decl @Class [template = constants.%Class] {}
  66. // CHECK:STDOUT: %Class.decl.loc20: type = class_decl @Class [template = constants.%Class] {}
  67. // CHECK:STDOUT: %F.decl: F = fn_decl @F.2 [template = constants.%struct.7] {}
  68. // CHECK:STDOUT: %G.decl: G = fn_decl @G [template = constants.%struct.4] {}
  69. // CHECK:STDOUT: %H.decl: H = fn_decl @H.2 [template = constants.%struct.5] {}
  70. // CHECK:STDOUT: %I.decl: I = fn_decl @I.2 [template = constants.%struct.6] {}
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: class @Class {
  74. // CHECK:STDOUT: %G.decl: G = fn_decl @G [template = constants.%struct.4] {}
  75. // CHECK:STDOUT: %H.decl: H = fn_decl @H.2 [template = constants.%struct.5] {}
  76. // CHECK:STDOUT: %I.decl: I = fn_decl @I.2 [template = constants.%struct.6] {}
  77. // CHECK:STDOUT:
  78. // CHECK:STDOUT: !members:
  79. // CHECK:STDOUT: .Self = constants.%Class
  80. // CHECK:STDOUT: .G = %G.decl
  81. // CHECK:STDOUT: .H = %H.decl
  82. // CHECK:STDOUT: .I = %I.decl
  83. // CHECK:STDOUT: .F = file.%F.decl
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT:
  86. // CHECK:STDOUT: fn @F.1();
  87. // CHECK:STDOUT:
  88. // CHECK:STDOUT: fn @H.1();
  89. // CHECK:STDOUT:
  90. // CHECK:STDOUT: fn @I.1() {
  91. // CHECK:STDOUT: !entry:
  92. // CHECK:STDOUT: return
  93. // CHECK:STDOUT: }
  94. // CHECK:STDOUT:
  95. // CHECK:STDOUT: fn @G() {
  96. // CHECK:STDOUT: !entry:
  97. // CHECK:STDOUT: return
  98. // CHECK:STDOUT: }
  99. // CHECK:STDOUT:
  100. // CHECK:STDOUT: fn @H.2() {
  101. // CHECK:STDOUT: !entry:
  102. // CHECK:STDOUT: return
  103. // CHECK:STDOUT: }
  104. // CHECK:STDOUT:
  105. // CHECK:STDOUT: fn @I.2() {
  106. // CHECK:STDOUT: !entry:
  107. // CHECK:STDOUT: return
  108. // CHECK:STDOUT:
  109. // CHECK:STDOUT: !.loc39:
  110. // CHECK:STDOUT: return
  111. // CHECK:STDOUT: }
  112. // CHECK:STDOUT:
  113. // CHECK:STDOUT: fn @F.2() {
  114. // CHECK:STDOUT: !entry:
  115. // CHECK:STDOUT: return
  116. // CHECK:STDOUT: }
  117. // CHECK:STDOUT: