fail_member_of_function.carbon 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/struct/fail_member_of_function.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/struct/fail_member_of_function.carbon
  10. fn A() {
  11. // CHECK:STDERR: fail_member_of_function.carbon:[[@LINE+3]]:3: ERROR: Expression cannot be used as a value.
  12. // CHECK:STDERR: A.y;
  13. // CHECK:STDERR: ^
  14. A.y;
  15. }
  16. // CHECK:STDOUT: --- fail_member_of_function.carbon
  17. // CHECK:STDOUT:
  18. // CHECK:STDOUT: constants {
  19. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  20. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  21. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  22. // CHECK:STDOUT: }
  23. // CHECK:STDOUT:
  24. // CHECK:STDOUT: file {
  25. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  26. // CHECK:STDOUT: .Core = %Core
  27. // CHECK:STDOUT: .A = %A.decl
  28. // CHECK:STDOUT: }
  29. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  30. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {}
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: fn @A() {
  34. // CHECK:STDOUT: !entry:
  35. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, file.%A.decl [template = constants.%A]
  36. // CHECK:STDOUT: return
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: