fail_base_modifiers.carbon 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/convert.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/inheritance/fail_base_modifiers.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/inheritance/fail_base_modifiers.carbon
  12. base class B {}
  13. class C1 {
  14. // CHECK:STDERR: fail_base_modifiers.carbon:[[@LINE+4]]:3: error: `private` not allowed on `base` declaration [ModifierNotAllowedOnDeclaration]
  15. // CHECK:STDERR: private extend base: B;
  16. // CHECK:STDERR: ^~~~~~~
  17. // CHECK:STDERR:
  18. private extend base: B;
  19. }
  20. class C2 {
  21. // CHECK:STDERR: fail_base_modifiers.carbon:[[@LINE+8]]:3: error: `abstract` not allowed on `base` declaration [ModifierNotAllowedOnDeclaration]
  22. // CHECK:STDERR: abstract base: B;
  23. // CHECK:STDERR: ^~~~~~~~
  24. // CHECK:STDERR:
  25. // CHECK:STDERR: fail_base_modifiers.carbon:[[@LINE+4]]:3: error: missing `extend` before `base` declaration [BaseMissingExtend]
  26. // CHECK:STDERR: abstract base: B;
  27. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~
  28. // CHECK:STDERR:
  29. abstract base: B;
  30. }
  31. class C3 {
  32. // CHECK:STDERR: fail_base_modifiers.carbon:[[@LINE+4]]:10: error: `default` not allowed on `base` declaration [ModifierNotAllowedOnDeclaration]
  33. // CHECK:STDERR: extend default base: B;
  34. // CHECK:STDERR: ^~~~~~~
  35. // CHECK:STDERR:
  36. extend default base: B;
  37. }
  38. class C4 {
  39. // CHECK:STDERR: fail_base_modifiers.carbon:[[@LINE+7]]:10: error: `extend` repeated on declaration [ModifierRepeated]
  40. // CHECK:STDERR: extend extend base: B;
  41. // CHECK:STDERR: ^~~~~~
  42. // CHECK:STDERR: fail_base_modifiers.carbon:[[@LINE+4]]:3: note: `extend` previously appeared here [ModifierPrevious]
  43. // CHECK:STDERR: extend extend base: B;
  44. // CHECK:STDERR: ^~~~~~
  45. // CHECK:STDERR:
  46. extend extend base: B;
  47. }