mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 08:01:05 +01:00
Drop GetDeclContext from parse, errors will be diagnosed in check (#3468)
The criteria being enforced is not correct since `final` and `default` functions in interfaces have definitions.
This commit is contained in:
@@ -417,30 +417,6 @@ auto Context::ConsumeListToken(NodeKind comma_kind, Lex::TokenKind close_kind,
|
||||
}
|
||||
}
|
||||
|
||||
auto Context::GetDeclContext() -> DeclContext {
|
||||
// i == 0 is the file-level DeclScopeLoop. Additionally, i == 1 can be
|
||||
// skipped because it will never be a DeclScopeLoop.
|
||||
for (int i = state_stack_.size() - 1; i > 1; --i) {
|
||||
// The declaration context is always the state _above_ a
|
||||
// DeclScopeLoop.
|
||||
if (state_stack_[i].state == State::DeclScopeLoop) {
|
||||
switch (state_stack_[i - 1].state) {
|
||||
case State::TypeDefinitionFinishAsClass:
|
||||
return DeclContext::Class;
|
||||
case State::TypeDefinitionFinishAsInterface:
|
||||
return DeclContext::Interface;
|
||||
case State::TypeDefinitionFinishAsNamedConstraint:
|
||||
return DeclContext::NamedConstraint;
|
||||
default:
|
||||
llvm_unreachable("Missing handling for a declaration scope");
|
||||
}
|
||||
}
|
||||
}
|
||||
CARBON_CHECK(!state_stack_.empty() &&
|
||||
state_stack_[0].state == State::DeclScopeLoop);
|
||||
return DeclContext::File;
|
||||
}
|
||||
|
||||
auto Context::RecoverFromDeclError(StateStackEntry state,
|
||||
NodeKind parse_node_kind,
|
||||
bool skip_past_likely_end) -> void {
|
||||
|
||||
Reference in New Issue
Block a user