fail_deref_error.carbon 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/pointer/fail_deref_error.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/pointer/fail_deref_error.carbon
  10. // CHECK:STDERR: fail_deref_error.carbon:[[@LINE+4]]:15: ERROR: Name `undeclared` not found.
  11. // CHECK:STDERR: let n: i32 = *undeclared;
  12. // CHECK:STDERR: ^~~~~~~~~~
  13. // CHECK:STDERR:
  14. let n: i32 = *undeclared;
  15. // CHECK:STDERR: fail_deref_error.carbon:[[@LINE+3]]:15: ERROR: Name `undeclared` not found.
  16. // CHECK:STDERR: let n2: i32 = undeclared->foo;
  17. // CHECK:STDERR: ^~~~~~~~~~
  18. let n2: i32 = undeclared->foo;
  19. // CHECK:STDOUT: --- fail_deref_error.carbon
  20. // CHECK:STDOUT:
  21. // CHECK:STDOUT: constants {
  22. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  23. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  24. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  25. // CHECK:STDOUT: }
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: file {
  28. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  29. // CHECK:STDOUT: .Core = %Core
  30. // CHECK:STDOUT: .n = @__global_init.%n
  31. // CHECK:STDOUT: .n2 = @__global_init.%n2
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  34. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  35. // CHECK:STDOUT: %int.make_type_32.loc15: init type = call constants.%Int32() [template = i32]
  36. // CHECK:STDOUT: %.loc15_8.1: type = value_of_initializer %int.make_type_32.loc15 [template = i32]
  37. // CHECK:STDOUT: %.loc15_8.2: type = converted %int.make_type_32.loc15, %.loc15_8.1 [template = i32]
  38. // CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  39. // CHECK:STDOUT: %int.make_type_32.loc19: init type = call constants.%Int32() [template = i32]
  40. // CHECK:STDOUT: %.loc19_9.1: type = value_of_initializer %int.make_type_32.loc19 [template = i32]
  41. // CHECK:STDOUT: %.loc19_9.2: type = converted %int.make_type_32.loc19, %.loc19_9.1 [template = i32]
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  45. // CHECK:STDOUT:
  46. // CHECK:STDOUT: fn @__global_init() {
  47. // CHECK:STDOUT: !entry:
  48. // CHECK:STDOUT: %undeclared.ref.loc15: <error> = name_ref undeclared, <error> [template = <error>]
  49. // CHECK:STDOUT: %.loc15: ref <error> = deref <error>
  50. // CHECK:STDOUT: %n: i32 = bind_name n, <error>
  51. // CHECK:STDOUT: %undeclared.ref.loc19: <error> = name_ref undeclared, <error> [template = <error>]
  52. // CHECK:STDOUT: %.loc19: ref <error> = deref <error>
  53. // CHECK:STDOUT: %n2: i32 = bind_name n2, <error>
  54. // CHECK:STDOUT: return
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT: