fail_modifiers.carbon 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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/none.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/var/fail_modifiers.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/var/fail_modifiers.carbon
  12. // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:1: error: `protected` not allowed; requires class scope [ModifierProtectedNotAllowed]
  13. // CHECK:STDERR: protected var b: () = ();
  14. // CHECK:STDERR: ^~~~~~~~~
  15. // CHECK:STDERR:
  16. protected var b: () = ();
  17. // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+7]]:9: error: `protected` not allowed on declaration with `private` [ModifierNotAllowedWith]
  18. // CHECK:STDERR: private protected var c: () = ();
  19. // CHECK:STDERR: ^~~~~~~~~
  20. // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:1: note: `private` previously appeared here [ModifierPrevious]
  21. // CHECK:STDERR: private protected var c: () = ();
  22. // CHECK:STDERR: ^~~~~~~
  23. // CHECK:STDERR:
  24. private protected var c: () = ();
  25. // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+11]]:11: error: `protected` repeated on declaration [ModifierRepeated]
  26. // CHECK:STDERR: protected protected var d: () = ();
  27. // CHECK:STDERR: ^~~~~~~~~
  28. // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+8]]:1: note: `protected` previously appeared here [ModifierPrevious]
  29. // CHECK:STDERR: protected protected var d: () = ();
  30. // CHECK:STDERR: ^~~~~~~~~
  31. // CHECK:STDERR:
  32. // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:1: error: `protected` not allowed; requires class scope [ModifierProtectedNotAllowed]
  33. // CHECK:STDERR: protected protected var d: () = ();
  34. // CHECK:STDERR: ^~~~~~~~~
  35. // CHECK:STDERR:
  36. protected protected var d: () = ();
  37. // CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:1: error: `abstract` not allowed on `var` declaration [ModifierNotAllowedOnDeclaration]
  38. // CHECK:STDERR: abstract var e: () = ();
  39. // CHECK:STDERR: ^~~~~~~~
  40. // CHECK:STDERR:
  41. abstract var e: () = ();