summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/Libraries/LibCpp/Parser.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/Userland/Libraries/LibCpp/Parser.cpp b/Userland/Libraries/LibCpp/Parser.cpp
index fd3eba2600..c3a630f0db 100644
--- a/Userland/Libraries/LibCpp/Parser.cpp
+++ b/Userland/Libraries/LibCpp/Parser.cpp
@@ -1311,7 +1311,7 @@ Vector<StringView> Parser::parse_function_qualifiers()
if (token.type() != Token::Type::Keyword)
break;
auto text = text_of_token(token);
- if (text == "static" || text == "inline" || text == "extern") {
+ if (text == "static" || text == "inline" || text == "extern" || text == "virtual") {
qualifiers.append(text);
consume();
} else {
@@ -1595,6 +1595,9 @@ bool Parser::match_destructor(const StringView& class_name)
save_state();
ScopeGuard state_guard = [this] { load_state(); };
+ if (match_keyword("virtual"))
+ consume();
+
if (!match(Token::Type::Tilde))
return false;
consume();
@@ -1611,13 +1614,19 @@ bool Parser::match_destructor(const StringView& class_name)
while (consume().type() != Token::Type::RightParen && !eof()) { };
+ if (match_keyword("override"))
+ consume();
+
return (peek(Token::Type::Semicolon).has_value() || peek(Token::Type::LeftCurly).has_value());
}
void Parser::parse_constructor_or_destructor_impl(FunctionDeclaration& func, CtorOrDtor type)
{
- if (type == CtorOrDtor::Dtor)
+ if (type == CtorOrDtor::Dtor) {
+ if (match_keyword("virtual"))
+ func.set_qualifiers({ consume().text() });
consume(Token::Type::Tilde);
+ }
auto name_token = consume();
if (name_token.type() != Token::Type::Identifier && name_token.type() != Token::Type::KnownType) {
@@ -1636,6 +1645,9 @@ void Parser::parse_constructor_or_destructor_impl(FunctionDeclaration& func, Cto
consume(Token::Type::RightParen);
+ if (type == CtorOrDtor::Dtor && match_keyword("override"))
+ consume();
+
// TODO: Parse =default, =delete.
RefPtr<FunctionDefinition> body;