mirror of
https://github.com/gbdev/rgbds.git
synced 2026-11-22 05:48:39 +00:00
Non-constant expressions do not fail a static_assert (#2215)
This commit is contained in:
1 parent
ddd4ba9952
commit
586bd2eec8
8 files changed
+11
-20
No files matched your search
+3
-2
@@ -132,8 +132,9 @@ void act_Assert(AssertionType type, Expression const &expr, std::string const &m
|
||||
}
|
||||
}
|
||||
|
||||
void act_StaticAssert(AssertionType type, int32_t condition, std::string const &message) {
|
||||
if (!condition) {
|
||||
void act_StaticAssert(AssertionType type, Expression const &expr, std::string const &message) {
|
||||
// If `expr` is not a known constant, `expr.getConstVal()` will print its own error.
|
||||
if (int32_t condition = expr.getConstVal(); expr.isKnown() && !condition) {
|
||||
failAssert(type, message);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -761,10 +761,10 @@ assert:
|
||||
| POP_ASSERT assert_type relocexpr COMMA string {
|
||||
act_Assert($2, $3, $5);
|
||||
}
|
||||
| POP_STATIC_ASSERT assert_type iconst {
|
||||
| POP_STATIC_ASSERT assert_type relocexpr {
|
||||
act_StaticAssert($2, $3, "");
|
||||
}
|
||||
| POP_STATIC_ASSERT assert_type iconst COMMA string {
|
||||
| POP_STATIC_ASSERT assert_type relocexpr COMMA string {
|
||||
act_StaticAssert($2, $3, $5);
|
||||
}
|
||||
;
|
||||
|
||||
Reference in new issue
Block a user