]> git.sur5r.net Git - cc65/blobdiff - src/cc65/scanner.c
Fixed an internal compiler error when the first token of a source file
[cc65] / src / cc65 / scanner.c
index 183898ff1a46fdb055245d638cfc912f2c8d6375..e87126f4101c9d6fb4d9566e248046ed2df1d479 100644 (file)
@@ -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 ());