fail_address_of_error.carbon 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. fn Test() {
  7. // CHECK:STDERR: fail_address_of_error.carbon:[[@LINE+4]]:4: ERROR: Name `undeclared` not found.
  8. // CHECK:STDERR: &undeclared;
  9. // CHECK:STDERR: ^~~~~~~~~~
  10. // CHECK:STDERR:
  11. &undeclared;
  12. // CHECK:STDERR: fail_address_of_error.carbon:[[@LINE+7]]:3: ERROR: Cannot take the address of non-reference expression.
  13. // CHECK:STDERR: &(&undeclared);
  14. // CHECK:STDERR: ^
  15. // CHECK:STDERR:
  16. // CHECK:STDERR: fail_address_of_error.carbon:[[@LINE+3]]:6: ERROR: Name `undeclared` not found.
  17. // CHECK:STDERR: &(&undeclared);
  18. // CHECK:STDERR: ^~~~~~~~~~
  19. &(&undeclared);
  20. }
  21. // CHECK:STDOUT: --- fail_address_of_error.carbon
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: constants {
  24. // CHECK:STDOUT: %Test: type = fn_type @Test [template]
  25. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  26. // CHECK:STDOUT: %struct: Test = struct_value () [template]
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: file {
  30. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  31. // CHECK:STDOUT: .Core = %Core
  32. // CHECK:STDOUT: .Test = %Test.decl
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  35. // CHECK:STDOUT: %Test.decl: Test = fn_decl @Test [template = constants.%struct] {}
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: fn @Test() {
  39. // CHECK:STDOUT: !entry:
  40. // CHECK:STDOUT: %undeclared.ref.loc12: <error> = name_ref undeclared, <error> [template = <error>]
  41. // CHECK:STDOUT: %.loc12: <error> = addr_of %undeclared.ref.loc12 [template = <error>]
  42. // CHECK:STDOUT: %undeclared.ref.loc20: <error> = name_ref undeclared, <error> [template = <error>]
  43. // CHECK:STDOUT: %.loc20_5: <error> = addr_of %undeclared.ref.loc20 [template = <error>]
  44. // CHECK:STDOUT: %.loc20_3: <error> = addr_of <error> [template = <error>]
  45. // CHECK:STDOUT: return
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT: