fail_dereference_not_pointer.carbon 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  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 Deref(n: i32) {
  7. // CHECK:STDERR: fail_dereference_not_pointer.carbon:[[@LINE+3]]:3: Cannot dereference operand of non-pointer type `i32`.
  8. // CHECK:STDERR: *n;
  9. // CHECK:STDERR: ^
  10. *n;
  11. // CHECK:STDERR: fail_dereference_not_pointer.carbon:[[@LINE+3]]:3: Cannot dereference operand of non-pointer type `() as type`.
  12. // CHECK:STDERR: *();
  13. // CHECK:STDERR: ^
  14. *();
  15. // CHECK:STDERR: fail_dereference_not_pointer.carbon:[[@LINE+3]]:3: Cannot dereference operand of non-pointer type `{} as type`.
  16. // CHECK:STDERR: *{};
  17. // CHECK:STDERR: ^
  18. *{};
  19. }
  20. // CHECK:STDOUT: package {
  21. // CHECK:STDOUT: %.loc7 = fn_decl @Deref
  22. // CHECK:STDOUT: }
  23. // CHECK:STDOUT:
  24. // CHECK:STDOUT: fn @Deref(%n: i32) {
  25. // CHECK:STDOUT: !entry:
  26. // CHECK:STDOUT: %.loc11: ref <error> = dereference %n
  27. // CHECK:STDOUT: %.loc15_5.1: type = tuple_type ()
  28. // CHECK:STDOUT: %.loc15_5.2: () = tuple_literal ()
  29. // CHECK:STDOUT: %.loc15_3: ref <error> = dereference %.loc15_5.2
  30. // CHECK:STDOUT: %.loc19_5.1: type = struct_type {}
  31. // CHECK:STDOUT: %.loc19_5.2: {} = struct_literal ()
  32. // CHECK:STDOUT: %.loc19_3: ref <error> = dereference %.loc19_5.2
  33. // CHECK:STDOUT: return
  34. // CHECK:STDOUT: }