mirror of
https://github.com/gbdev/rgbds.git
synced 2026-10-06 04:05:38 +00:00
Add -Wsingle-union warning for UNION without NEXTU (#2170)
This commit is contained in:
1 parent
62a9d8d518
commit
ba4e58f4e0
11 files changed
+22
-3
No files matched your search
+6
-1
@@ -38,6 +38,7 @@ using namespace std::literals;
|
||||
struct UnionStackEntry {
|
||||
uint32_t start;
|
||||
uint32_t size;
|
||||
bool hasNextu;
|
||||
};
|
||||
|
||||
struct SectionStackEntry {
|
||||
@@ -782,7 +783,7 @@ void sect_StartUnion() {
|
||||
return;
|
||||
}
|
||||
|
||||
currentUnionStack.push({.start = curOffset, .size = 0});
|
||||
currentUnionStack.push({.start = curOffset, .size = 0, .hasNextu = false});
|
||||
}
|
||||
|
||||
static void endUnionMember() {
|
||||
@@ -801,6 +802,7 @@ void sect_NextUnionMember() {
|
||||
return;
|
||||
}
|
||||
endUnionMember();
|
||||
currentUnionStack.top().hasNextu = true;
|
||||
}
|
||||
|
||||
void sect_EndUnion() {
|
||||
@@ -808,6 +810,9 @@ void sect_EndUnion() {
|
||||
error("Found `ENDU` outside of a `UNION` construct");
|
||||
return;
|
||||
}
|
||||
if (!currentUnionStack.top().hasNextu) {
|
||||
warning(WARNING_SINGLE_UNION, "`UNION` construct has no `NEXTU` alternatives");
|
||||
}
|
||||
endUnionMember();
|
||||
curOffset += currentUnionStack.top().size;
|
||||
currentUnionStack.pop();
|
||||
|
||||
@@ -37,6 +37,7 @@ Diagnostics<WarningLevel, WarningID> warnings = {
|
||||
{"obsolete", LEVEL_DEFAULT },
|
||||
{"shift", LEVEL_EVERYTHING},
|
||||
{"shift-amount", LEVEL_EVERYTHING},
|
||||
{"single-union", LEVEL_EVERYTHING},
|
||||
{"unmatched-directive", LEVEL_EXTRA },
|
||||
{"unterminated-load", LEVEL_EXTRA },
|
||||
{"user", LEVEL_DEFAULT },
|
||||
|
||||
Reference in new issue
Block a user