modifiers.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. #ifndef CARBON_TOOLCHAIN_CHECK_MODIFIERS_H_
  5. #define CARBON_TOOLCHAIN_CHECK_MODIFIERS_H_
  6. #include "toolchain/check/context.h"
  7. namespace Carbon::Check {
  8. // Reports a diagnostic (using `decl_name`) if access control modifiers on this
  9. // are not allowed, and updates the declaration state in `context`.
  10. auto CheckAccessModifiersOnDecl(Context& context, Lex::TokenKind decl_kind)
  11. -> void;
  12. // Reports a diagnostic (using `decl_kind`) if modifiers on this declaration are
  13. // not in `allowed`. Updates the declaration state in
  14. // `context.decl_state_stack()`.
  15. auto LimitModifiersOnDecl(Context& context, KeywordModifierSet allowed,
  16. Lex::TokenKind decl_kind) -> void;
  17. // Like `LimitModifiersOnDecl`, except says which modifiers are forbidden, and a
  18. // `context_string` (and optional `context_node`) specifying the context in
  19. // which those modifiers are forbidden.
  20. auto ForbidModifiersOnDecl(Context& context, KeywordModifierSet forbidden,
  21. Lex::TokenKind decl_kind,
  22. llvm::StringRef context_string,
  23. Parse::NodeId context_node = Parse::NodeId::Invalid)
  24. -> void;
  25. // Report a diagonostic if `default` and `final` modifiers are used on
  26. // declarations where they are not allowed. Right now they are only allowed
  27. // inside interfaces.
  28. auto RequireDefaultFinalOnlyInInterfaces(Context& context,
  29. Lex::TokenKind decl_kind) -> void;
  30. } // namespace Carbon::Check
  31. #endif // CARBON_TOOLCHAIN_CHECK_MODIFIERS_H_