]> git.sur5r.net Git - cc65/blobdiff - src/cc65/error.c
Added first provisions for a code size factor check in the optimizer
[cc65] / src / cc65 / error.c
index d6557c57ca85df624ef6fe31bb2d34e7c12dbebc..cba0a479e97ecb2dca7979037abf8696655a93c7 100644 (file)
@@ -43,6 +43,7 @@
 /* cc65 */
 #include "global.h"
 #include "input.h"
+#include "lineinfo.h"
 #include "scanner.h"
 #include "stmt.h"
 #include "error.h"
@@ -87,7 +88,7 @@ void Warning (const char* Format, ...)
 {
     va_list ap;
     va_start (ap, Format);
-    IntWarning (GetCurrentFile(), curpos, Format, ap);
+    IntWarning (GetInputName (CurTok.LI), GetInputLine (CurTok.LI), Format, ap);
     va_end (ap);
 }
 
@@ -125,7 +126,7 @@ void Error (const char* Format, ...)
 {
     va_list ap;
     va_start (ap, Format);
-    IntError (GetCurrentFile(), curpos, Format, ap);
+    IntError (GetInputName (CurTok.LI), GetInputLine (CurTok.LI), Format, ap);
     va_end (ap);
 }
 
@@ -147,7 +148,17 @@ void Fatal (const char* Format, ...)
 {
     va_list ap;
 
-    fprintf (stderr, "%s(%u): Fatal: ", GetCurrentFile(), curpos);
+    const char* FileName;
+    unsigned    LineNum;
+    if (CurTok.LI) {
+       FileName = GetInputName (CurTok.LI);
+       LineNum  = GetInputLine (CurTok.LI);
+    } else {
+       FileName = GetCurrentFile ();
+       LineNum  = GetCurrentLine ();
+    }
+
+    fprintf (stderr, "%s(%u): Fatal: ", FileName, LineNum);
 
     va_start (ap, Format);
     vfprintf (stderr, Format, ap);
@@ -160,13 +171,23 @@ void Fatal (const char* Format, ...)
 
 
 
-void Internal (char* Format, ...)
+void Internal (const char* Format, ...)
 /* Print a message about an internal compiler error and die. */
 {
     va_list ap;
 
+    const char* FileName;
+    unsigned    LineNum;
+    if (CurTok.LI) {
+       FileName = GetInputName (CurTok.LI);
+       LineNum  = GetInputLine (CurTok.LI);
+    } else {
+       FileName = GetCurrentFile ();
+       LineNum  = GetCurrentLine ();
+    }
+
     fprintf (stderr, "%s(%u): Internal compiler error:\n",
-            GetCurrentFile(), curpos);
+            FileName, LineNum);
 
     va_start (ap, Format);
     vfprintf (stderr, Format, ap);
@@ -175,7 +196,7 @@ void Internal (char* Format, ...)
 
     /* Use abort to create a core dump */
     abort ();
-}
+}              
 
 
 
@@ -190,3 +211,4 @@ void ErrorReport (void)
 
 
 
+