fail_base_modifiers.carbon 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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_modifiers.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_modifiers.carbon
  10. base class B {}
  11. class C1 {
  12. // CHECK:STDERR: fail_base_modifiers.carbon:[[@LINE+4]]:3: error: `private` not allowed on `base` declaration [ModifierNotAllowedOnDeclaration]
  13. // CHECK:STDERR: private extend base: B;
  14. // CHECK:STDERR: ^~~~~~~
  15. // CHECK:STDERR:
  16. private extend base: B;
  17. }
  18. class C2 {
  19. // CHECK:STDERR: fail_base_modifiers.carbon:[[@LINE+8]]:3: error: `abstract` not allowed on `base` declaration [ModifierNotAllowedOnDeclaration]
  20. // CHECK:STDERR: abstract base: B;
  21. // CHECK:STDERR: ^~~~~~~~
  22. // CHECK:STDERR:
  23. // CHECK:STDERR: fail_base_modifiers.carbon:[[@LINE+4]]:3: error: missing `extend` before `base` declaration [BaseMissingExtend]
  24. // CHECK:STDERR: abstract base: B;
  25. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~
  26. // CHECK:STDERR:
  27. abstract base: B;
  28. }
  29. class C3 {
  30. // CHECK:STDERR: fail_base_modifiers.carbon:[[@LINE+4]]:10: error: `default` not allowed on `base` declaration [ModifierNotAllowedOnDeclaration]
  31. // CHECK:STDERR: extend default base: B;
  32. // CHECK:STDERR: ^~~~~~~
  33. // CHECK:STDERR:
  34. extend default base: B;
  35. }
  36. class C4 {
  37. // CHECK:STDERR: fail_base_modifiers.carbon:[[@LINE+7]]:10: error: `extend` repeated on declaration [ModifierRepeated]
  38. // CHECK:STDERR: extend extend base: B;
  39. // CHECK:STDERR: ^~~~~~
  40. // CHECK:STDERR: fail_base_modifiers.carbon:[[@LINE+4]]:3: note: `extend` previously appeared here [ModifierPrevious]
  41. // CHECK:STDERR: extend extend base: B;
  42. // CHECK:STDERR: ^~~~~~
  43. // CHECK:STDERR:
  44. extend extend base: B;
  45. }