X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=support%2FUtil%2FSDCCerr.c;h=0770abd44d27eca9f6d9141445ddcc8a022635f7;hb=aa19331a763254d88391d0d953725162a654da14;hp=12816428d6badfbb5a817e331f0d4f7ae15fa1a6;hpb=bf85b4cb3c675c32d900f2f8c0e42b13086e7e98;p=fw%2Fsdcc diff --git a/support/Util/SDCCerr.c b/support/Util/SDCCerr.c index 12816428..0770abd4 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 ; @@ -54,7 +55,7 @@ struct { E_SYNTAX_ERROR, ERROR_LEVEL_ERROR, "Syntax error, declaration ignored at '%s'" }, { E_CONST_EXPECTED, ERROR_LEVEL_ERROR, - "Constant Expected Found Variable" }, + "Initializer element is not constant" }, { E_OUT_OF_MEM, ERROR_LEVEL_ERROR, "'malloc' failed file '%s' for size %ld" }, { E_FILE_OPEN_ERR, ERROR_LEVEL_ERROR, @@ -71,13 +72,13 @@ struct "FATAL Compiler Internal Error in file '%s' line number '%d' : %s \n" "Contact Author with source code" }, { E_LVALUE_REQUIRED, ERROR_LEVEL_ERROR, - "'lvalue' required for '%s' operation ." }, + "'lvalue' required for '%s' operation." }, { E_TMPFILE_FAILED, ERROR_LEVEL_ERROR, "Creation of temp file failed" }, { E_FUNCTION_EXPECTED, ERROR_LEVEL_ERROR, "called object is not a function" }, { E_USING_ERROR, ERROR_LEVEL_ERROR, - "'using', 'interrupt' or 'reentrant' must follow a function definiton .'%s'" }, + "'using', 'interrupt' or 'reentrant' must follow a function definiton.'%s'" }, { E_SFR_INIT, ERROR_LEVEL_ERROR, "Absolute address & initial value both cannot be specified for\n" " a 'sfr','sbit' storage class, initial value ignored '%s'" }, @@ -114,11 +115,11 @@ 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, - "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" }, @@ -226,7 +227,7 @@ struct { E_OP_UNKNOWN_SIZE, ERROR_LEVEL_ERROR, "unknown size for operand" }, { W_LONG_UNSUPPORTED, ERROR_LEVEL_WARNING, - "'%s' 'long' not supported , declared as 'int' ." }, + "'%s' 'long' not supported , declared as 'int'." }, { E_LITERAL_GENERIC, ERROR_LEVEL_ERROR, //"illegal cast of LITERAL value to 'generic' pointer: assuming 'xdata' pointer" }, "illegal cast of LITERAL value to 'generic' pointer" }, @@ -241,7 +242,7 @@ struct { 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" }, + "if-statement condition always false, if-statement not generated" }, { W_FUNC_NO_RETURN, ERROR_LEVEL_WARNING, "no 'return' statement found for function '%s'" }, { W_PRE_PROC_WARNING, ERROR_LEVEL_WARNING, @@ -280,8 +281,8 @@ struct "function '%s' implicit declaration" }, { W_CONTINUE, ERROR_LEVEL_WARNING, "%s" }, -{ I_TOOMANY_SPILS, ERROR_LEVEL_INFO, - "extended by %d bytes for compiler temp(s) :in function '%s': %s " }, +{ I_EXTENDED_STACK_SPILS, ERROR_LEVEL_INFO, + "extended stack by %d bytes for compiler temp(s) :in function '%s': %s " }, { W_UNKNOWN_PRAGMA, ERROR_LEVEL_WARNING, "unknown or unsupported #pragma directive '%s'" }, { W_SHIFT_CHANGED, ERROR_LEVEL_PEDANTIC, @@ -293,7 +294,7 @@ struct { W_UNKNOWN_FEXT, ERROR_LEVEL_WARNING, "don't know what to do with file '%s'. file extension unsupported" }, { W_TOO_MANY_SRC, ERROR_LEVEL_WARNING, - "cannot compile more than one source file . file '%s' ignored" }, + "cannot compile more than one source file. file '%s' ignored" }, { I_CYCLOMATIC, ERROR_LEVEL_INFO, "function '%s', # edges %d , # nodes %d , cyclomatic complexity %d" }, { E_DIVIDE_BY_ZERO, ERROR_LEVEL_ERROR, @@ -311,7 +312,7 @@ struct { W_POSSBUG, ERROR_LEVEL_WARNING, "possible code generation error at line %d,\n" " send source to sandeep.dutta@usa.net" }, -{ E_INCOMPAT_PTYPES, ERROR_LEVEL_WARNING, +{ E_INCOMPAT_PTYPES, ERROR_LEVEL_ERROR, "pointer types incompatible " }, { W_UNKNOWN_MODEL, ERROR_LEVEL_WARNING, "unknown memory model at %s : %d" }, @@ -370,6 +371,34 @@ 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" }, +{ E_PARAM_NAME_OMITTED, ERROR_LEVEL_ERROR, + "in function %s: name omitted for parameter %d" }, +{ W_NO_FILE_ARG_IN_C1, ERROR_LEVEL_WARNING, + "only standard input is compiled in c1 mode. file '%s' ignored" }, +{ E_NEED_OPT_O_IN_C1, ERROR_LEVEL_ERROR, + "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_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" }, +{ E_INVALID_CRITICAL, ERROR_LEVEL_ERROR, + "not allowed in a critical section" }, }; /* @@ -409,7 +438,7 @@ void vwerror (int errNum, va_list marker) 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); } @@ -418,22 +447,27 @@ void vwerror (int errNum, va_list marker) fatalError++ ; if ( filename && lineno ) { - fprintf(_SDCCERRG.out, "%s(%d):",filename,lineno); - } else if (lineno) { - fprintf(_SDCCERRG.out, "at %d:", 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: "); break; case ERROR_LEVEL_WARNING: case ERROR_LEVEL_PEDANTIC: - fprintf(_SDCCERRG.out, "warning *** "); + fprintf(_SDCCERRG.out, "warning: "); break; case ERROR_LEVEL_INFO: - fprintf(_SDCCERRG.out, "info *** "); + fprintf(_SDCCERRG.out, "info: "); break; default: break; @@ -443,7 +477,7 @@ void vwerror (int errNum, va_list marker) fprintf(_SDCCERRG.out, "\n"); } else { - // Below the logging level, drop. + /* Below the logging level, drop. */ } } /* @@ -453,11 +487,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; +}