fail_address_of_error.carbon 1.6 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+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: constants {
  22. // CHECK:STDOUT: %.loc11: type = ptr_type <error>
  23. // CHECK:STDOUT: %.loc18: type = ptr_type <error>*
  24. // CHECK:STDOUT: }
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: file {
  27. // CHECK:STDOUT: %Test: <function> = fn_decl @Test
  28. // CHECK:STDOUT: }
  29. // CHECK:STDOUT:
  30. // CHECK:STDOUT: fn @Test() {
  31. // CHECK:STDOUT: !entry:
  32. // CHECK:STDOUT: %undeclared.ref.loc11: <error> = name_ref undeclared, <error>
  33. // CHECK:STDOUT: %.loc11: <error>* = address_of %undeclared.ref.loc11
  34. // CHECK:STDOUT: %undeclared.ref.loc18: <error> = name_ref undeclared, <error>
  35. // CHECK:STDOUT: %.loc18_5: <error>* = address_of %undeclared.ref.loc18
  36. // CHECK:STDOUT: %.loc18_3: <error>** = address_of %.loc18_5
  37. // CHECK:STDOUT: return
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT: