fail_deref_error.carbon 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 [NameNotFound]
  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 [NameNotFound]
  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: %Int32: %Int32.type = struct_value () [template]
  24. // CHECK:STDOUT: }
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: imports {
  27. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  28. // CHECK:STDOUT: .Int32 = %import_ref
  29. // CHECK:STDOUT: import Core//prelude
  30. // CHECK:STDOUT: import Core//prelude/...
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: file {
  35. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  36. // CHECK:STDOUT: .Core = imports.%Core
  37. // CHECK:STDOUT: .n = @__global_init.%n
  38. // CHECK:STDOUT: .n2 = @__global_init.%n2
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: %Core.import = import Core
  41. // CHECK:STDOUT: %int.make_type_32.loc15: init type = call constants.%Int32() [template = i32]
  42. // CHECK:STDOUT: %.loc15_8.1: type = value_of_initializer %int.make_type_32.loc15 [template = i32]
  43. // CHECK:STDOUT: %.loc15_8.2: type = converted %int.make_type_32.loc15, %.loc15_8.1 [template = i32]
  44. // CHECK:STDOUT: %int.make_type_32.loc19: init type = call constants.%Int32() [template = i32]
  45. // CHECK:STDOUT: %.loc19_9.1: type = value_of_initializer %int.make_type_32.loc19 [template = i32]
  46. // CHECK:STDOUT: %.loc19_9.2: type = converted %int.make_type_32.loc19, %.loc19_9.1 [template = i32]
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: fn @__global_init() {
  50. // CHECK:STDOUT: !entry:
  51. // CHECK:STDOUT: %undeclared.ref.loc15: <error> = name_ref undeclared, <error> [template = <error>]
  52. // CHECK:STDOUT: %.loc15: ref <error> = deref <error>
  53. // CHECK:STDOUT: %n: i32 = bind_name n, <error>
  54. // CHECK:STDOUT: %undeclared.ref.loc19: <error> = name_ref undeclared, <error> [template = <error>]
  55. // CHECK:STDOUT: %.loc19: ref <error> = deref <error>
  56. // CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [template = <error>]
  57. // CHECK:STDOUT: %n2: i32 = bind_name n2, <error>
  58. // CHECK:STDOUT: return
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT: