X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=support%2FUtil%2FSDCCerr.c;h=af987ae31b3eed4f67f67bdd3239f61e1331dd99;hb=d3e9a3c6e43e6623ed168709704e410609302ddd;hp=2efbdc8c2071dafc056ab2617b8603595eb2fce2;hpb=d197b07bdaca9791286af66f1d3a91a85e5265a8;p=fw%2Fsdcc diff --git a/support/Util/SDCCerr.c b/support/Util/SDCCerr.c index 2efbdc8c..af987ae3 100644 --- a/support/Util/SDCCerr.c +++ b/support/Util/SDCCerr.c @@ -17,10 +17,10 @@ */ #include +#include #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 ; @@ -114,7 +115,7 @@ struct { E_INT_REQD, ERROR_LEVEL_ERROR, "type must be INT for bit field definition" }, { E_BITFLD_SIZE, ERROR_LEVEL_ERROR, - "bit field size greater than 16. assuming 16" }, + "bit field size cannot be greater than int (%d bits)" }, { W_TRUNCATION, ERROR_LEVEL_WARNING, "high order truncation might occur" }, { E_CODE_WRITE, ERROR_LEVEL_ERROR, @@ -384,6 +385,18 @@ struct "duplicate %s member '%s'" }, { E_STACK_VIOLATION, ERROR_LEVEL_ERROR, "'%s' internal stack %s" }, +{ W_INT_OVL, ERROR_LEVEL_PEDANTIC, + "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" }, +{ W_BITFLD_NAMED, ERROR_LEVEL_WARNING, + "ignoring declarator of 0 length bitfield" }, +{ E_FUNC_ATTR, ERROR_LEVEL_ERROR, + "function attribute following non-function declaration"}, +{ W_SAVE_RESTORE, ERROR_LEVEL_PEDANTIC, + "unmatched #pragma SAVE and #pragma RESTORE" }, }; /* @@ -432,8 +445,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: "); @@ -459,7 +475,7 @@ void vwerror (int errNum, va_list marker) fprintf(_SDCCERRG.out, "\n"); } else { - // Below the logging level, drop. + /* Below the logging level, drop. */ } } /* @@ -469,11 +485,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; +}