mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-02 22:02:51 +01:00
Implementation of unused pattern bindings #2022, continued. Whereas previous PR #6460 took care of parsing, and PR #6479 prepared the stage by using _ in some test cases, this PR has the the actual implementation, using a simple dataflow analysis. --------- Co-authored-by: Burak Emir <bqe@google.com> Co-authored-by: jonmeow <jperkins@google.com>
44 lines
1.6 KiB
Plaintext
44 lines
1.6 KiB
Plaintext
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/destroy.carbon
|
|
// EXTRA-ARGS: --dump-sem-ir-ranges=only
|
|
//
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/operators/builtin/ref.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/operators/builtin/ref.carbon
|
|
|
|
// --- fail_discarded_ref.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
fn F() {
|
|
var x: () = ();
|
|
// CHECK:STDERR: fail_discarded_ref.carbon:[[@LINE+4]]:3: error: `ref` tag is not an argument to a `ref` parameter [RefTagNoRefParam]
|
|
// CHECK:STDERR: ref x;
|
|
// CHECK:STDERR: ^~~~~
|
|
// CHECK:STDERR:
|
|
ref x;
|
|
}
|
|
|
|
// --- fail_ref_out_of_place.carbon
|
|
|
|
library "[[@TEST_NAME]]";
|
|
|
|
fn F() {
|
|
var x: () = ();
|
|
// CHECK:STDERR: fail_ref_out_of_place.carbon:[[@LINE+4]]:22: error: `ref` tag is not an argument to a `ref` parameter [RefTagNoRefParam]
|
|
// CHECK:STDERR: let unused y: () = ref x;
|
|
// CHECK:STDERR: ^~~~~
|
|
// CHECK:STDERR:
|
|
let unused y: () = ref x;
|
|
// CHECK:STDERR: fail_ref_out_of_place.carbon:[[@LINE+4]]:23: error: `ref` tag is not an argument to a `ref` parameter [RefTagNoRefParam]
|
|
// CHECK:STDERR: let unused z: () = (ref x);
|
|
// CHECK:STDERR: ^~~~~
|
|
// CHECK:STDERR:
|
|
let unused z: () = (ref x);
|
|
}
|