fail_base_no_extend.carbon 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 in class.
  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: %C: type = class_type @C [template]
  23. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  24. // CHECK:STDOUT: %.3: type = ptr_type %.1 [template]
  25. // CHECK:STDOUT: %.4: type = unbound_element_type %C, %B [template]
  26. // CHECK:STDOUT: %.5: type = struct_type {.base: %B} [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/operators
  33. // CHECK:STDOUT: import Core//prelude/types
  34. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  35. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  36. // CHECK:STDOUT: import Core//prelude/operators/comparison
  37. // CHECK:STDOUT: import Core//prelude/types/bool
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: file {
  42. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  43. // CHECK:STDOUT: .Core = imports.%Core
  44. // CHECK:STDOUT: .B = %B.decl
  45. // CHECK:STDOUT: .C = %C.decl
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT: %Core.import = import Core
  48. // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {}
  49. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: class @B {
  53. // CHECK:STDOUT: !members:
  54. // CHECK:STDOUT: .Self = constants.%B
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT:
  57. // CHECK:STDOUT: class @C {
  58. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [template = constants.%B]
  59. // CHECK:STDOUT: %.loc17: %.4 = base_decl %B, element0 [template]
  60. // CHECK:STDOUT:
  61. // CHECK:STDOUT: !members:
  62. // CHECK:STDOUT: .Self = constants.%C
  63. // CHECK:STDOUT: .base = %.loc17
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT: