fail_address_of_error.carbon 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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_address_of_error.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/pointer/fail_address_of_error.carbon
  10. fn Test() {
  11. // CHECK:STDERR: fail_address_of_error.carbon:[[@LINE+4]]:4: ERROR: Name `undeclared` not found.
  12. // CHECK:STDERR: &undeclared;
  13. // CHECK:STDERR: ^~~~~~~~~~
  14. // CHECK:STDERR:
  15. &undeclared;
  16. // CHECK:STDERR: fail_address_of_error.carbon:[[@LINE+7]]:3: ERROR: Cannot take the address of non-reference expression.
  17. // CHECK:STDERR: &(&undeclared);
  18. // CHECK:STDERR: ^
  19. // CHECK:STDERR:
  20. // CHECK:STDERR: fail_address_of_error.carbon:[[@LINE+3]]:6: ERROR: Name `undeclared` not found.
  21. // CHECK:STDERR: &(&undeclared);
  22. // CHECK:STDERR: ^~~~~~~~~~
  23. &(&undeclared);
  24. }
  25. // CHECK:STDOUT: --- fail_address_of_error.carbon
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: constants {
  28. // CHECK:STDOUT: %Test.type: type = fn_type @Test [template]
  29. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  30. // CHECK:STDOUT: %Test: %Test.type = struct_value () [template]
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: imports {
  34. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  35. // CHECK:STDOUT: import Core//prelude
  36. // CHECK:STDOUT: import Core//prelude/operators
  37. // CHECK:STDOUT: import Core//prelude/types
  38. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  39. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  40. // CHECK:STDOUT: import Core//prelude/operators/comparison
  41. // CHECK:STDOUT: import Core//prelude/types/bool
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT:
  45. // CHECK:STDOUT: file {
  46. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  47. // CHECK:STDOUT: .Core = imports.%Core
  48. // CHECK:STDOUT: .Test = %Test.decl
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT: %Core.import = import Core
  51. // CHECK:STDOUT: %Test.decl: %Test.type = fn_decl @Test [template = constants.%Test] {}
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT:
  54. // CHECK:STDOUT: fn @Test() {
  55. // CHECK:STDOUT: !entry:
  56. // CHECK:STDOUT: %undeclared.ref.loc16: <error> = name_ref undeclared, <error> [template = <error>]
  57. // CHECK:STDOUT: %.loc16: <error> = addr_of %undeclared.ref.loc16 [template = <error>]
  58. // CHECK:STDOUT: %undeclared.ref.loc24: <error> = name_ref undeclared, <error> [template = <error>]
  59. // CHECK:STDOUT: %.loc24_5: <error> = addr_of %undeclared.ref.loc24 [template = <error>]
  60. // CHECK:STDOUT: %.loc24_3: <error> = addr_of <error> [template = <error>]
  61. // CHECK:STDOUT: return
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT: