From: cuz Date: Tue, 19 Aug 2003 20:30:55 +0000 (+0000) Subject: Fixed an internal compiler error when the first token of a source file X-Git-Tag: V2.12.0~1374 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7596da75f024b9c6e74735d60bff847ca173483a;p=cc65 Fixed an internal compiler error when the first token of a source file caused an error message. In this case, the line info was not available leading to a PRECONDITION VIOLATED. git-svn-id: svn://svn.cc65.org/cc65/trunk@2370 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/cc65/scanner.c b/src/cc65/scanner.c index 183898ff1..e87126f41 100644 --- a/src/cc65/scanner.c +++ b/src/cc65/scanner.c @@ -396,6 +396,14 @@ void NextToken (void) } CurTok = NextTok; + /* When reading the first time from the file, the line info in NextTok, + * which was copied to CurTok is invalid. Since the information from + * the token is used for error messages, we must make it valid. + */ + if (CurTok.LI == 0) { + CurTok.LI = UseLineInfo (GetCurLineInfo ()); + } + /* Remember the starting position of the next token */ NextTok.LI = UseLineInfo (GetCurLineInfo ());