fail_member_of_function.carbon 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  6. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  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/struct/fail_member_of_function.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/struct/fail_member_of_function.carbon
  13. fn A() {
  14. // CHECK:STDERR: fail_member_of_function.carbon:[[@LINE+4]]:3: error: expression cannot be used as a value [UseOfNonExprAsValue]
  15. // CHECK:STDERR: A.y;
  16. // CHECK:STDERR: ^
  17. // CHECK:STDERR:
  18. A.y;
  19. }
  20. // CHECK:STDOUT: --- fail_member_of_function.carbon
  21. // CHECK:STDOUT:
  22. // CHECK:STDOUT: constants {
  23. // CHECK:STDOUT: %A.type: type = fn_type @A [concrete]
  24. // CHECK:STDOUT: %A: %A.type = struct_value () [concrete]
  25. // CHECK:STDOUT: }
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: imports {
  28. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  29. // CHECK:STDOUT: import Core//prelude
  30. // CHECK:STDOUT: import Core//prelude/...
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: file {
  35. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  36. // CHECK:STDOUT: .Core = imports.%Core
  37. // CHECK:STDOUT: .A = %A.decl
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT: %Core.import = import Core
  40. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [concrete = constants.%A] {} {}
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: fn @A() {
  44. // CHECK:STDOUT: !entry:
  45. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, file.%A.decl [concrete = constants.%A]
  46. // CHECK:STDOUT: %y.ref: <error> = name_ref y, <error> [concrete = <error>]
  47. // CHECK:STDOUT: return
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: