fail_redecl.carbon 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. fn A();
  7. // CHECK:STDERR: fail_redecl.carbon:[[@LINE+7]]:1: ERROR: Redeclaration of `fn A` is redundant.
  8. // CHECK:STDERR: fn A();
  9. // CHECK:STDERR: ^~~~~~~
  10. // CHECK:STDERR: fail_redecl.carbon:[[@LINE-4]]:1: Previously declared here.
  11. // CHECK:STDERR: fn A();
  12. // CHECK:STDERR: ^~~~~~~
  13. // CHECK:STDERR:
  14. fn A();
  15. fn B(x: ());
  16. // CHECK:STDERR: fail_redecl.carbon:[[@LINE+7]]:1: ERROR: Redeclaration of `fn B` is redundant.
  17. // CHECK:STDERR: fn B(x: ());
  18. // CHECK:STDERR: ^~~~~~~~~~~~
  19. // CHECK:STDERR: fail_redecl.carbon:[[@LINE-4]]:1: Previously declared here.
  20. // CHECK:STDERR: fn B(x: ());
  21. // CHECK:STDERR: ^~~~~~~~~~~~
  22. // CHECK:STDERR:
  23. fn B(x: ());
  24. fn C();
  25. // CHECK:STDERR: fail_redecl.carbon:[[@LINE+7]]:1: ERROR: Redeclaration differs because of parameter count of 1.
  26. // CHECK:STDERR: fn C(x: ());
  27. // CHECK:STDERR: ^~~~~~~~~~~~
  28. // CHECK:STDERR: fail_redecl.carbon:[[@LINE-4]]:1: Previously declared with parameter count of 0.
  29. // CHECK:STDERR: fn C();
  30. // CHECK:STDERR: ^~~~~~~
  31. // CHECK:STDERR:
  32. fn C(x: ());
  33. fn D() {}
  34. // CHECK:STDERR: fail_redecl.carbon:[[@LINE+7]]:1: ERROR: Redeclaration of `fn D` is redundant.
  35. // CHECK:STDERR: fn D();
  36. // CHECK:STDERR: ^~~~~~~
  37. // CHECK:STDERR: fail_redecl.carbon:[[@LINE-4]]:1: Previously declared here.
  38. // CHECK:STDERR: fn D() {}
  39. // CHECK:STDERR: ^~~~~~~~
  40. // CHECK:STDERR:
  41. fn D();
  42. fn E() {}
  43. // CHECK:STDERR: fail_redecl.carbon:[[@LINE+6]]:1: ERROR: Redefinition of `fn E`.
  44. // CHECK:STDERR: fn E() {}
  45. // CHECK:STDERR: ^~~~~~~~
  46. // CHECK:STDERR: fail_redecl.carbon:[[@LINE-4]]:1: Previously defined here.
  47. // CHECK:STDERR: fn E() {}
  48. // CHECK:STDERR: ^~~~~~~~
  49. fn E() {}
  50. // CHECK:STDOUT: --- fail_redecl.carbon
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: constants {
  53. // CHECK:STDOUT: %A: type = fn_type @A [template]
  54. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  55. // CHECK:STDOUT: %struct.1: A = struct_value () [template]
  56. // CHECK:STDOUT: %B: type = fn_type @B [template]
  57. // CHECK:STDOUT: %struct.2: B = struct_value () [template]
  58. // CHECK:STDOUT: %C: type = fn_type @C [template]
  59. // CHECK:STDOUT: %struct.3: C = struct_value () [template]
  60. // CHECK:STDOUT: %.2: type = fn_type @.1 [template]
  61. // CHECK:STDOUT: %struct.4: <invalid> = struct_value () [template]
  62. // CHECK:STDOUT: %D: type = fn_type @D [template]
  63. // CHECK:STDOUT: %struct.5: D = struct_value () [template]
  64. // CHECK:STDOUT: %E: type = fn_type @E [template]
  65. // CHECK:STDOUT: %struct.6: E = struct_value () [template]
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: file {
  69. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  70. // CHECK:STDOUT: .A = %A.decl.loc7
  71. // CHECK:STDOUT: .B = %B.decl.loc17
  72. // CHECK:STDOUT: .C = %C.decl
  73. // CHECK:STDOUT: .D = %D.decl.loc37
  74. // CHECK:STDOUT: .E = %E.decl.loc47
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT: %A.decl.loc7: A = fn_decl @A [template = constants.%struct.1] {}
  77. // CHECK:STDOUT: %A.decl.loc15: A = fn_decl @A [template = constants.%struct.1] {}
  78. // CHECK:STDOUT: %B.decl.loc17: B = fn_decl @B [template = constants.%struct.2] {
  79. // CHECK:STDOUT: %.loc17_10.1: () = tuple_literal ()
  80. // CHECK:STDOUT: %.loc17_10.2: type = converted %.loc17_10.1, constants.%.1 [template = constants.%.1]
  81. // CHECK:STDOUT: %x.loc17_6.1: () = param x
  82. // CHECK:STDOUT: @B.%x: () = bind_name x, %x.loc17_6.1
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT: %B.decl.loc25: B = fn_decl @B [template = constants.%struct.2] {
  85. // CHECK:STDOUT: %.loc25_10.1: () = tuple_literal ()
  86. // CHECK:STDOUT: %.loc25_10.2: type = converted %.loc25_10.1, constants.%.1 [template = constants.%.1]
  87. // CHECK:STDOUT: %x.loc25_6.1: () = param x
  88. // CHECK:STDOUT: %x.loc25_6.2: () = bind_name x, %x.loc25_6.1
  89. // CHECK:STDOUT: }
  90. // CHECK:STDOUT: %C.decl: C = fn_decl @C [template = constants.%struct.3] {}
  91. // CHECK:STDOUT: %.decl: <invalid> = fn_decl @.1 [template = constants.%struct.4] {
  92. // CHECK:STDOUT: %.loc35_10.1: () = tuple_literal ()
  93. // CHECK:STDOUT: %.loc35_10.2: type = converted %.loc35_10.1, constants.%.1 [template = constants.%.1]
  94. // CHECK:STDOUT: %x.loc35_6.1: () = param x
  95. // CHECK:STDOUT: @.1.%x: () = bind_name x, %x.loc35_6.1
  96. // CHECK:STDOUT: }
  97. // CHECK:STDOUT: %D.decl.loc37: D = fn_decl @D [template = constants.%struct.5] {}
  98. // CHECK:STDOUT: %D.decl.loc45: D = fn_decl @D [template = constants.%struct.5] {}
  99. // CHECK:STDOUT: %E.decl.loc47: E = fn_decl @E [template = constants.%struct.6] {}
  100. // CHECK:STDOUT: %E.decl.loc54: E = fn_decl @E [template = constants.%struct.6] {}
  101. // CHECK:STDOUT: }
  102. // CHECK:STDOUT:
  103. // CHECK:STDOUT: fn @A();
  104. // CHECK:STDOUT:
  105. // CHECK:STDOUT: fn @B(%x: ());
  106. // CHECK:STDOUT:
  107. // CHECK:STDOUT: fn @C();
  108. // CHECK:STDOUT:
  109. // CHECK:STDOUT: fn @.1(%x: ());
  110. // CHECK:STDOUT:
  111. // CHECK:STDOUT: fn @D() {
  112. // CHECK:STDOUT: !entry:
  113. // CHECK:STDOUT: return
  114. // CHECK:STDOUT: }
  115. // CHECK:STDOUT:
  116. // CHECK:STDOUT: fn @E() {
  117. // CHECK:STDOUT: !entry:
  118. // CHECK:STDOUT: return
  119. // CHECK:STDOUT:
  120. // CHECK:STDOUT: !.loc54:
  121. // CHECK:STDOUT: return
  122. // CHECK:STDOUT: }
  123. // CHECK:STDOUT: