mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 10:42:07 +00:00
Implement -Wtruncation=level (#931)
* Implement -Wtruncation=level -Wtruncation=0 is the same as the current -Wno-truncation. -Wtruncation=2 is the same as the current -Wtruncation. -Wtruncation=1 is the new default; it's less strict, allowing N-bit values to be between -2**N and 2**N (exclusive). * Implement generic "parametrized warning" system * Test more `Wtruncation` variants Co-authored-by: ISSOtm <eldredhabert0@gmail.com>
This commit is contained in:
@@ -284,8 +284,10 @@ void rpn_CheckNBit(struct Expression const *expr, uint8_t n)
|
||||
if (rpn_isKnown(expr)) {
|
||||
int32_t val = expr->val;
|
||||
|
||||
if (val < -(1 << (n - 1)) || val >= 1 << n)
|
||||
warning(WARNING_TRUNCATION, "Expression must be %u-bit\n", n);
|
||||
if (val <= -(1 << n) || val >= 1 << n)
|
||||
warning(WARNING_TRUNCATION_1, "Expression must be %u-bit\n", n);
|
||||
else if (val < -(1 << (n - 1)))
|
||||
warning(WARNING_TRUNCATION_2, "Expression must be %u-bit\n", n);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user