fail_deref_error.carbon 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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+4]]:15: error: name `undeclared` not found [NameNotFound]
  16. // CHECK:STDERR: let n2: i32 = undeclared->foo;
  17. // CHECK:STDERR: ^~~~~~~~~~
  18. // CHECK:STDERR:
  19. let n2: i32 = undeclared->foo;
  20. // CHECK:STDOUT: --- fail_deref_error.carbon
  21. // CHECK:STDOUT:
  22. // CHECK:STDOUT: constants {
  23. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  24. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  25. // CHECK:STDOUT: }
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: imports {
  28. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  29. // CHECK:STDOUT: .Int = %import_ref.485
  30. // CHECK:STDOUT: import Core//prelude
  31. // CHECK:STDOUT: import Core//prelude/...
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: file {
  36. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  37. // CHECK:STDOUT: .Core = imports.%Core
  38. // CHECK:STDOUT: .n = %n
  39. // CHECK:STDOUT: .n2 = %n2
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT: %Core.import = import Core
  42. // CHECK:STDOUT: name_binding_decl {
  43. // CHECK:STDOUT: %n.patt: %i32 = binding_pattern n
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT: %.loc15: type = splice_block %i32.loc15 [template = constants.%i32] {
  46. // CHECK:STDOUT: %int_32.loc15: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  47. // CHECK:STDOUT: %i32.loc15: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: %n: %i32 = bind_name n, <error>
  50. // CHECK:STDOUT: name_binding_decl {
  51. // CHECK:STDOUT: %n2.patt: %i32 = binding_pattern n2
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT: %.loc20: type = splice_block %i32.loc20 [template = constants.%i32] {
  54. // CHECK:STDOUT: %int_32.loc20: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  55. // CHECK:STDOUT: %i32.loc20: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT: %n2: %i32 = bind_name n2, <error>
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: fn @__global_init() {
  61. // CHECK:STDOUT: !entry:
  62. // CHECK:STDOUT: %undeclared.ref.loc15: <error> = name_ref undeclared, <error> [template = <error>]
  63. // CHECK:STDOUT: %.loc15: ref <error> = deref <error>
  64. // CHECK:STDOUT: %undeclared.ref.loc20: <error> = name_ref undeclared, <error> [template = <error>]
  65. // CHECK:STDOUT: %.loc20: ref <error> = deref <error>
  66. // CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [template = <error>]
  67. // CHECK:STDOUT: return
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT: