fail_deref_function.carbon 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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/pointer/fail_deref_function.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/pointer/fail_deref_function.carbon
  13. fn A() {
  14. // CHECK:STDERR: fail_deref_function.carbon:[[@LINE+4]]:4: error: expression cannot be used as a value [UseOfNonExprAsValue]
  15. // CHECK:STDERR: *A;
  16. // CHECK:STDERR: ^
  17. // CHECK:STDERR:
  18. *A;
  19. // CHECK:STDERR: fail_deref_function.carbon:[[@LINE+4]]:3: error: expression cannot be used as a value [UseOfNonExprAsValue]
  20. // CHECK:STDERR: A->foo;
  21. // CHECK:STDERR: ^
  22. // CHECK:STDERR:
  23. A->foo;
  24. }
  25. // CHECK:STDOUT: --- fail_deref_function.carbon
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: constants {
  28. // CHECK:STDOUT: %A.type: type = fn_type @A [concrete]
  29. // CHECK:STDOUT: %A: %A.type = struct_value () [concrete]
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: imports {
  33. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  34. // CHECK:STDOUT: import Core//prelude
  35. // CHECK:STDOUT: import Core//prelude/...
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: file {
  40. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  41. // CHECK:STDOUT: .Core = imports.%Core
  42. // CHECK:STDOUT: .A = %A.decl
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT: %Core.import = import Core
  45. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [concrete = constants.%A] {} {}
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: fn @A() {
  49. // CHECK:STDOUT: !entry:
  50. // CHECK:STDOUT: %A.ref.loc19: %A.type = name_ref A, file.%A.decl [concrete = constants.%A]
  51. // CHECK:STDOUT: %.loc19: ref <error> = deref <error> [concrete = <error>]
  52. // CHECK:STDOUT: %A.ref.loc24: %A.type = name_ref A, file.%A.decl [concrete = constants.%A]
  53. // CHECK:STDOUT: %.loc24: ref <error> = deref <error> [concrete = <error>]
  54. // CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [concrete = <error>]
  55. // CHECK:STDOUT: return
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT: