ref.carbon 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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/destroy.carbon
  6. // EXTRA-ARGS: --dump-sem-ir-ranges=only
  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/operators/builtin/ref.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/operators/builtin/ref.carbon
  13. // --- fail_discarded_ref.carbon
  14. library "[[@TEST_NAME]]";
  15. fn F() {
  16. var x: () = ();
  17. // CHECK:STDERR: fail_discarded_ref.carbon:[[@LINE+4]]:3: error: `ref` tag is not an argument to a `ref` parameter [RefTagNoRefParam]
  18. // CHECK:STDERR: ref x;
  19. // CHECK:STDERR: ^~~~~
  20. // CHECK:STDERR:
  21. ref x;
  22. }
  23. // --- fail_ref_out_of_place.carbon
  24. library "[[@TEST_NAME]]";
  25. fn F() {
  26. var x: () = ();
  27. // CHECK:STDERR: fail_ref_out_of_place.carbon:[[@LINE+4]]:15: error: `ref` tag is not an argument to a `ref` parameter [RefTagNoRefParam]
  28. // CHECK:STDERR: let y: () = ref x;
  29. // CHECK:STDERR: ^~~~~
  30. // CHECK:STDERR:
  31. let y: () = ref x;
  32. // CHECK:STDERR: fail_ref_out_of_place.carbon:[[@LINE+4]]:16: error: `ref` tag is not an argument to a `ref` parameter [RefTagNoRefParam]
  33. // CHECK:STDERR: let z: () = (ref x);
  34. // CHECK:STDERR: ^~~~~
  35. // CHECK:STDERR:
  36. let z: () = (ref x);
  37. }