fail_address_of_error.carbon 2.6 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. // 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 [NameNotFound]
  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 [AddrOfNonRef]
  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 [NameNotFound]
  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: %Test: %Test.type = struct_value () [template]
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: imports {
  33. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  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 [template] {
  41. // CHECK:STDOUT: .Core = imports.%Core
  42. // CHECK:STDOUT: .Test = %Test.decl
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT: %Core.import = import Core
  45. // CHECK:STDOUT: %Test.decl: %Test.type = fn_decl @Test [template = constants.%Test] {} {}
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: fn @Test() {
  49. // CHECK:STDOUT: !entry:
  50. // CHECK:STDOUT: %undeclared.ref.loc16: <error> = name_ref undeclared, <error> [template = <error>]
  51. // CHECK:STDOUT: %addr.loc16: <error> = addr_of %undeclared.ref.loc16 [template = <error>]
  52. // CHECK:STDOUT: %undeclared.ref.loc24: <error> = name_ref undeclared, <error> [template = <error>]
  53. // CHECK:STDOUT: %addr.loc24_5: <error> = addr_of %undeclared.ref.loc24 [template = <error>]
  54. // CHECK:STDOUT: %addr.loc24_3: <error> = addr_of <error> [template = <error>]
  55. // CHECK:STDOUT: return
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT: