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