Made the constant following the "interrupt" keyword optional. If omitted,
[fw/sdcc] / support / Util / SDCCerr.c
index 86ae987e0c50dbe3cc945df0c58acd06d7752cd6..925b81c2b9f83b729d8f138580b1fb1be9eacea5 100644 (file)
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 
 #include "SDCCerr.h"
 
-
 #define USE_STDOUT_FOR_ERRORS          0
 
 #if USE_STDOUT_FOR_ERRORS
@@ -32,6 +32,7 @@
 static struct {
     ERROR_LOG_LEVEL logLevel;
     FILE *out;
+    int style; /* 1=MSVC */
 } _SDCCERRG;
 
 extern char *filename ;
@@ -118,7 +119,7 @@ struct
 { W_TRUNCATION, ERROR_LEVEL_WARNING,
    "high order truncation might occur" },
 { E_CODE_WRITE, ERROR_LEVEL_ERROR,
-   "Attempt to assign value to a constant variable %s" },
+   "Attempt to assign value to a constant variable (%s)" },
 { E_LVALUE_CONST, ERROR_LEVEL_ERROR,
    "Lvalue specifies constant object" },
 { E_ILLEGAL_ADDR, ERROR_LEVEL_ERROR,
@@ -169,7 +170,7 @@ struct
    "Label undefined '%s'" },
 { E_FUNC_VOID, ERROR_LEVEL_ERROR,
    "void function returning value" },
-{ E_VOID_FUNC, ERROR_LEVEL_ERROR,
+{ W_VOID_FUNC, ERROR_LEVEL_WARNING,
    "function '%s' must return value" },
 { W_RETURN_MISMATCH, ERROR_LEVEL_WARNING,
    "function return value mismatch" },
@@ -380,6 +381,16 @@ struct
     "must specify assembler file name with -o in c1 mode" },
 { W_ILLEGAL_OPT_COMBINATION, ERROR_LEVEL_WARNING,
     "illegal combination of options (--c1mode, -E, -S -c)" },
+{ E_DUPLICATE_MEMBER, ERROR_LEVEL_ERROR,
+    "duplicate %s member '%s'" },
+{ E_STACK_VIOLATION, ERROR_LEVEL_ERROR,
+    "'%s' internal stack %s" },
+{ W_INT_OVL, ERROR_LEVEL_WARNING,
+    "integer overflow in expression" },
+{ W_USELESS_DECL, ERROR_LEVEL_WARNING,
+    "useless declaration (possible use of keyword as variable name)" },
+{ E_INT_BAD_INTNO, ERROR_LEVEL_ERROR,
+    "interrupt number '%u' is not valid" },
 };
 
 /*
@@ -428,8 +439,11 @@ void vwerror (int errNum, va_list marker)
             fatalError++ ;
   
         if ( filename && lineno ) {
-            fprintf(_SDCCERRG.out, "%s:%d: ",filename,lineno);
-        } else if (lineno) {
+                       if(_SDCCERRG.style)
+                               fprintf(_SDCCERRG.out, "%s(%d) : ",filename,lineno);
+                       else
+                               fprintf(_SDCCERRG.out, "%s:%d: ",filename,lineno);
+         } else if (lineno) {
             fprintf(_SDCCERRG.out, "at %d: ", lineno);
         } else {
             fprintf(_SDCCERRG.out, "-:0: ");
@@ -455,7 +469,7 @@ void vwerror (int errNum, va_list marker)
         fprintf(_SDCCERRG.out, "\n");
     }
     else {
-        // Below the logging level, drop.
+        /* Below the logging level, drop. */
     }
 }
 /*
@@ -465,11 +479,38 @@ werror - Output a standard eror message with variable number of arguements
 -------------------------------------------------------------------------------
 */
 
-void werror (int errNum, ... )
+void werror (int errNum, ...)
 {
-    va_list    marker;
+    va_list marker;
     va_start(marker,errNum);
     vwerror(errNum, marker);
-    va_end( marker );
+    va_end(marker);
 }
 
+
+/*
+-------------------------------------------------------------------------------
+fatal - Output a standard eror message with variable number of arguements and
+        call exit()
+-------------------------------------------------------------------------------
+*/
+void fatal (int exitCode, int errNum, ...)
+{
+    va_list marker;
+    va_start(marker,errNum);
+    vwerror(errNum, marker);
+    va_end(marker);
+
+    exit(exitCode);
+}
+
+/*
+-------------------------------------------------------------------------------
+style - Change the output error style to MSVC
+-------------------------------------------------------------------------------
+*/
+
+void    MSVC_style (int style)
+{
+    _SDCCERRG.style = style;
+}