fail_address_of_error.carbon 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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: file {
  24. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  25. // CHECK:STDOUT: .Test = %Test
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT: %Test: <function> = fn_decl @Test [template] {}
  28. // CHECK:STDOUT: }
  29. // CHECK:STDOUT:
  30. // CHECK:STDOUT: fn @Test() {
  31. // CHECK:STDOUT: !entry:
  32. // CHECK:STDOUT: %undeclared.ref.loc12: <error> = name_ref undeclared, <error> [template = <error>]
  33. // CHECK:STDOUT: %.loc12: <error> = addr_of %undeclared.ref.loc12 [template = <error>]
  34. // CHECK:STDOUT: %undeclared.ref.loc20: <error> = name_ref undeclared, <error> [template = <error>]
  35. // CHECK:STDOUT: %.loc20_5: <error> = addr_of %undeclared.ref.loc20 [template = <error>]
  36. // CHECK:STDOUT: %.loc20_3: <error> = addr_of <error> [template = <error>]
  37. // CHECK:STDOUT: return
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT: