fail_scope.carbon 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. class Class {
  7. fn F() -> i32 {
  8. return 1;
  9. }
  10. }
  11. fn G() -> i32 {
  12. // CHECK:STDERR: fail_scope.carbon:[[@LINE+3]]:10: ERROR: Name `F` not found.
  13. // CHECK:STDERR: return F();
  14. // CHECK:STDERR: ^
  15. return F();
  16. }
  17. // CHECK:STDOUT: --- fail_scope.carbon
  18. // CHECK:STDOUT:
  19. // CHECK:STDOUT: constants {
  20. // CHECK:STDOUT: %Class: type = class_type @Class [template]
  21. // CHECK:STDOUT: %Int32: type = fn_type @Int32 [template]
  22. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  23. // CHECK:STDOUT: %struct.1: Int32 = struct_value () [template]
  24. // CHECK:STDOUT: %F: type = fn_type @F [template]
  25. // CHECK:STDOUT: %struct.2: F = struct_value () [template]
  26. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  27. // CHECK:STDOUT: %.3: i32 = int_literal 1 [template]
  28. // CHECK:STDOUT: %G: type = fn_type @G [template]
  29. // CHECK:STDOUT: %struct.3: G = struct_value () [template]
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: file {
  33. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  34. // CHECK:STDOUT: .Core = %Core
  35. // CHECK:STDOUT: .Class = %Class.decl
  36. // CHECK:STDOUT: .G = %G.decl
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  39. // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {}
  40. // CHECK:STDOUT: %import_ref.1: Int32 = import_ref ir3, inst+3, loaded [template = constants.%struct.1]
  41. // CHECK:STDOUT: %import_ref.2: Int32 = import_ref ir3, inst+3, loaded [template = constants.%struct.1]
  42. // CHECK:STDOUT: %G.decl: G = fn_decl @G [template = constants.%struct.3] {
  43. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%struct.1() [template = i32]
  44. // CHECK:STDOUT: %.loc13_11.1: type = value_of_initializer %int.make_type_32 [template = i32]
  45. // CHECK:STDOUT: %.loc13_11.2: type = converted %int.make_type_32, %.loc13_11.1 [template = i32]
  46. // CHECK:STDOUT: @G.%return: ref i32 = var <return slot>
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: class @Class {
  51. // CHECK:STDOUT: %F.decl: F = fn_decl @F [template = constants.%struct.2] {
  52. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%struct.1() [template = i32]
  53. // CHECK:STDOUT: %.loc8_13.1: type = value_of_initializer %int.make_type_32 [template = i32]
  54. // CHECK:STDOUT: %.loc8_13.2: type = converted %int.make_type_32, %.loc8_13.1 [template = i32]
  55. // CHECK:STDOUT: %return.var: ref i32 = var <return slot>
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: !members:
  59. // CHECK:STDOUT: .Self = constants.%Class
  60. // CHECK:STDOUT: .F = %F.decl
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT:
  63. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: fn @F() -> i32 {
  66. // CHECK:STDOUT: !entry:
  67. // CHECK:STDOUT: %.loc9: i32 = int_literal 1 [template = constants.%.3]
  68. // CHECK:STDOUT: return %.loc9
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: fn @G() -> i32 {
  72. // CHECK:STDOUT: !entry:
  73. // CHECK:STDOUT: %F.ref: <error> = name_ref F, <error> [template = <error>]
  74. // CHECK:STDOUT: return <error>
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT: