fail_base_no_extend.carbon 2.7 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/class/fail_base_no_extend.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_no_extend.carbon
  10. base class B {}
  11. class C {
  12. // CHECK:STDERR: fail_base_no_extend.carbon:[[@LINE+3]]:3: error: missing `extend` before `base` declaration [BaseMissingExtend]
  13. // CHECK:STDERR: base: B;
  14. // CHECK:STDERR: ^~~~~~~~
  15. base: B;
  16. }
  17. // CHECK:STDOUT: --- fail_base_no_extend.carbon
  18. // CHECK:STDOUT:
  19. // CHECK:STDOUT: constants {
  20. // CHECK:STDOUT: %B: type = class_type @B [template]
  21. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  22. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  23. // CHECK:STDOUT: %C: type = class_type @C [template]
  24. // CHECK:STDOUT: %.4: type = unbound_element_type %C, %B [template]
  25. // CHECK:STDOUT: %.5: type = struct_type {.base: %B} [template]
  26. // CHECK:STDOUT: %.6: <witness> = complete_type_witness %.5 [template]
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: imports {
  30. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  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: .B = %B.decl
  40. // CHECK:STDOUT: .C = %C.decl
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT: %Core.import = import Core
  43. // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} {}
  44. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: class @B {
  48. // CHECK:STDOUT: %.loc11: <witness> = complete_type_witness %.1 [template = constants.%.2]
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: !members:
  51. // CHECK:STDOUT: .Self = constants.%B
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT:
  54. // CHECK:STDOUT: class @C {
  55. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [template = constants.%B]
  56. // CHECK:STDOUT: %.loc17: %.4 = base_decl %B, element0 [template]
  57. // CHECK:STDOUT: %.loc18: <witness> = complete_type_witness %.5 [template = constants.%.6]
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: !members:
  60. // CHECK:STDOUT: .Self = constants.%C
  61. // CHECK:STDOUT: .base = %.loc17
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT: