Handle missing newline at EOF for linkerscript INCLUDEd files (#1691)

This commit is contained in:
Rangi
2025-05-22 04:55:58 -04:00
committed by GitHub
parent 5d998ef483
commit 804db4e073
9 changed files with 32 additions and 3 deletions

View File

@@ -251,10 +251,16 @@ yy::parser::symbol_type yylex() {
if (c == EOF) {
// Basically yywrap().
if (lexerStack.size() != 1) {
lexerStack.pop_back();
return yylex();
if (!atEof) {
// Inject a newline at EOF to simplify parsing.
atEof = true;
return yy::parser::make_newline();
} else {
lexerStack.pop_back();
return yylex();
}
} else if (!atEof) {
// Inject a newline at EOF, to avoid errors for files that don't end with one.
// Inject a newline at EOF to simplify parsing.
atEof = true;
return yy::parser::make_newline();
} else {