fail_deref_not_pointer.carbon 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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_deref_not_pointer.carbon:[[@LINE+3]]:3: ERROR: Cannot dereference operand of non-pointer type `i32`.
  8. // CHECK:STDERR: *n;
  9. // CHECK:STDERR: ^
  10. *n;
  11. // CHECK:STDERR: fail_deref_not_pointer.carbon:[[@LINE+3]]:3: ERROR: Cannot dereference operand of non-pointer type `()`.
  12. // CHECK:STDERR: *();
  13. // CHECK:STDERR: ^
  14. *();
  15. // CHECK:STDERR: fail_deref_not_pointer.carbon:[[@LINE+3]]:3: ERROR: Cannot dereference operand of non-pointer type `{}`.
  16. // CHECK:STDERR: *{};
  17. // CHECK:STDERR: ^
  18. *{};
  19. }
  20. // CHECK:STDOUT: --- fail_deref_not_pointer.carbon
  21. // CHECK:STDOUT:
  22. // CHECK:STDOUT: constants {
  23. // CHECK:STDOUT: %.loc15_5.1: type = tuple_type (), const
  24. // CHECK:STDOUT: %.loc15_5.2: () = tuple_value (), const
  25. // CHECK:STDOUT: %.loc19_5.1: type = struct_type {}, const
  26. // CHECK:STDOUT: %.loc19_5.2: {} = struct_value (), const
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: file {
  30. // CHECK:STDOUT: package: <namespace> = namespace package, {.Deref = %Deref}
  31. // CHECK:STDOUT: %Deref: <function> = fn_decl @Deref, const
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: fn @Deref(%n: i32) {
  35. // CHECK:STDOUT: !entry:
  36. // CHECK:STDOUT: %n.ref: i32 = name_ref n, %n
  37. // CHECK:STDOUT: %.loc11: ref <error> = deref %n.ref
  38. // CHECK:STDOUT: %.loc15_5.1: () = tuple_literal ()
  39. // CHECK:STDOUT: %.loc15_5.2: () = tuple_value (), const = constants.%.loc15_5.2
  40. // CHECK:STDOUT: %.loc15_5.3: () = converted %.loc15_5.1, %.loc15_5.2, const = constants.%.loc15_5.2
  41. // CHECK:STDOUT: %.loc15_3: ref <error> = deref %.loc15_5.3
  42. // CHECK:STDOUT: %.loc19_5.1: {} = struct_literal ()
  43. // CHECK:STDOUT: %.loc19_5.2: {} = struct_value (), const = constants.%.loc19_5.2
  44. // CHECK:STDOUT: %.loc19_5.3: {} = converted %.loc19_5.1, %.loc19_5.2, const = constants.%.loc19_5.2
  45. // CHECK:STDOUT: %.loc19_3: ref <error> = deref %.loc19_5.3
  46. // CHECK:STDOUT: return
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT: