multi_error.carbon 2.2 KB

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