X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=support%2FUtil%2FSDCCerr.c;h=374c383b58fa0632d71e6fc2fe37c7cbb35b539d;hb=d3116fbcb26b6893466538702b9ad9d5819687a7;hp=b21cc39d672202c1f98d0d08292627f3c576468b;hpb=bfd60fe0cc5ae4f16ce456a39f622bcc52ac2a70;p=fw%2Fsdcc diff --git a/support/Util/SDCCerr.c b/support/Util/SDCCerr.c index b21cc39d..374c383b 100644 --- a/support/Util/SDCCerr.c +++ b/support/Util/SDCCerr.c @@ -21,7 +21,6 @@ #include "SDCCerr.h" - #define USE_STDOUT_FOR_ERRORS 0 #if USE_STDOUT_FOR_ERRORS @@ -33,6 +32,7 @@ static struct { ERROR_LOG_LEVEL logLevel; FILE *out; + int style; /* 1=MSVC */ } _SDCCERRG; extern char *filename ; @@ -115,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, @@ -133,7 +133,7 @@ struct { E_ARG_COUNT, ERROR_LEVEL_ERROR, "Function was expecting more arguments" }, { E_FUNC_EXPECTED, ERROR_LEVEL_ERROR, - "Function name expected '%s'.ANSI style declaration REQUIRED" }, + "Function name expected '%s'. ANSI style declaration REQUIRED" }, { E_PLUS_INVALID, ERROR_LEVEL_ERROR, "invalid operand '%s'" }, { E_PTR_PLUS_PTR, ERROR_LEVEL_ERROR, @@ -155,7 +155,7 @@ struct { E_BIT_ARRAY, ERROR_LEVEL_ERROR, "Array or Pointer to bit|sbit|sfr not allowed.'%s'" }, { E_DUPLICATE_TYPEDEF, ERROR_LEVEL_ERROR, - "typedef/enum '%s' duplicate.Previous definiton Ignored" }, + "typedef/enum '%s' duplicate. Previous definiton Ignored" }, { E_ARG_TYPE, ERROR_LEVEL_ERROR, "Actual Argument type different from declaration %d" }, { E_RET_VALUE, ERROR_LEVEL_ERROR, @@ -165,7 +165,7 @@ struct { E_FUNC_DEF, ERROR_LEVEL_ERROR, "ANSI Style declaration needed" }, { E_DUPLICATE_LABEL, ERROR_LEVEL_ERROR, - "Label name redefined '%s'" }, + "Duplicate label '%s'" }, { E_LABEL_UNDEF, ERROR_LEVEL_ERROR, "Label undefined '%s'" }, { E_FUNC_VOID, ERROR_LEVEL_ERROR, @@ -175,9 +175,9 @@ struct { W_RETURN_MISMATCH, ERROR_LEVEL_WARNING, "function return value mismatch" }, { E_CASE_CONTEXT, ERROR_LEVEL_ERROR, - "'case/default' found without 'switch'.statement ignored" }, + "'case/default' found without 'switch'. Statement ignored" }, { E_CASE_CONSTANT, ERROR_LEVEL_ERROR, - "'case' expression not constant. statement ignored" }, + "'case' expression not constant. Statement ignored" }, { E_BREAK_CONTEXT, ERROR_LEVEL_ERROR, "'break/continue' statement out of context" }, { E_SWITCH_AGGR, ERROR_LEVEL_ERROR, @@ -211,9 +211,9 @@ struct { E_INCOMPAT_TYPES, ERROR_LEVEL_ERROR, "incompatible types" }, { W_LOOP_ELIMINATE, ERROR_LEVEL_WARNING, - "'while' loop with 'zero' constant.loop eliminated" }, + "'while' loop with 'zero' constant. Loop eliminated" }, { W_NO_SIDE_EFFECTS, ERROR_LEVEL_WARNING, - "%s expression has NO side effects.expr eliminated" }, + "%s expression has NO side effects. Expr eliminated" }, { W_CONST_TOO_LARGE, ERROR_LEVEL_PEDANTIC, "constant value '%s', out of range." }, { W_BAD_COMPARE, ERROR_LEVEL_WARNING, @@ -221,7 +221,7 @@ struct { E_TERMINATING, ERROR_LEVEL_ERROR, "Compiler Terminating , contact author with source" }, { W_LOCAL_NOINIT, ERROR_LEVEL_WARNING, - "'auto' variable '%s' may be used before initialization at %s(%d)" }, + "'auto' variable '%s' may be used before initialization" }, { W_NO_REFERENCE, ERROR_LEVEL_WARNING, "in function %s unreferenced %s : '%s'" }, { E_OP_UNKNOWN_SIZE, ERROR_LEVEL_ERROR, @@ -274,9 +274,9 @@ struct { W_FUNC_TOO_LARGE, ERROR_LEVEL_WARNING, "function '%s' too large for global optimization" }, { W_CONTROL_FLOW, ERROR_LEVEL_PEDANTIC, - "conditional flow changed by optimizer '%s(%d)':so said EVELYN the modified DOG" }, + "conditional flow changed by optimizer: so said EVELYN the modified DOG" }, { W_PTR_TYPE_INVALID, ERROR_LEVEL_WARNING, - "invalid type specifier for pointer type specifier ignored" }, + "invalid type specifier for pointer type; specifier ignored" }, { W_IMPLICIT_FUNC, ERROR_LEVEL_WARNING, "function '%s' implicit declaration" }, { W_CONTINUE, ERROR_LEVEL_WARNING, @@ -306,7 +306,7 @@ struct { W_CONST_RANGE, ERROR_LEVEL_WARNING, "constant is out of range %s" }, { W_CODE_UNREACH, ERROR_LEVEL_PEDANTIC, - "unreachable code %s(%d)" }, + "unreachable code" }, { E_NONPTR2_GENPTR, ERROR_LEVEL_ERROR, "non-pointer type cast to generic pointer" }, { W_POSSBUG, ERROR_LEVEL_WARNING, @@ -350,7 +350,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' at line %d" }, + "excess elements in %s initializer after `%s'" }, { E_ARGUMENT_MISSING, ERROR_LEVEL_ERROR, "Option %s requires an argument." }, { W_STRAY_BACKSLASH, ERROR_LEVEL_WARNING, @@ -385,6 +385,26 @@ 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" }, +{ E_INVALID_CRITICAL, ERROR_LEVEL_ERROR, + "not allowed in a critical section" }, +{ E_NOT_ALLOWED, ERROR_LEVEL_ERROR, + "%s not allowed here" }, +{ E_BAD_TAG, ERROR_LEVEL_ERROR, + "'%s' is not a %s tag" }, +{ E_ENUM_NON_INTEGER, ERROR_LEVEL_ERROR, + "enumeration constant not an integer" }, }; /* @@ -433,8 +453,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: "); @@ -460,7 +483,7 @@ void vwerror (int errNum, va_list marker) fprintf(_SDCCERRG.out, "\n"); } else { - // Below the logging level, drop. + /* Below the logging level, drop. */ } } /* @@ -470,12 +493,37 @@ 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); +} + +/* +------------------------------------------------------------------------------- +werrorfl - Output a standard eror message with variable number of arguements. + Use a specified filename and line number instead of the default. + +------------------------------------------------------------------------------- +*/ + +void werrorfl (char *newFilename, int newLineno, int errNum, ...) +{ + char *oldFilename = filename; + int oldLineno = lineno; + va_list marker; + + filename = newFilename; + lineno = newLineno; + + va_start(marker,errNum); + vwerror(errNum, marker); + va_end(marker); + + filename = oldFilename; + lineno = oldLineno; } @@ -485,12 +533,23 @@ fatal - Output a standard eror message with variable number of arguements and call exit() ------------------------------------------------------------------------------- */ -void fatal (int exitCode, int errNum, ... ) +void fatal (int exitCode, int errNum, ...) { - va_list marker; + va_list marker; va_start(marker,errNum); vwerror(errNum, marker); - va_end( marker ); + va_end(marker); exit(exitCode); } + +/* +------------------------------------------------------------------------------- +style - Change the output error style to MSVC +------------------------------------------------------------------------------- +*/ + +void MSVC_style (int style) +{ + _SDCCERRG.style = style; +}