mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Add warnings for empty elements in lists of consts
Even though this behaviour is documented (empty elements are treated as 0), it can be misleading. By having a warning, compatibility is maintained and potential problems in the code can be detected. Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
This commit is contained in:
@@ -982,33 +982,50 @@ const_3bit : const
|
||||
}
|
||||
;
|
||||
|
||||
constlist_8bit : constlist_8bit_entry
|
||||
| constlist_8bit_entry ',' constlist_8bit
|
||||
constlist_8bit : constlist_8bit_entry
|
||||
| constlist_8bit_entry ',' constlist_8bit
|
||||
;
|
||||
|
||||
constlist_8bit_entry : { out_Skip( 1 ); }
|
||||
| const_8bit { out_RelByte( &$1 ); }
|
||||
| string { char *s; int length; s = $1; length = charmap_Convert(&s); out_AbsByteGroup(s, length); free(s); }
|
||||
constlist_8bit_entry : /* empty */ {
|
||||
out_Skip( 1 );
|
||||
if( nPass==1 )
|
||||
warning("Empty entry in list of 8-bit elements (treated as 0).");
|
||||
} | const_8bit {
|
||||
out_RelByte( &$1 );
|
||||
} | string {
|
||||
char *s = $1;
|
||||
int length = charmap_Convert(&s);
|
||||
out_AbsByteGroup(s, length);
|
||||
free(s);
|
||||
}
|
||||
;
|
||||
|
||||
constlist_16bit : constlist_16bit_entry
|
||||
| constlist_16bit_entry ',' constlist_16bit
|
||||
constlist_16bit : constlist_16bit_entry
|
||||
| constlist_16bit_entry ',' constlist_16bit
|
||||
;
|
||||
|
||||
constlist_16bit_entry : { out_Skip( 2 ); }
|
||||
| const_16bit { out_RelWord( &$1 ); }
|
||||
constlist_16bit_entry : /* empty */ {
|
||||
out_Skip( 2 );
|
||||
if( nPass==1 )
|
||||
warning("Empty entry in list of 16-bit elements (treated as 0).");
|
||||
} | const_16bit {
|
||||
out_RelWord( &$1 );
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
constlist_32bit : constlist_32bit_entry
|
||||
| constlist_32bit_entry ',' constlist_32bit
|
||||
constlist_32bit : constlist_32bit_entry
|
||||
| constlist_32bit_entry ',' constlist_32bit
|
||||
;
|
||||
|
||||
constlist_32bit_entry : { out_Skip( 4 ); }
|
||||
| relocconst { out_RelLong( &$1 ); }
|
||||
constlist_32bit_entry : /* empty */ {
|
||||
out_Skip( 4 );
|
||||
if( nPass==1 )
|
||||
warning("Empty entry in list of 32-bit elements (treated as 0).");
|
||||
} | relocconst {
|
||||
out_RelLong( &$1 );
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
const_PCrel : relocconst
|
||||
{
|
||||
$$ = $1;
|
||||
|
||||
Reference in New Issue
Block a user