ref: ff2ba7290cfc3e59e9c93432a14e890e64ac430b
parent: 53842cd07d8ebfb05ce2cba545279ed0cae58210
author: Ben10do <[email protected]>
date: Sun Apr 2 09:18:29 EDT 2017
Add a warning() function, similiar to yyerror() This function produces a similar output to the other error handlers, including printing to stderr, and including a stack trace. However, ‘warning’ is displayed instead of ‘ERROR’, and the compilation does not fail. This function is now used for the deprecation warnings, ensuring that these errors can be found.
--- a/include/asm/main.h
+++ b/include/asm/main.h
@@ -27,6 +27,7 @@
noreturn void fatalerror(const char *fmt, ...);
void yyerror(const char *fmt, ...);
+void warning(const char *fmt, ...);
#define YY_FATAL_ERROR fatalerror
--- a/src/asm/asmy.y
+++ b/src/asm/asmy.y
@@ -1282,7 +1282,7 @@
{
out_AbsByte(0xE9);
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
{ out_AbsByte(0xE9); }
@@ -1300,7 +1300,7 @@
{
out_AbsByte(0x0A|(2<<4));
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
{ out_AbsByte(0x0A|(2<<4)); }
@@ -1312,7 +1312,7 @@
{
out_AbsByte(0x0A|(3<<4));
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
{ out_AbsByte(0x0A|(3<<4)); }
--- a/src/asm/main.c
+++ b/src/asm/main.c
@@ -226,9 +226,9 @@
void
verror(const char *fmt, va_list args)
{
- fprintf(stderr, "ERROR:\t");
+ fprintf(stderr, "ERROR: ");
fstk_Dump();
- fprintf(stderr, " :\n\t");
+ fprintf(stderr, ":\n\t");
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
nErrors += 1;
@@ -251,6 +251,21 @@
verror(fmt, args);
va_end(args);
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