mirror of
https://github.com/gbdev/rgbds.git
synced 2026-06-10 02:32:34 +00:00
Fix off-by-one error with INCLUDEd linker script line numbers
This commit is contained in:
+5
-4
@@ -52,11 +52,10 @@ void lexer_IncludeFile(std::string &&path) {
|
||||
scriptError(
|
||||
"Failed to open included linker script \"%s\": %s", badPath.c_str(), strerror(errno)
|
||||
);
|
||||
// `.pop_back()` cannot invalidate an unpopped reference, so `prevContext`
|
||||
// is still valid even if `.open()` failed.
|
||||
++prevContext.lineNo;
|
||||
}
|
||||
|
||||
// `.pop_back()` cannot invalidate an unpopped reference, so `prevContext`
|
||||
// is still valid even if `.open()` failed.
|
||||
++prevContext.lineNo;
|
||||
}
|
||||
|
||||
void lexer_IncLineNo() {
|
||||
@@ -74,6 +73,8 @@ static yy::parser::symbol_type yywrap() {
|
||||
return yy::parser::make_newline();
|
||||
}
|
||||
lexerStack.pop_back();
|
||||
// Increment the line number *after* an INCLUDE has finished.
|
||||
++lexerStack.back().lineNo;
|
||||
return yylex();
|
||||
}
|
||||
if (!atEof) {
|
||||
|
||||
+2
-1
@@ -52,7 +52,8 @@ lines:
|
||||
|
||||
line:
|
||||
INCLUDE string newline {
|
||||
lexer_IncludeFile(std::move($2)); // Note: this additionally increments the line number!
|
||||
// This does *not* increment the line number until the included content has finished parsing!
|
||||
lexer_IncludeFile(std::move($2));
|
||||
}
|
||||
| directive newline {
|
||||
lexer_IncLineNo();
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
warning: Integer constant is too large [-Wlarge-constant]
|
||||
at large-constant.inc(1) <- large-constant.link(3)
|
||||
at large-constant.inc(1) <- large-constant.link(2)
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
error: The linker script assigns section "test" to address $0000, but it was already at $002a
|
||||
at linkerscript-include.inc(1) <- linkerscript-include.link(4)
|
||||
at linkerscript-include.inc(1) <- linkerscript-include.link(3)
|
||||
Linking failed with 1 error
|
||||
|
||||
Reference in New Issue
Block a user