From 221ef5a9c20b89c26535c59612dbe6f4b515e856 Mon Sep 17 00:00:00 2001 From: cuz Date: Sun, 15 Oct 2000 19:52:01 +0000 Subject: [PATCH] Error handling cleanup/changes. git-svn-id: svn://svn.cc65.org/cc65/trunk@369 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/cc65/codegen.c | 4 +- src/cc65/declare.c | 2 +- src/cc65/error.c | 148 +++++++++++++++------------------------------ src/cc65/error.h | 69 +++------------------ src/cc65/expr.c | 10 +-- src/cc65/input.c | 8 +-- src/cc65/litpool.c | 2 +- src/cc65/locals.c | 2 +- src/cc65/main.c | 10 +-- src/cc65/pragma.c | 4 +- src/cc65/preproc.c | 39 ++++++------ src/cc65/scanner.c | 8 +-- src/cc65/stmt.c | 8 +-- src/cc65/symtab.c | 6 +- 14 files changed, 111 insertions(+), 209 deletions(-) diff --git a/src/cc65/codegen.c b/src/cc65/codegen.c index 4a041b4e8..74e5b9774 100644 --- a/src/cc65/codegen.c +++ b/src/cc65/codegen.c @@ -3372,7 +3372,7 @@ void g_lt (unsigned flags, unsigned long val) /* Give a warning in some special cases */ if ((flags & CF_UNSIGNED) && val == 0) { - Warning (WARN_COND_NEVER_TRUE); + Warning ("Condition is never true"); } /* Look at the type */ @@ -3587,7 +3587,7 @@ void g_ge (unsigned flags, unsigned long val) /* Give a warning in some special cases */ if ((flags & CF_UNSIGNED) && val == 0) { - Warning (WARN_COND_ALWAYS_TRUE); + Warning ("Condition is always true"); } /* Look at the type */ diff --git a/src/cc65/declare.c b/src/cc65/declare.c index c2b4c5313..004a9c27a 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -907,7 +907,7 @@ void CheckEmptyDecl (const DeclSpec* D) */ { if ((D->Flags & DS_EXTRA_TYPE) == 0) { - Warning (WARN_USELESS_DECL); + Warning ("Useless declaration"); } } diff --git a/src/cc65/error.c b/src/cc65/error.c index 8fdea9068..95db80a45 100644 --- a/src/cc65/error.c +++ b/src/cc65/error.c @@ -51,30 +51,8 @@ -static char* WarnMsg [WARN_COUNT-1] = { - "Unreachable code", - "Condition is never true", - "Condition is always true", - "Converting pointer to integer without a cast", - "Converting integer to pointer without a cast", - "Function call without a prototype", - "Unknown #pragma", - "No case labels", - "Function must be extern", - "Parameter `%s' is never used", - "`%s' is defined but never used", - "Constant is long", - "`/*' found inside a comment", - "Useless declaration", -}; - - - /* Error messages sorted by ErrTypes */ static char* ErrMsg [ERR_COUNT-1] = { - "Invalid character (%u)", - "Unexpected newline", - "End-of-file reached in comment starting at line %u", "Syntax error", "`\"' expected", "`:' expected", @@ -92,23 +70,11 @@ static char* ErrMsg [ERR_COUNT-1] = { "Incompatible pointer types", "Too many arguments in function call", "Too few arguments in function call", - "Macro argument count mismatch", "Duplicate macro parameter: %s", - "Macro redefinition is not identical", "Variable identifier expected", "Integer expression expected", "Constant expression expected", "No active loop", - "`\"' or `<' expected", - "Missing terminator or name too long", - "Include file `%s' not found", - "Cannot open include file `%s': %s", - "Invalid #error directive", - "#error: %s", - "Unexpected `#endif'", - "Unexpected `#else'", - "`#endif' expected", - "Compiler directive expected", "Redefinition of `%s'", "Conflicting types for `%s'", "String literal expected", @@ -118,7 +84,6 @@ static char* ErrMsg [ERR_COUNT-1] = { "Unexpected `continue'", "Undefined symbol: `%s'", "Undefined label: `%s'", - "Include nesting too deep", "Too many local variables", "Too many initializers", "Cannot initialize incomplete type", @@ -134,7 +99,6 @@ static char* ErrMsg [ERR_COUNT-1] = { "Illegal function call", "Illegal indirection", "Illegal address", - "Illegal macro call", "Illegal hex digit", "Illegal character constant", "Illegal modifier", @@ -162,20 +126,6 @@ static char* ErrMsg [ERR_COUNT-1] = { -static char* FatMsg [FAT_COUNT-1] = { - "Too many errors", - "Cannot open output file: %s", - "Cannot write to output file (disk full?)", - "Cannot open input file: %s", - "Out of memory", - "Stack overflow", - "Stack empty", - "Out of string space", - "Too many case labels", -}; - - - /* Count of errors/warnings */ unsigned ErrorCount = 0; unsigned WarningCount = 0; @@ -188,59 +138,50 @@ unsigned WarningCount = 0; -void Warning (unsigned WarnNum, ...) -/* Print warning message. */ +static void IntWarning (const char* Filename, unsigned Line, const char* Msg, va_list ap) +/* Print warning message - internal function. */ { - va_list ap; - if (!NoWarn) { - fprintf (stderr, "%s(%u): Warning #%u: ", - GetCurrentFile(), curpos, WarnNum); - - va_start (ap, WarnNum); - vfprintf (stderr, WarnMsg [WarnNum-1], ap); - va_end (ap); + fprintf (stderr, "%s(%u): Warning: ", Filename, Line); + vfprintf (stderr, Msg, ap); fprintf (stderr, "\n"); if (Verbose) { fprintf (stderr, "Line: %s\n", line); } + ++WarningCount; } - ++ WarningCount; } -void PPWarning (unsigned WarnNum, ...) -/* Print warning message. For use within the preprocessor. */ +void Warning (const char* Format, ...) +/* Print warning message. */ { va_list ap; - - if (!NoWarn) { - fprintf (stderr, "%s(%u): Warning #%u: ", - GetCurrentFile(), GetCurrentLine(), WarnNum); - - va_start (ap, WarnNum); - vfprintf (stderr, WarnMsg [WarnNum-1], ap); - va_end (ap); - fprintf (stderr, "\n"); - } - ++WarningCount; + va_start (ap, Format); + IntWarning (GetCurrentFile(), curpos, Format, ap); + va_end (ap); } -void Error (unsigned ErrNum, ...) -/* Print an error message */ +void PPWarning (const char* Format, ...) +/* Print warning message. For use within the preprocessor. */ { va_list ap; + va_start (ap, Format); + IntWarning (GetCurrentFile(), GetCurrentLine(), Format, ap); + va_end (ap); +} - fprintf (stderr, "%s(%u): Error #%u: ", - GetCurrentFile(), curpos, ErrNum); - va_start (ap, ErrNum); - vfprintf (stderr, ErrMsg [ErrNum-1], ap); - va_end (ap); + +static void IntError (const char* Filename, unsigned Line, const char* Msg, va_list ap) +/* Print an error message - internal function*/ +{ + fprintf (stderr, "%s(%u): Error: ", Filename, Line); + vfprintf (stderr, Msg, ap); fprintf (stderr, "\n"); if (Verbose) { @@ -248,43 +189,54 @@ void Error (unsigned ErrNum, ...) } ++ErrorCount; if (ErrorCount > 10) { - Fatal (FAT_TOO_MANY_ERRORS); + Fatal ("Too many errors"); } } -void PPError (unsigned ErrNum, ...) -/* Print an error message. For use within the preprocessor. */ +void Error (unsigned ErrNum, ...) +/* Print an error message */ { va_list ap; + va_start (ap, ErrNum); + IntError (GetCurrentFile(), curpos, ErrMsg [ErrNum-1], ap); + va_end (ap); +} - fprintf (stderr, "%s(%u): Error #%u: ", - GetCurrentFile(), GetCurrentLine(), ErrNum); - va_start (ap, ErrNum); - vfprintf (stderr, ErrMsg [ErrNum-1], ap); + +void MError (const char* Format, ...) +/* Print an error message */ +{ + va_list ap; + va_start (ap, Format); + IntError (GetCurrentFile(), curpos, Format, ap); va_end (ap); - fprintf (stderr, "\n"); +} - ++ErrorCount; - if (ErrorCount > 10) { - Fatal (FAT_TOO_MANY_ERRORS); - } + + +void PPError (const char* Format, ...) +/* Print an error message. For use within the preprocessor. */ +{ + va_list ap; + va_start (ap, Format); + IntError (GetCurrentFile(), GetCurrentLine(), Format, ap); + va_end (ap); } -void Fatal (unsigned FatNum, ...) +void Fatal (const char* Format, ...) /* Print a message about a fatal error and die */ { va_list ap; - fprintf (stderr, "%s(%u): Fatal #%u: ", - GetCurrentFile(), curpos, FatNum); + fprintf (stderr, "%s(%u): Fatal: ", GetCurrentFile(), curpos); - va_start (ap, FatNum); - vfprintf (stderr, FatMsg [FatNum-1], ap); + va_start (ap, Format); + vfprintf (stderr, Format, ap); va_end (ap); fprintf (stderr, "\n"); diff --git a/src/cc65/error.h b/src/cc65/error.h index c44518300..b67fcb240 100644 --- a/src/cc65/error.h +++ b/src/cc65/error.h @@ -49,32 +49,9 @@ -/* Warning numbers */ -enum Warnings { - WARN_NONE, /* No warning */ - WARN_UNREACHABLE_CODE, - WARN_COND_NEVER_TRUE, - WARN_COND_ALWAYS_TRUE, - WARN_PTR_TO_INT_CONV, - WARN_INT_TO_PTR_CONV, - WARN_FUNC_WITHOUT_PROTO, - WARN_UNKNOWN_PRAGMA, - WARN_NO_CASE_LABELS, - WARN_FUNC_MUST_BE_EXTERN, - WARN_UNUSED_PARM, - WARN_UNUSED_ITEM, - WARN_CONSTANT_IS_LONG, - WARN_NESTED_COMMENT, - WARN_USELESS_DECL, - WARN_COUNT /* Warning count */ -}; - /* Error numbers */ -enum Errors { +enum Errors { ERR_NONE, /* No error */ - ERR_INVALID_CHAR, - ERR_UNEXPECTED_NEWLINE, - ERR_EOF_IN_COMMENT, ERR_SYNTAX, ERR_QUOTE_EXPECTED, ERR_COLON_EXPECTED, @@ -92,23 +69,11 @@ enum Errors { ERR_INCOMPATIBLE_POINTERS, ERR_TOO_MANY_FUNC_ARGS, ERR_TOO_FEW_FUNC_ARGS, - ERR_MACRO_ARGCOUNT, ERR_DUPLICATE_MACRO_ARG, - ERR_MACRO_REDEF, ERR_VAR_IDENT_EXPECTED, ERR_INT_EXPR_EXPECTED, ERR_CONST_EXPR_EXPECTED, ERR_NO_ACTIVE_LOOP, - ERR_INCLUDE_LTERM_EXPECTED, - ERR_INCLUDE_RTERM_EXPECTED, - ERR_INCLUDE_NOT_FOUND, - ERR_INCLUDE_OPEN_FAILURE, - ERR_INVALID_USER_ERROR, - ERR_USER_ERROR, - ERR_UNEXPECTED_CPP_ENDIF, - ERR_UNEXPECTED_CPP_ELSE, - ERR_CPP_ENDIF_EXPECTED, - ERR_CPP_DIRECTIVE_EXPECTED, ERR_MULTIPLE_DEFINITION, ERR_CONFLICTING_TYPES, ERR_STRLIT_EXPECTED, @@ -118,7 +83,6 @@ enum Errors { ERR_UNEXPECTED_CONTINUE, ERR_UNDEFINED_SYMBOL, ERR_UNDEFINED_LABEL, - ERR_INCLUDE_NESTING, ERR_TOO_MANY_LOCALS, ERR_TOO_MANY_INITIALIZERS, ERR_INIT_INCOMPLETE_TYPE, @@ -134,7 +98,6 @@ enum Errors { ERR_ILLEGAL_FUNC_CALL, ERR_ILLEGAL_INDIRECT, ERR_ILLEGAL_ADDRESS, - ERR_ILLEGAL_MACRO_CALL, ERR_ILLEGAL_HEX_DIGIT, ERR_ILLEGAL_CHARCONST, ERR_ILLEGAL_MODIFIER, @@ -161,23 +124,6 @@ enum Errors { ERR_COUNT /* Error count */ }; -/* Fatal errors */ -enum Fatals { - FAT_NONE, - FAT_TOO_MANY_ERRORS, - FAT_CANNOT_OPEN_OUTPUT, - FAT_CANNOT_WRITE_OUTPUT, - FAT_CANNOT_OPEN_INPUT, - FAT_OUT_OF_MEMORY, - FAT_STACK_OVERFLOW, - FAT_STACK_EMPTY, - FAT_OUT_OF_STRSPACE, - FAT_TOO_MANY_CASE_LABELS, - FAT_COUNT /* Fatal error count */ -}; - - - /* Count of errors/warnings */ extern unsigned ErrorCount; extern unsigned WarningCount; @@ -190,22 +136,25 @@ extern unsigned WarningCount; -void Warning (unsigned WarnNum, ...); +void Warning (const char* Format, ...) attribute ((format (printf, 1, 2))); /* Print warning message. */ -void PPWarning (unsigned WarnNum, ...); +void PPWarning (const char* Format, ...) attribute ((format (printf, 1, 2))); /* Print warning message. For use within the preprocessor. */ void Error (unsigned ErrNum, ...); /* Print an error message */ -void PPError (unsigned ErrNum, ...); +void MError (const char* Format, ...) attribute ((format (printf, 1, 2))); +/* Print an error message */ + +void PPError (const char* Format, ...) attribute ((format (printf, 1, 2))); /* Print an error message. For use within the preprocessor. */ -void Fatal (unsigned FatNum, ...); +void Fatal (const char* Format, ...) attribute ((noreturn, format (printf, 1, 2))); /* Print a message about a fatal error and die */ -void Internal (char* Format, ...) attribute ((noreturn)); +void Internal (char* Format, ...) attribute ((noreturn, format (printf, 1, 2))); /* Print a message about an internal compiler error and die. */ void ErrorReport (void); diff --git a/src/cc65/expr.c b/src/cc65/expr.c index a971ee322..b7bd14ac2 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -213,9 +213,9 @@ unsigned assignadjust (type* lhst, struct expent* rhs) } else if (IsClassInt (lhst)) { if (IsClassPtr (rhst)) { /* Pointer -> int conversion */ - Warning (WARN_PTR_TO_INT_CONV); + Warning ("Converting pointer to integer without a cast"); } else if (!IsClassInt (rhst)) { - Error (ERR_INCOMPATIBLE_TYPES); + Error (ERR_INCOMPATIBLE_TYPES); } else { /* Adjust the int types. To avoid manipulation of TOS mark lhs * as const. @@ -253,7 +253,7 @@ unsigned assignadjust (type* lhst, struct expent* rhs) } else if (IsClassInt (rhst)) { /* Int to pointer assignment is valid only for constant zero */ if ((rhs->e_flags & E_MCONST) == 0 || rhs->e_const != 0) { - Warning (WARN_INT_TO_PTR_CONV); + Warning ("Converting integer to pointer without a cast"); } } else if (IsTypeFuncPtr (lhst) && IsTypeFunc(rhst)) { /* Assignment of function to function pointer is allowed, provided @@ -815,7 +815,7 @@ static int primary (struct expent* lval) * function signature for a function having an empty param list * and returning int. */ - Warning (WARN_FUNC_WITHOUT_PROTO); + Warning ("Function call without a prototype"); Sym = AddGlobalSym (Ident, GetImplicitFuncType(), SC_EXTERN | SC_REF | SC_FUNC); lval->e_tptr = Sym->Type; lval->e_flags = E_MGLOBAL | E_MCONST | E_TGLAB; @@ -3008,7 +3008,7 @@ void test (unsigned label, int cond) /* Constant rvalue */ if (cond == 0 && lval.e_const == 0) { g_jump (label); - Warning (WARN_UNREACHABLE_CODE); + Warning ("Unreachable code"); } else if (cond && lval.e_const) { g_jump (label); } diff --git a/src/cc65/input.c b/src/cc65/input.c index d4b278f1d..cefeed6a9 100644 --- a/src/cc65/input.c +++ b/src/cc65/input.c @@ -198,7 +198,7 @@ void OpenMainFile (const char* Name) FILE* F = fopen (Name, "r"); if (F == 0) { /* Cannot open */ - Fatal (FAT_CANNOT_OPEN_INPUT, strerror (errno)); + Fatal ("Cannot open input file `%s': %s", Name, strerror (errno)); } /* Allocate a new AFile structure for the file */ @@ -216,14 +216,14 @@ void OpenIncludeFile (const char* Name, unsigned DirSpec) /* Check for the maximum include nesting */ if (CollCount (&AFiles) > MAX_INC_NESTING) { - PPError (ERR_INCLUDE_NESTING); + PPError ("Include nesting too deep"); return; } /* Search for the file */ N = FindInclude (Name, DirSpec); if (N == 0) { - PPError (ERR_INCLUDE_NOT_FOUND, Name); + PPError ("Include file `%s' not found", Name); return; } @@ -242,7 +242,7 @@ void OpenIncludeFile (const char* Name, unsigned DirSpec) F = fopen (IF->Name, "r"); if (F == 0) { /* Error opening the file */ - PPError (ERR_INCLUDE_OPEN_FAILURE, IF->Name, strerror (errno)); + PPError ("Cannot open include file `%s': %s", IF->Name, strerror (errno)); return; } diff --git a/src/cc65/litpool.c b/src/cc65/litpool.c index 801a5ab43..2d4432c53 100644 --- a/src/cc65/litpool.c +++ b/src/cc65/litpool.c @@ -140,7 +140,7 @@ void AddLiteralChar (char C) /* Add one character to the literal pool */ { if (LiteralOffs >= LITPOOL_SIZE) { - Fatal (FAT_OUT_OF_STRSPACE); + Fatal ("Out of literal space"); } LiteralPool[LiteralOffs++] = C; } diff --git a/src/cc65/locals.c b/src/cc65/locals.c index 082488443..af3d169f3 100644 --- a/src/cc65/locals.c +++ b/src/cc65/locals.c @@ -152,7 +152,7 @@ static void ParseOneDecl (const DeclSpec* Spec) if (IsTypeFunc (Decl.Type)) { /* Function prototypes are always external */ if ((SC & SC_EXTERN) == 0) { - Warning (WARN_FUNC_MUST_BE_EXTERN); + Warning ("Function must be extern"); } SC |= SC_FUNC | SC_EXTERN; diff --git a/src/cc65/main.c b/src/cc65/main.c index 0b2e0e709..7d68817f9 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -174,7 +174,7 @@ static void SetSys (const char* Sys) default: AbEnd ("Unknown target system type"); - } + } /* Initialize the translation tables for the target system */ TgtTranslateInit (); @@ -191,7 +191,7 @@ static void DoCreateDep (const char* OutputName) /* Open the file */ FILE* F = fopen (DepName, "w"); if (F == 0) { - Fatal (FAT_CANNOT_OPEN_OUTPUT, strerror (errno)); + Fatal ("Cannot open dependency file `%s': %s", DepName, strerror (errno)); } /* Write the dependencies to the file */ @@ -200,7 +200,7 @@ static void DoCreateDep (const char* OutputName) /* Close the file, check for errors */ if (fclose (F) != 0) { remove (DepName); - Fatal (FAT_CANNOT_WRITE_OUTPUT); + Fatal ("Cannot write to dependeny file (disk full?)"); } /* Free the name */ @@ -615,7 +615,7 @@ int main (int argc, char* argv[]) /* Open the file */ F = fopen (OutputFile, "w"); if (F == 0) { - Fatal (FAT_CANNOT_OPEN_OUTPUT, strerror (errno)); + Fatal ("Cannot open output file `%s': %s", OutputFile, strerror (errno)); } /* Write the output to the file */ @@ -624,7 +624,7 @@ int main (int argc, char* argv[]) /* Close the file, check for errors */ if (fclose (F) != 0) { remove (OutputFile); - Fatal (FAT_CANNOT_WRITE_OUTPUT); + Fatal ("Cannot write to output file (disk full?)"); } /* Create dependencies if requested */ diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index 27ed3a53d..ebd429379 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -151,7 +151,7 @@ static void SegNamePragma (void (*Func) (const char*)) Func (Name); } else { - + /* Segment name is invalid */ Error (ERR_ILLEGAL_SEG_NAME, Name); @@ -201,7 +201,7 @@ void DoPragma (void) * for unknown pragmas, however, we're allowed to warn - and we will * do so. Otherwise one typo may give you hours of bug hunting... */ - Warning (WARN_UNKNOWN_PRAGMA); + Warning ("Unknown #pragma `%s'", CurTok.Ident); return; } diff --git a/src/cc65/preproc.c b/src/cc65/preproc.c index e884f49ac..4877dad3b 100644 --- a/src/cc65/preproc.c +++ b/src/cc65/preproc.c @@ -98,12 +98,13 @@ static void Comment (void) while (CurC != '*' || NextC != '/') { if (CurC == '\0') { if (NextLine () == 0) { - PPError (ERR_EOF_IN_COMMENT, StartingLine); + PPError ("End-of-file reached in comment starting at line %u", + StartingLine); return; } } else { if (CurC == '/' && NextC == '*') { - PPWarning (WARN_NESTED_COMMENT); + PPWarning ("`/*' found inside a comment"); } NextChar (); } @@ -170,7 +171,7 @@ static int MacName (char* Ident) /* Get macro symbol name. If error, print message and clear line. */ { if (IsSym (Ident) == 0) { - PPError (ERR_IDENT_EXPECTED); + PPError ("Identifier expected"); ClearLine (); return 0; } else { @@ -242,7 +243,7 @@ static int MacroCall (Macro* M) /* Expect an argument list */ SkipBlank (); if (CurC != '(') { - PPError (ERR_ILLEGAL_MACRO_CALL); + PPError ("Illegal macro call"); return 0; } @@ -315,7 +316,7 @@ static int MacroCall (Macro* M) /* Compare formal argument count with actual */ if (M->ArgCount != ArgCount) { - PPError (ERR_MACRO_ARGCOUNT); + PPError ("Macro argument count mismatch"); /* Be sure to make enough empty arguments available */ while (ArgCount < M->ArgCount) { M->ActualArgs [ArgCount++] = ""; @@ -395,7 +396,7 @@ static void addmac (void) /* Check for a right paren and eat it if we find one */ if (CurC != ')') { - PPError (ERR_RPAREN_EXPECTED); + PPError ("`)' expected"); ClearLine (); return; } @@ -421,7 +422,7 @@ static void addmac (void) */ if (Existing) { if (MacroCmp (M, Existing) != 0) { - PPError (ERR_MACRO_REDEF); + PPError ("Macro redefinition is not identical"); } } } @@ -465,7 +466,7 @@ static int Pass1 (const char* From, char* To) SkipBlank(); } if (!IsIdent (CurC)) { - PPError (ERR_IDENT_EXPECTED); + PPError ("Identifier expected"); *mptr++ = '0'; } else { SymName (Ident); @@ -473,7 +474,7 @@ static int Pass1 (const char* From, char* To) if (HaveParen) { SkipBlank(); if (CurC != ')') { - PPError (ERR_RPAREN_EXPECTED); + PPError ("`)' expected"); } else { NextChar (); } @@ -701,7 +702,7 @@ static void doinclude (void) break; default: - PPError (ERR_INCLUDE_LTERM_EXPECTED); + PPError ("`\"' or `<' expected"); goto Done; } NextChar (); @@ -719,7 +720,7 @@ static void doinclude (void) /* Check if we got a terminator */ if (CurC != RTerm) { /* No terminator found */ - PPError (ERR_INCLUDE_RTERM_EXPECTED); + PPError ("Missing terminator or file name too long"); goto Done; } @@ -740,9 +741,9 @@ static void doerror (void) { SkipBlank (); if (CurC == '\0') { - PPError (ERR_INVALID_USER_ERROR); + PPError ("Invalid #error directive"); } else { - PPError (ERR_USER_ERROR, lptr); + PPError ("#error: %s", lptr); } /* clear rest of line */ @@ -818,7 +819,7 @@ void Preprocess (void) continue; } if (!IsSym (Directive)) { - PPError (ERR_CPP_DIRECTIVE_EXPECTED); + PPError ("Preprocessor directive expected"); ClearLine (); } else { switch (searchtok (Directive, pre_toks)) { @@ -836,7 +837,7 @@ void Preprocess (void) } s_ifdef[i_ifdef] ^= 2; } else { - PPError (ERR_UNEXPECTED_CPP_ELSE); + PPError ("Unexpected `#else'"); } break; @@ -844,7 +845,7 @@ void Preprocess (void) if (i_ifdef >= 0) { Skip = s_ifdef[i_ifdef--] & 1; } else { - PPError (ERR_UNEXPECTED_CPP_ENDIF); + PPError ("Unexpected `#endif'"); } break; @@ -875,7 +876,7 @@ void Preprocess (void) case PP_LINE: /* Not allowed in strict ANSI mode */ if (ANSI) { - PPError (ERR_CPP_DIRECTIVE_EXPECTED); + PPError ("Preprocessor directive expected"); ClearLine (); } break; @@ -896,7 +897,7 @@ void Preprocess (void) break; default: - PPError (ERR_CPP_DIRECTIVE_EXPECTED); + PPError ("Preprocessor directive expected"); ClearLine (); } } @@ -904,7 +905,7 @@ void Preprocess (void) } if (NextLine () == 0) { if (i_ifdef >= 0) { - PPError (ERR_CPP_ENDIF_EXPECTED); + PPError ("`#endif' expected"); } return; } diff --git a/src/cc65/scanner.c b/src/cc65/scanner.c index 5249b7134..ae339ed9d 100644 --- a/src/cc65/scanner.c +++ b/src/cc65/scanner.c @@ -192,7 +192,7 @@ int IsSym (char *s) static void unknown (char C) /* Error message for unknown character */ { - Error (ERR_INVALID_CHAR, C); + MError ("Invalid input character with code %02X", C & 0xFF); NextChar (); /* Skip */ } @@ -350,7 +350,7 @@ static void StringConst (void) while (CurC != '\"') { if (CurC == '\0') { - Error (ERR_UNEXPECTED_NEWLINE); + MError ("Unexpected newline"); break; } AddLiteralChar (ParseChar ()); @@ -458,7 +458,7 @@ void NextToken (void) * warning. */ if (k <= 0xFFFF && (types & IT_UINT) == 0 && !HaveSuffix) { - Warning (WARN_CONSTANT_IS_LONG); + Warning ("Constant is long"); } } if (k > 0xFFFF) { @@ -754,7 +754,7 @@ void NextToken (void) } while (CurC == ' '); if (!IsSym (token) || strcmp (token, "pragma") != 0) { /* OOPS - should not happen */ - Error (ERR_CPP_DIRECTIVE_EXPECTED); + MError ("Preprocessor directive expected"); } nxttok = TOK_PRAGMA; break; diff --git a/src/cc65/stmt.c b/src/cc65/stmt.c index 496843c2f..2d1d0ea8c 100644 --- a/src/cc65/stmt.c +++ b/src/cc65/stmt.c @@ -13,7 +13,7 @@ /* common */ #include "xmalloc.h" - + /* cc65 */ #include "asmcode.h" #include "asmlabel.h" @@ -395,7 +395,7 @@ static void cascadeswitch (struct expent* eval) /* Check if we have any labels */ if (lcount == 0) { - Warning (WARN_NO_CASE_LABELS); + Warning ("No case labels"); } /* Eat the closing curly brace */ @@ -451,7 +451,7 @@ static void tableswitch (struct expent* eval) while (curtok != TOK_RCURLY) { if (curtok == TOK_CASE || curtok == TOK_DEFAULT) { if (lcount >= CASE_MAX) { - Fatal (FAT_TOO_MANY_CASE_LABELS); + Fatal ("Too many case labels"); } label = GetLabel (); do { @@ -481,7 +481,7 @@ static void tableswitch (struct expent* eval) /* Check if we have any labels */ if (lcount == 0) { - Warning (WARN_NO_CASE_LABELS); + Warning ("No case labels"); } /* Eat the closing curly brace */ diff --git a/src/cc65/symtab.c b/src/cc65/symtab.c index 11a4252f4..45af446ab 100644 --- a/src/cc65/symtab.c +++ b/src/cc65/symtab.c @@ -165,9 +165,9 @@ static void CheckSymTable (SymTable* Tab) if (((Flags & SC_AUTO) || (Flags & SC_STATIC)) && (Flags & SC_EXTERN) == 0) { if ((Flags & SC_DEF) && !(Flags & SC_REF)) { if (Flags & SC_PARAM) { - Warning (WARN_UNUSED_PARM, Entry->Name); + Warning ("Parameter `%s' is never used", Entry->Name); } else { - Warning (WARN_UNUSED_ITEM, Entry->Name); + Warning ("`%s' is defined but never used", Entry->Name); } } } @@ -179,7 +179,7 @@ static void CheckSymTable (SymTable* Tab) Error (ERR_UNDEFINED_LABEL, Entry->Name); } else if ((Flags & SC_REF) == 0) { /* Defined but not used */ - Warning (WARN_UNUSED_ITEM, Entry->Name); + Warning ("`%s' is defined but never used", Entry->Name); } } -- 2.39.5