fail_deref_function.carbon 2.5 KB

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