fail_duplicate_decl.carbon 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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/var/no_prelude/fail_duplicate_decl.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/var/no_prelude/fail_duplicate_decl.carbon
  10. fn Main() {
  11. var x: () = ();
  12. // CHECK:STDERR: fail_duplicate_decl.carbon:[[@LINE+6]]:7: error: duplicate name being declared in the same scope [NameDeclDuplicate]
  13. // CHECK:STDERR: var x: () = ();
  14. // CHECK:STDERR: ^
  15. // CHECK:STDERR: fail_duplicate_decl.carbon:[[@LINE-4]]:7: note: name is previously declared here [NameDeclPrevious]
  16. // CHECK:STDERR: var x: () = ();
  17. // CHECK:STDERR: ^
  18. var x: () = ();
  19. }
  20. // CHECK:STDOUT: --- fail_duplicate_decl.carbon
  21. // CHECK:STDOUT:
  22. // CHECK:STDOUT: constants {
  23. // CHECK:STDOUT: %Main.type: type = fn_type @Main [template]
  24. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  25. // CHECK:STDOUT: %Main: %Main.type = struct_value () [template]
  26. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template]
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: file {
  30. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  31. // CHECK:STDOUT: .Main = %Main.decl
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} {}
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT:
  36. // CHECK:STDOUT: fn @Main() {
  37. // CHECK:STDOUT: !entry:
  38. // CHECK:STDOUT: %x.var.loc13: ref %empty_tuple.type = var x
  39. // CHECK:STDOUT: %x.loc13: ref %empty_tuple.type = bind_name x, %x.var.loc13
  40. // CHECK:STDOUT: %.loc13_16.1: %empty_tuple.type = tuple_literal ()
  41. // CHECK:STDOUT: %.loc13_16.2: init %empty_tuple.type = tuple_init () to %x.var.loc13 [template = constants.%empty_tuple]
  42. // CHECK:STDOUT: %.loc13_17: init %empty_tuple.type = converted %.loc13_16.1, %.loc13_16.2 [template = constants.%empty_tuple]
  43. // CHECK:STDOUT: assign %x.var.loc13, %.loc13_17
  44. // CHECK:STDOUT: %x.var.loc20: ref %empty_tuple.type = var x
  45. // CHECK:STDOUT: %x.loc20: ref %empty_tuple.type = bind_name x, %x.var.loc20
  46. // CHECK:STDOUT: %.loc20_16.1: %empty_tuple.type = tuple_literal ()
  47. // CHECK:STDOUT: %.loc20_16.2: init %empty_tuple.type = tuple_init () to %x.var.loc20 [template = constants.%empty_tuple]
  48. // CHECK:STDOUT: %.loc20_17: init %empty_tuple.type = converted %.loc20_16.1, %.loc20_16.2 [template = constants.%empty_tuple]
  49. // CHECK:STDOUT: assign %x.var.loc20, %.loc20_17
  50. // CHECK:STDOUT: return
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT: