fail_base_unbound.carbon 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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/class/fail_base_unbound.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/fail_base_unbound.carbon
  10. base class B {}
  11. class C {
  12. extend base: B;
  13. }
  14. // CHECK:STDERR: fail_base_unbound.carbon:[[@LINE+3]]:12: ERROR: Expression cannot be used as a value.
  15. // CHECK:STDERR: let b: B = C.base;
  16. // CHECK:STDERR: ^~~~~~
  17. let b: B = C.base;
  18. // CHECK:STDOUT: --- fail_base_unbound.carbon
  19. // CHECK:STDOUT:
  20. // CHECK:STDOUT: constants {
  21. // CHECK:STDOUT: %B: type = class_type @B [template]
  22. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  23. // CHECK:STDOUT: %C: type = class_type @C [template]
  24. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  25. // CHECK:STDOUT: %.3: type = ptr_type %.1 [template]
  26. // CHECK:STDOUT: %.4: type = unbound_element_type %C, %B [template]
  27. // CHECK:STDOUT: %.5: type = struct_type {.base: %B} [template]
  28. // CHECK:STDOUT: %.6: type = struct_type {.base: %.3} [template]
  29. // CHECK:STDOUT: %.7: type = ptr_type %.5 [template]
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: imports {
  33. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  34. // CHECK:STDOUT: import Core//prelude
  35. // CHECK:STDOUT: import Core//prelude/operators
  36. // CHECK:STDOUT: import Core//prelude/types
  37. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  38. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  39. // CHECK:STDOUT: import Core//prelude/operators/comparison
  40. // CHECK:STDOUT: import Core//prelude/types/bool
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: file {
  45. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  46. // CHECK:STDOUT: .Core = imports.%Core
  47. // CHECK:STDOUT: .B = %B.decl
  48. // CHECK:STDOUT: .C = %C.decl
  49. // CHECK:STDOUT: .b = @__global_init.%b
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT: %Core.import = import Core
  52. // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {}
  53. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  54. // CHECK:STDOUT: %B.ref: type = name_ref B, %B.decl [template = constants.%B]
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT:
  57. // CHECK:STDOUT: class @B {
  58. // CHECK:STDOUT: !members:
  59. // CHECK:STDOUT: .Self = constants.%B
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: class @C {
  63. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [template = constants.%B]
  64. // CHECK:STDOUT: %.loc14: %.4 = base_decl %B, element0 [template]
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: !members:
  67. // CHECK:STDOUT: .Self = constants.%C
  68. // CHECK:STDOUT: .base = %.loc14
  69. // CHECK:STDOUT: extend name_scope2
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT:
  72. // CHECK:STDOUT: fn @__global_init() {
  73. // CHECK:STDOUT: !entry:
  74. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  75. // CHECK:STDOUT: %base.ref: %.4 = name_ref base, @C.%.loc14 [template = @C.%.loc14]
  76. // CHECK:STDOUT: %b: %B = bind_name b, <error>
  77. // CHECK:STDOUT: return
  78. // CHECK:STDOUT: }
  79. // CHECK:STDOUT: