fail_deref_error.carbon 3.4 KB

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