fail_base_unbound.carbon 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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: }
  29. // CHECK:STDOUT:
  30. // CHECK:STDOUT: file {
  31. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  32. // CHECK:STDOUT: .Core = %Core
  33. // CHECK:STDOUT: .B = %B.decl
  34. // CHECK:STDOUT: .C = %C.decl
  35. // CHECK:STDOUT: .b = @__global_init.%b
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  38. // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {}
  39. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  40. // CHECK:STDOUT: %B.ref: type = name_ref B, %B.decl [template = constants.%B]
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: class @B {
  44. // CHECK:STDOUT: !members:
  45. // CHECK:STDOUT: .Self = constants.%B
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: class @C {
  49. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [template = constants.%B]
  50. // CHECK:STDOUT: %.loc14: %.4 = base_decl %B, element0 [template]
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: !members:
  53. // CHECK:STDOUT: .Self = constants.%C
  54. // CHECK:STDOUT: .base = %.loc14
  55. // CHECK:STDOUT: extend name_scope2
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: fn @__global_init() {
  59. // CHECK:STDOUT: !entry:
  60. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  61. // CHECK:STDOUT: %base.ref: %.4 = name_ref base, @C.%.loc14 [template = @C.%.loc14]
  62. // CHECK:STDOUT: %b: %B = bind_name b, <error>
  63. // CHECK:STDOUT: return
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT: