Merge pull request #150 from Ben10do/deprecation-positions

Add a warning() function, similiar to other error handlers
This commit is contained in:
AntonioND
2017-04-02 17:03:03 +01:00
committed by GitHub
3 changed files with 21 additions and 5 deletions

View File

@@ -27,6 +27,7 @@ extern void opt_Parse(char *s);
noreturn void fatalerror(const char *fmt, ...); noreturn void fatalerror(const char *fmt, ...);
void yyerror(const char *fmt, ...); void yyerror(const char *fmt, ...);
void warning(const char *fmt, ...);
#define YY_FATAL_ERROR fatalerror #define YY_FATAL_ERROR fatalerror

View File

@@ -1282,7 +1282,7 @@ z80_jp : T_Z80_JP const_16bit
{ {
out_AbsByte(0xE9); out_AbsByte(0xE9);
if( nPass==1 ) if( nPass==1 )
printf("warning:'JP [HL]' is obsolete, use 'JP HL' instead.\n"); warning("'JP [HL]' is obsolete, use 'JP HL' instead.\n");
} }
| T_Z80_JP T_MODE_HL | T_Z80_JP T_MODE_HL
{ out_AbsByte(0xE9); } { out_AbsByte(0xE9); }
@@ -1300,7 +1300,7 @@ z80_ldi : T_Z80_LDI T_MODE_HL_IND comma T_MODE_A
{ {
out_AbsByte(0x0A|(2<<4)); out_AbsByte(0x0A|(2<<4));
if( nPass==1 ) if( nPass==1 )
printf("warning:'LDI A,HL' is obsolete, use 'LDI A,[HL]' or 'LD A,[HL+] instead.\n"); warning("'LDI A,HL' is obsolete, use 'LDI A,[HL]' or 'LD A,[HL+] instead.\n");
} }
| T_Z80_LDI T_MODE_A comma T_MODE_HL_IND | T_Z80_LDI T_MODE_A comma T_MODE_HL_IND
{ out_AbsByte(0x0A|(2<<4)); } { out_AbsByte(0x0A|(2<<4)); }
@@ -1312,7 +1312,7 @@ z80_ldd : T_Z80_LDD T_MODE_HL_IND comma T_MODE_A
{ {
out_AbsByte(0x0A|(3<<4)); out_AbsByte(0x0A|(3<<4));
if( nPass==1 ) if( nPass==1 )
printf("warning:'LDD A,HL' is obsolete, use 'LDD A,[HL]' or 'LD A,[HL-] instead.\n"); warning("'LDD A,HL' is obsolete, use 'LDD A,[HL]' or 'LD A,[HL-] instead.\n");
} }
| T_Z80_LDD T_MODE_A comma T_MODE_HL_IND | T_Z80_LDD T_MODE_A comma T_MODE_HL_IND
{ out_AbsByte(0x0A|(3<<4)); } { out_AbsByte(0x0A|(3<<4)); }

View File

@@ -226,9 +226,9 @@ opt_ParseDefines()
void void
verror(const char *fmt, va_list args) verror(const char *fmt, va_list args)
{ {
fprintf(stderr, "ERROR:\t"); fprintf(stderr, "ERROR: ");
fstk_Dump(); fstk_Dump();
fprintf(stderr, " :\n\t"); fprintf(stderr, ":\n\t");
vfprintf(stderr, fmt, args); vfprintf(stderr, fmt, args);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
nErrors += 1; nErrors += 1;
@@ -253,6 +253,21 @@ fatalerror(const char *fmt, ...)
exit(5); exit(5);
} }
void
warning(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
fprintf(stderr, "warning: ");
fstk_Dump();
fprintf(stderr, ":\n\t");
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
va_end(args);
}
static void static void
usage(void) usage(void)
{ {