-Weffectless-statement now also triggers on effectless incrementors in for-loops, if an incrementor was specified

This commit is contained in:
Wolfgang (Blub) Bumiller 2012-08-23 20:54:24 +02:00
parent 3f1cad18af
commit cb604603ca

View file

@ -1622,6 +1622,13 @@ static bool parser_parse_for(parser_t *parser, ast_block *block, ast_expression
increment = parser_expression_leave(parser, false); increment = parser_expression_leave(parser, false);
if (!increment) if (!increment)
goto onerr; goto onerr;
if (!ast_istype(increment, ast_store) &&
!ast_istype(increment, ast_call) &&
!ast_istype(increment, ast_binstore))
{
if (parsewarning(parser, WARN_EFFECTLESS_STATEMENT, "statement has no effect"))
goto onerr;
}
} }
/* closing paren */ /* closing paren */