X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=support%2FUtil%2FSDCCerr.c;h=6839b417bde682f632b2dd0904050dd297c2dfc3;hb=aa0ca082f440cf7b9cf126faf97e03fbbf0c0bc2;hp=b5a92ec46978b2e256115f21fc7251634cf64a97;hpb=589a7d9c77e21f8425d4c96bdc8446c84df27dca;p=fw%2Fsdcc diff --git a/support/Util/SDCCerr.c b/support/Util/SDCCerr.c index b5a92ec4..6839b417 100644 --- a/support/Util/SDCCerr.c +++ b/support/Util/SDCCerr.c @@ -29,11 +29,7 @@ #define DEFAULT_ERROR_OUT stderr #endif -static struct { - ERROR_LOG_LEVEL logLevel; - FILE *out; - int style; /* 1=MSVC */ -} _SDCCERRG; +struct SDCCERRG _SDCCERRG; extern char *filename ; extern int lineno ; @@ -85,7 +81,7 @@ struct { W_INIT_IGNORED, ERROR_LEVEL_WARNING, "Variable in the storage class cannot be initialized.'%s'" }, { E_AUTO_ASSUMED, ERROR_LEVEL_ERROR, - "storage class not allowed for automatic variable '%s' in reentrant function unless static" }, + "variable '%s' must be static to have storage class in reentrant function" }, { E_AUTO_ABSA, ERROR_LEVEL_ERROR, "absolute address not allowed for automatic var '%s' in reentrant function " }, { W_INIT_WRONG, ERROR_LEVEL_WARNING, @@ -241,8 +237,8 @@ struct "Functions called via pointers must be 'reentrant' to take arguments" }, { W_DOUBLE_UNSUPPORTED, ERROR_LEVEL_WARNING, "type 'double' not supported assuming 'float'" }, -{ W_IF_NEVER_TRUE, ERROR_LEVEL_WARNING, - "if-statement condition always false, if-statement not generated" }, +{ W_COMP_RANGE, ERROR_LEVEL_WARNING, + "comparison is always %s due to limited range of data type" }, { W_FUNC_NO_RETURN, ERROR_LEVEL_WARNING, "no 'return' statement found for function '%s'" }, { W_PRE_PROC_WARNING, ERROR_LEVEL_WARNING, @@ -350,7 +346,7 @@ struct { E_TWO_OR_MORE_STORAGE_CLASSES, ERROR_LEVEL_ERROR, "two or more storage classes in declaration for '%s'" }, { W_EXCESS_INITIALIZERS, ERROR_LEVEL_WARNING, - "excess elements in %s initializer after `%s'" }, + "excess elements in %s initializer after '%s'" }, { E_ARGUMENT_MISSING, ERROR_LEVEL_ERROR, "Option %s requires an argument." }, { W_STRAY_BACKSLASH, ERROR_LEVEL_WARNING, @@ -371,8 +367,8 @@ struct "symbol name too long, truncated to %d chars" }, { W_CAST_STRUCT_PTR,ERROR_LEVEL_WARNING, "cast of struct %s * to struct %s * " }, -{ W_IF_ALWAYS_TRUE, ERROR_LEVEL_WARNING, - "if-statement condition always true, if-statement not generated" }, +{ W_LIT_OVERFLOW, ERROR_LEVEL_WARNING, + "overflow in implicit constant conversion" }, { E_PARAM_NAME_OMITTED, ERROR_LEVEL_ERROR, "in function %s: name omitted for parameter %d" }, { W_NO_FILE_ARG_IN_C1, ERROR_LEVEL_WARNING, @@ -409,6 +405,33 @@ struct "pragma %s is deprecated, please see documentation for details" }, { E_SIZEOF_INCOMPLETE_TYPE, ERROR_LEVEL_ERROR, "sizeof applied to an incomplete type" }, +{ E_PREVIOUS_DEF, ERROR_LEVEL_ERROR, + "previously defined here" }, +{ W_SIZEOF_VOID, ERROR_LEVEL_WARNING, + "size of void is zero" }, +{ W_POSSBUG2, ERROR_LEVEL_WARNING, + "possible code generation error at %s line %d,\n" + " please report problem and send source code at SDCC-USER list on SF.Net"}, +{ W_COMPLEMENT, ERROR_LEVEL_WARNING, + "using ~ on bit/bool/unsigned char variables can give unexpected results due to promotion to int" }, +{ E_SHADOWREGS_NO_ISR, ERROR_LEVEL_ERROR, + "ISR function attribute 'shadowregs' following non-ISR function '%s'" }, +{ W_SFR_ABSRANGE, ERROR_LEVEL_WARNING, + "absolute address for sfr '%s' probably out of range." }, +{ E_BANKED_WITH_CALLEESAVES, ERROR_LEVEL_ERROR, + "Both banked and callee-saves cannot be used together." }, +{ W_INVALID_INT_CONST, ERROR_LEVEL_WARNING, + "integer constant '%s' out of range, truncated to %.0lf." }, +{ W_CMP_SU_CHAR, ERROR_LEVEL_PEDANTIC, + "comparison of 'signed char' with 'unsigned char' requires promotion to int" }, +{ W_INVALID_FLEXARRAY, ERROR_LEVEL_WARNING, + "invalid use of structure with flexible array member" }, +{ W_C89_NO_FLEXARRAY, ERROR_LEVEL_PEDANTIC, + "ISO C90 does not support flexible array members" }, +{ E_FLEXARRAY_NOTATEND, ERROR_LEVEL_ERROR, + "flexible array member not at end of struct" }, +{ E_FLEXARRAY_INEMPTYSTRCT, ERROR_LEVEL_ERROR, + "flexible array in otherwise empty struct" }, }; /* @@ -419,15 +442,13 @@ SetErrorOut - Set the error output file */ FILE *SetErrorOut(FILE *NewErrorOut) - { _SDCCERRG.out = NewErrorOut ; -return NewErrorOut ; + return NewErrorOut ; } -void -setErrorLogLevel (ERROR_LOG_LEVEL level) +void setErrorLogLevel (ERROR_LOG_LEVEL level) { _SDCCERRG.logLevel = level; } @@ -445,39 +466,37 @@ void vwerror (int errNum, va_list marker) _SDCCERRG.out = DEFAULT_ERROR_OUT; } - if (ErrTab[errNum].errIndex != errNum) - { + if (ErrTab[errNum].errIndex != errNum) { fprintf(_SDCCERRG.out, - "Internal error: error table entry for %d inconsistent.", errNum); + "Internal error: error table entry for %d inconsistent.", errNum); } - - if (ErrTab[errNum].errType >= _SDCCERRG.logLevel) { + if ((ErrTab[errNum].errType >= _SDCCERRG.logLevel) && (!_SDCCERRG.disabled[errNum])) { if ( ErrTab[errNum].errType == ERROR_LEVEL_ERROR ) fatalError++ ; if ( filename && lineno ) { - if(_SDCCERRG.style) - fprintf(_SDCCERRG.out, "%s(%d) : ",filename,lineno); - else - 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: "); } - + switch(ErrTab[errNum].errType) { case ERROR_LEVEL_ERROR: - fprintf(_SDCCERRG.out, "error: "); + fprintf(_SDCCERRG.out, "error %d: ", errNum); break; case ERROR_LEVEL_WARNING: case ERROR_LEVEL_PEDANTIC: - fprintf(_SDCCERRG.out, "warning: "); + fprintf(_SDCCERRG.out, "warning %d: ", errNum); break; case ERROR_LEVEL_INFO: - fprintf(_SDCCERRG.out, "info: "); + fprintf(_SDCCERRG.out, "info %d: ", errNum); break; default: break; @@ -485,8 +504,7 @@ void vwerror (int errNum, va_list marker) vfprintf(_SDCCERRG.out, ErrTab[errNum].errText,marker); fprintf(_SDCCERRG.out, "\n"); - } - else { + } else { /* Below the logging level, drop. */ } } @@ -553,7 +571,19 @@ style - Change the output error style to MSVC ------------------------------------------------------------------------------- */ -void MSVC_style (int style) +void MSVC_style (int style) { _SDCCERRG.style = style; } + +/* +------------------------------------------------------------------------------- +disabled - Disable output of specified warning +------------------------------------------------------------------------------- +*/ + +void setWarningDisabled (int errNum) +{ + if ((errNum < MAX_ERROR_WARNING) && (ErrTab[errNum].errType <= ERROR_LEVEL_WARNING)) + _SDCCERRG.disabled[errNum] = 1; +}