fail_address_of_error.carbon 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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+3]]:4: ERROR: Name `undeclared` not found.
  8. // CHECK:STDERR: &undeclared;
  9. // CHECK:STDERR: ^~~~~~~~~~
  10. &undeclared;
  11. // CHECK:STDERR: fail_address_of_error.carbon:[[@LINE+6]]:3: ERROR: Cannot take the address of non-reference expression.
  12. // CHECK:STDERR: &(&undeclared);
  13. // CHECK:STDERR: ^
  14. // CHECK:STDERR: fail_address_of_error.carbon:[[@LINE+3]]:6: ERROR: Name `undeclared` not found.
  15. // CHECK:STDERR: &(&undeclared);
  16. // CHECK:STDERR: ^~~~~~~~~~
  17. &(&undeclared);
  18. }
  19. // CHECK:STDOUT: --- fail_address_of_error.carbon
  20. // CHECK:STDOUT:
  21. // CHECK:STDOUT: file {
  22. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  23. // CHECK:STDOUT: .Test = %Test
  24. // CHECK:STDOUT: }
  25. // CHECK:STDOUT: %Test: <function> = fn_decl @Test [template] {}
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: fn @Test() {
  29. // CHECK:STDOUT: !entry:
  30. // CHECK:STDOUT: %undeclared.ref.loc11: <error> = name_ref undeclared, <error> [template = <error>]
  31. // CHECK:STDOUT: %.loc11: <error> = addr_of %undeclared.ref.loc11 [template = <error>]
  32. // CHECK:STDOUT: %undeclared.ref.loc18: <error> = name_ref undeclared, <error> [template = <error>]
  33. // CHECK:STDOUT: %.loc18_5: <error> = addr_of %undeclared.ref.loc18 [template = <error>]
  34. // CHECK:STDOUT: %.loc18_3: <error> = addr_of <error> [template = <error>]
  35. // CHECK:STDOUT: return
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT: