mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:17:34 +00:00
Everywhere: Switch from (void) to [[maybe_unused]] (#4473)
Problem: - `(void)` simply casts the expression to void. This is understood to indicate that it is ignored, but this is really a compiler trick to get the compiler to not generate a warning. Solution: - Use the `[[maybe_unused]]` attribute to indicate the value is unused. Note: - Functions taking a `(void)` argument list have also been changed to `()` because this is not needed and shows up in the same grep command.
This commit is contained in:
parent
4421d98e30
commit
765936ebae
103 changed files with 219 additions and 362 deletions
|
@ -264,35 +264,35 @@ TEST_CASE(negative_incr)
|
|||
TEST_CASE(negative_cmp)
|
||||
{
|
||||
BareNumeric a = 12;
|
||||
(void)(a < a);
|
||||
[[maybe_unused]] auto res = (a < a);
|
||||
// error: static assertion failed: 'a<b' is only available for DistinctNumeric types with 'Cmp'.
|
||||
}
|
||||
|
||||
TEST_CASE(negative_bool)
|
||||
{
|
||||
BareNumeric a = 12;
|
||||
(void)!a;
|
||||
[[maybe_unused]] auto res = !a;
|
||||
// error: static assertion failed: '!a', 'a&&b', 'a||b' and similar operators are only available for DistinctNumeric types with 'Bool'.
|
||||
}
|
||||
|
||||
TEST_CASE(negative_flags)
|
||||
{
|
||||
BareNumeric a = 12;
|
||||
(void)(a & a);
|
||||
[[maybe_unused]] auto res = (a & a);
|
||||
// error: static assertion failed: 'a&b' is only available for DistinctNumeric types with 'Flags'.
|
||||
}
|
||||
|
||||
TEST_CASE(negative_shift)
|
||||
{
|
||||
BareNumeric a = 12;
|
||||
(void)(a << a);
|
||||
[[maybe_unused]] auto res = (a << a);
|
||||
// error: static assertion failed: 'a<<b' is only available for DistinctNumeric types with 'Shift'.
|
||||
}
|
||||
|
||||
TEST_CASE(negative_arith)
|
||||
{
|
||||
BareNumeric a = 12;
|
||||
(void)(a + a);
|
||||
[[maybe_unused]] auto res = (a + a);
|
||||
// error: static assertion failed: 'a+b' is only available for DistinctNumeric types with 'Arith'.
|
||||
}
|
||||
|
||||
|
@ -302,13 +302,13 @@ TEST_CASE(negative_incompatible)
|
|||
ArithNumeric b = 345;
|
||||
// And this is the entire point of `DistinctNumeric`:
|
||||
// Theoretically, the operation *could* be supported, but we declared those int types incompatible.
|
||||
(void)(a + b);
|
||||
[[maybe_unused]] auto res = (a + b);
|
||||
// error: no match for ‘operator+’ (operand types are ‘GeneralNumeric’ {aka ‘AK::DistinctNumeric<int, true, true, true, true, true, true, 64, 64>’} and ‘ArithNumeric’ {aka ‘AK::DistinctNumeric<int, false, false, false, false, false, true, 64, 63>’})
|
||||
// 313 | (void)(a + b);
|
||||
// | ~ ^ ~
|
||||
// | | |
|
||||
// | | DistinctNumeric<[...],false,false,false,false,false,[...],[...],63>
|
||||
// | DistinctNumeric<[...],true,true,true,true,true,[...],[...],64>
|
||||
// 313 | [[maybe_unused]] auto res = (a + b);
|
||||
// | ~ ^ ~
|
||||
// | | |
|
||||
// | | DistinctNumeric<[...],false,false,false,false,false,[...],[...],63>
|
||||
// | DistinctNumeric<[...],true,true,true,true,true,[...],[...],64>
|
||||
}
|
||||
#endif /* COMPILE_NEGATIVE_TESTS */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue