fail_deref_not_pointer.carbon 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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: %.1: type = tuple_type () [template]
  24. // CHECK:STDOUT: %.2: () = tuple_value () [template]
  25. // CHECK:STDOUT: %.3: type = struct_type {} [template]
  26. // CHECK:STDOUT: %.4: {} = struct_value () [template]
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: file {
  30. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  31. // CHECK:STDOUT: .Deref = %Deref
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT: %Deref: <function> = fn_decl @Deref [template] {
  34. // CHECK:STDOUT: %n.loc7_10.1: i32 = param n
  35. // CHECK:STDOUT: @Deref.%n: i32 = bind_name n, %n.loc7_10.1
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: fn @Deref(%n: i32) {
  40. // CHECK:STDOUT: !entry:
  41. // CHECK:STDOUT: %n.ref: i32 = name_ref n, %n
  42. // CHECK:STDOUT: %.loc11: ref <error> = deref %n.ref
  43. // CHECK:STDOUT: %.loc15_5.1: () = tuple_literal ()
  44. // CHECK:STDOUT: %.loc15_5.2: () = tuple_value () [template = constants.%.2]
  45. // CHECK:STDOUT: %.loc15_5.3: () = converted %.loc15_5.1, %.loc15_5.2 [template = constants.%.2]
  46. // CHECK:STDOUT: %.loc15_3: ref <error> = deref %.loc15_5.3
  47. // CHECK:STDOUT: %.loc19_5.1: {} = struct_literal ()
  48. // CHECK:STDOUT: %.loc19_5.2: {} = struct_value () [template = constants.%.4]
  49. // CHECK:STDOUT: %.loc19_5.3: {} = converted %.loc19_5.1, %.loc19_5.2 [template = constants.%.4]
  50. // CHECK:STDOUT: %.loc19_3: ref <error> = deref %.loc19_5.3
  51. // CHECK:STDOUT: return
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT: