fail_duplicate.carbon 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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/namespace/fail_duplicate.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/namespace/fail_duplicate.carbon
  10. namespace Foo;
  11. fn Foo.Baz() {
  12. }
  13. // CHECK:STDERR: fail_duplicate.carbon:[[@LINE+6]]:1: ERROR: Redefinition of `fn Baz`.
  14. // CHECK:STDERR: fn Foo.Baz() {
  15. // CHECK:STDERR: ^~~~~~~~~~~~~~
  16. // CHECK:STDERR: fail_duplicate.carbon:[[@LINE-6]]:1: Previously defined here.
  17. // CHECK:STDERR: fn Foo.Baz() {
  18. // CHECK:STDERR: ^~~~~~~~~~~~~~
  19. fn Foo.Baz() {
  20. }
  21. // CHECK:STDOUT: --- fail_duplicate.carbon
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: constants {
  24. // CHECK:STDOUT: %Baz.type: type = fn_type @Baz [template]
  25. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  26. // CHECK:STDOUT: %Baz: %Baz.type = struct_value () [template]
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: file {
  30. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  31. // CHECK:STDOUT: .Core = %Core
  32. // CHECK:STDOUT: .Foo = %Foo
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  35. // CHECK:STDOUT: %Foo: <namespace> = namespace [template] {
  36. // CHECK:STDOUT: .Baz = %Baz.decl.loc13
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: %Baz.decl.loc13: %Baz.type = fn_decl @Baz [template = constants.%Baz] {}
  39. // CHECK:STDOUT: %Baz.decl.loc22: %Baz.type = fn_decl @Baz [template = constants.%Baz] {}
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: fn @Baz() {
  43. // CHECK:STDOUT: !entry:
  44. // CHECK:STDOUT: return
  45. // CHECK:STDOUT:
  46. // CHECK:STDOUT: !.loc23:
  47. // CHECK:STDOUT: return
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: