Skip to content

Commit

Permalink
Fix parser error when invalid class override specifiers exists at the…
Browse files Browse the repository at this point in the history
… end of a file
  • Loading branch information
MikePopoloski committed Nov 26, 2024
1 parent 051c03f commit 47ccb86
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion source/parsing/Parser_members.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -999,9 +999,12 @@ ClassSpecifierSyntax* Parser::parseClassSpecifier() {
case TokenKind::FinalKeyword:
keyword = consume();
break;
default:
case TokenKind::Identifier:
skipToken(diag::ExpectedClassSpecifier);
break;
default:
addDiag(diag::ExpectedClassSpecifier, peek().location());
break;
}

auto& result = factory.classSpecifier(colon, keyword);
Expand Down
9 changes: 9 additions & 0 deletions tests/unittests/parsing/MemberParsingTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1522,3 +1522,12 @@ endclass
REQUIRE(diagnostics.size() == 1);
CHECK(diagnostics[0].code == diag::SpecifiersNotAllowed);
}

TEST_CASE("Class specifier parsing crash regress") {
auto& text = R"(
task:
)";

parseCompilationUnit(text, LanguageVersion::v1800_2023);
REQUIRE(diagnostics.size() == 3);
}

0 comments on commit 47ccb86

Please sign in to comment.