mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
@@ -10,6 +10,7 @@
|
|||||||
#define RGBDS_SECTION_H
|
#define RGBDS_SECTION_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "linkdefs.h"
|
#include "linkdefs.h"
|
||||||
|
|
||||||
@@ -48,7 +49,7 @@ void sect_AlignPC(uint8_t alignment, uint16_t offset);
|
|||||||
|
|
||||||
void out_AbsByte(uint8_t b);
|
void out_AbsByte(uint8_t b);
|
||||||
void out_AbsByteGroup(uint8_t const *s, int32_t length);
|
void out_AbsByteGroup(uint8_t const *s, int32_t length);
|
||||||
void out_Skip(int32_t skip);
|
void out_Skip(int32_t skip, bool ds);
|
||||||
void out_String(char const *s);
|
void out_String(char const *s);
|
||||||
void out_RelByte(struct Expression *expr);
|
void out_RelByte(struct Expression *expr);
|
||||||
void out_RelBytes(struct Expression *expr, uint32_t n);
|
void out_RelBytes(struct Expression *expr, uint32_t n);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ enum WarningID {
|
|||||||
WARNING_ASSERT,
|
WARNING_ASSERT,
|
||||||
WARNING_BUILTIN_ARG,
|
WARNING_BUILTIN_ARG,
|
||||||
WARNING_DIV,
|
WARNING_DIV,
|
||||||
|
WARNING_EMPTY_DATA_DIRECTIVE,
|
||||||
WARNING_EMPTY_ENTRY,
|
WARNING_EMPTY_ENTRY,
|
||||||
WARNING_LARGE_CONSTANT,
|
WARNING_LARGE_CONSTANT,
|
||||||
WARNING_LONG_STR,
|
WARNING_LONG_STR,
|
||||||
|
|||||||
@@ -995,7 +995,7 @@ endu : T_POP_ENDU {
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
ds : T_POP_DS uconst { out_Skip($2); }
|
ds : T_POP_DS uconst { out_Skip($2, true); }
|
||||||
| T_POP_DS uconst ',' reloc_8bit {
|
| T_POP_DS uconst ',' reloc_8bit {
|
||||||
out_RelBytes(&$4, $2);
|
out_RelBytes(&$4, $2);
|
||||||
}
|
}
|
||||||
@@ -1189,7 +1189,7 @@ constlist_8bit : constlist_8bit_entry
|
|||||||
;
|
;
|
||||||
|
|
||||||
constlist_8bit_entry : /* empty */ {
|
constlist_8bit_entry : /* empty */ {
|
||||||
out_Skip(1);
|
out_Skip(1, false);
|
||||||
nListCountEmpty++;
|
nListCountEmpty++;
|
||||||
}
|
}
|
||||||
| reloc_8bit_no_str { out_RelByte(&$1); }
|
| reloc_8bit_no_str { out_RelByte(&$1); }
|
||||||
@@ -1207,7 +1207,7 @@ constlist_16bit : constlist_16bit_entry
|
|||||||
;
|
;
|
||||||
|
|
||||||
constlist_16bit_entry : /* empty */ {
|
constlist_16bit_entry : /* empty */ {
|
||||||
out_Skip(2);
|
out_Skip(2, false);
|
||||||
nListCountEmpty++;
|
nListCountEmpty++;
|
||||||
}
|
}
|
||||||
| reloc_16bit { out_RelWord(&$1); }
|
| reloc_16bit { out_RelWord(&$1); }
|
||||||
@@ -1218,7 +1218,7 @@ constlist_32bit : constlist_32bit_entry
|
|||||||
;
|
;
|
||||||
|
|
||||||
constlist_32bit_entry : /* empty */ {
|
constlist_32bit_entry : /* empty */ {
|
||||||
out_Skip(4);
|
out_Skip(4, false);
|
||||||
nListCountEmpty++;
|
nListCountEmpty++;
|
||||||
}
|
}
|
||||||
| relocexpr { out_RelLong(&$1); }
|
| relocexpr { out_RelLong(&$1); }
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "asm/fstack.h"
|
#include "asm/fstack.h"
|
||||||
#include "asm/main.h"
|
#include "asm/main.h"
|
||||||
@@ -434,11 +435,14 @@ void out_AbsByteGroup(uint8_t const *s, int32_t length)
|
|||||||
/*
|
/*
|
||||||
* Skip this many bytes
|
* Skip this many bytes
|
||||||
*/
|
*/
|
||||||
void out_Skip(int32_t skip)
|
void out_Skip(int32_t skip, bool ds)
|
||||||
{
|
{
|
||||||
checksection();
|
checksection();
|
||||||
reserveSpace(skip);
|
reserveSpace(skip);
|
||||||
|
|
||||||
|
if (!ds && sect_HasData(pCurrentSection->nType))
|
||||||
|
warning(WARNING_EMPTY_DATA_DIRECTIVE, "db/dw/dl directive without data in ROM");
|
||||||
|
|
||||||
if (!sect_HasData(pCurrentSection->nType)) {
|
if (!sect_HasData(pCurrentSection->nType)) {
|
||||||
growSection(skip);
|
growSection(skip);
|
||||||
} else if (nUnionDepth > 0) {
|
} else if (nUnionDepth > 0) {
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ static enum WarningState const defaultWarnings[NB_WARNINGS] = {
|
|||||||
WARNING_ENABLED, /* Assertions */
|
WARNING_ENABLED, /* Assertions */
|
||||||
WARNING_DISABLED, /* Invalid args to builtins */
|
WARNING_DISABLED, /* Invalid args to builtins */
|
||||||
WARNING_DISABLED, /* Division undefined behavior */
|
WARNING_DISABLED, /* Division undefined behavior */
|
||||||
|
WARNING_DISABLED, /* `db`, `dw`, or `dl` with no directive in ROM */
|
||||||
WARNING_DISABLED, /* Empty entry in `db`, `dw` or `dl` */
|
WARNING_DISABLED, /* Empty entry in `db`, `dw` or `dl` */
|
||||||
WARNING_DISABLED, /* Constants too large */
|
WARNING_DISABLED, /* Constants too large */
|
||||||
WARNING_DISABLED, /* String too long for internal buffers */
|
WARNING_DISABLED, /* String too long for internal buffers */
|
||||||
@@ -68,6 +69,7 @@ static char const *warningFlags[NB_WARNINGS_ALL] = {
|
|||||||
"assert",
|
"assert",
|
||||||
"builtin-args",
|
"builtin-args",
|
||||||
"div",
|
"div",
|
||||||
|
"empty-data-directive",
|
||||||
"empty-entry",
|
"empty-entry",
|
||||||
"large-constant",
|
"large-constant",
|
||||||
"long-string",
|
"long-string",
|
||||||
@@ -90,6 +92,7 @@ enum MetaWarningCommand {
|
|||||||
/* Warnings that probably indicate an error */
|
/* Warnings that probably indicate an error */
|
||||||
static uint8_t const _wallCommands[] = {
|
static uint8_t const _wallCommands[] = {
|
||||||
WARNING_BUILTIN_ARG,
|
WARNING_BUILTIN_ARG,
|
||||||
|
WARNING_EMPTY_DATA_DIRECTIVE,
|
||||||
WARNING_LARGE_CONSTANT,
|
WARNING_LARGE_CONSTANT,
|
||||||
WARNING_LONG_STR,
|
WARNING_LONG_STR,
|
||||||
META_WARNING_DONE
|
META_WARNING_DONE
|
||||||
@@ -106,6 +109,7 @@ static uint8_t const _wextraCommands[] = {
|
|||||||
static uint8_t const _weverythingCommands[] = {
|
static uint8_t const _weverythingCommands[] = {
|
||||||
WARNING_BUILTIN_ARG,
|
WARNING_BUILTIN_ARG,
|
||||||
WARNING_DIV,
|
WARNING_DIV,
|
||||||
|
WARNING_EMPTY_DATA_DIRECTIVE,
|
||||||
WARNING_EMPTY_ENTRY,
|
WARNING_EMPTY_ENTRY,
|
||||||
WARNING_LARGE_CONSTANT,
|
WARNING_LARGE_CONSTANT,
|
||||||
WARNING_LONG_STR,
|
WARNING_LONG_STR,
|
||||||
|
|||||||
16
test/asm/empty-data-directive.asm
Normal file
16
test/asm/empty-data-directive.asm
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
SECTION "Empty Data Directive in ROM", ROM0
|
||||||
|
ds 1
|
||||||
|
ds 2
|
||||||
|
ds 3
|
||||||
|
ds 4
|
||||||
|
db
|
||||||
|
dw
|
||||||
|
dl
|
||||||
|
SECTION "Empty Data Directive in HRAM", HRAM
|
||||||
|
ds 1
|
||||||
|
ds 2
|
||||||
|
ds 3
|
||||||
|
ds 4
|
||||||
|
db
|
||||||
|
dw
|
||||||
|
dl
|
||||||
6
test/asm/empty-data-directive.err
Normal file
6
test/asm/empty-data-directive.err
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
warning: empty-data-directive.asm(6): [-Wempty-data-directive]
|
||||||
|
db/dw/dl directive without data in ROM
|
||||||
|
warning: empty-data-directive.asm(7): [-Wempty-data-directive]
|
||||||
|
db/dw/dl directive without data in ROM
|
||||||
|
warning: empty-data-directive.asm(8): [-Wempty-data-directive]
|
||||||
|
db/dw/dl directive without data in ROM
|
||||||
0
test/asm/empty-data-directive.out
Normal file
0
test/asm/empty-data-directive.out
Normal file
Reference in New Issue
Block a user