multi_error.carbon 2.2 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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/none.carbon
  6. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  7. //
  8. // AUTOUPDATE
  9. // TIP: To test this file alone, run:
  10. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/basics/multi_error.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/basics/multi_error.carbon
  13. // --- fail_multi_error.carbon
  14. // When naming insts, the `error` instruction generated is added for naming.
  15. // This regression test ensures that reuse of `<error>` in different scopes
  16. // works.
  17. // CHECK:STDERR: fail_multi_error.carbon:[[@LINE+4]]:8: error: implicit parameters of functions must be constant or `self` [ImplictParamMustBeConstant]
  18. // CHECK:STDERR: fn Foo[a: ()]();
  19. // CHECK:STDERR: ^~~~~
  20. // CHECK:STDERR:
  21. fn Foo[a: ()]();
  22. // CHECK:STDERR: fail_multi_error.carbon:[[@LINE+4]]:8: error: implicit parameters of functions must be constant or `self` [ImplictParamMustBeConstant]
  23. // CHECK:STDERR: fn Boo[a: ()]() {}
  24. // CHECK:STDERR: ^~~~~
  25. // CHECK:STDERR:
  26. fn Boo[a: ()]() {}
  27. // CHECK:STDOUT: --- fail_multi_error.carbon
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: constants {
  30. // CHECK:STDOUT: %Foo.type: type = fn_type @Foo [concrete]
  31. // CHECK:STDOUT: %Foo: %Foo.type = struct_value () [concrete]
  32. // CHECK:STDOUT: %Boo.type: type = fn_type @Boo [concrete]
  33. // CHECK:STDOUT: %Boo: %Boo.type = struct_value () [concrete]
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT:
  36. // CHECK:STDOUT: file {
  37. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  38. // CHECK:STDOUT: .Foo = %Foo.decl
  39. // CHECK:STDOUT: .Boo = %Boo.decl
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [concrete = constants.%Foo] {} {}
  42. // CHECK:STDOUT: %Boo.decl: %Boo.type = fn_decl @Boo [concrete = constants.%Boo] {} {}
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT:
  45. // CHECK:STDOUT: fn @Foo();
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: fn @Boo() {
  48. // CHECK:STDOUT: !entry:
  49. // CHECK:STDOUT: return
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT: