unused_underscore.carbon 1.2 KB

12345678910111213141516171819202122232425
  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/primitives.carbon
  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/patterns/unused_underscore.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/patterns/unused_underscore.carbon
  12. fn F() {
  13. // CHECK:STDERR: unused_underscore.carbon:[[@LINE+4]]:7: warning: `unused` modifier on pattern without bindings [UnusedPatternNoBindings]
  14. // CHECK:STDERR: var unused _: i32 = 1;
  15. // CHECK:STDERR: ^~~~~~~~~~~~~
  16. // CHECK:STDERR:
  17. var unused _: i32 = 1;
  18. // CHECK:STDERR: unused_underscore.carbon:[[@LINE+4]]:7: warning: `unused` modifier on pattern without bindings [UnusedPatternNoBindings]
  19. // CHECK:STDERR: let unused (_: i32, _: i32) = (1, 1);
  20. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~
  21. // CHECK:STDERR:
  22. let unused (_: i32, _: i32) = (1, 1);
  23. }