forked from Mirrors/openclonk
Remove warning on assignment in while() conditions (for now)
parent
75bfef6b06
commit
704994f1b9
|
@ -1570,7 +1570,10 @@ void C4AulCompiler::CodegenAstVisitor::visit(const ::aul::ast::WhileLoop *n)
|
|||
{
|
||||
int cond = AddJumpTarget();
|
||||
PushLoop();
|
||||
WarnOnAssignment(n->cond);
|
||||
// XXX:
|
||||
// Assignments in the condition here should warn as well (like they do in
|
||||
// for and if conditions) but a ton of code uses those assignments at the
|
||||
// moment and people are divided about allowing it
|
||||
SafeVisit(n->cond);
|
||||
active_loops.top().breaks.push_back(AddBCC(n->cond->loc, AB_CONDN));
|
||||
if (SafeVisit(n->body))
|
||||
|
|
|
@ -105,15 +105,6 @@ TEST_F(AulDiagnosticsTest, suspicious_assignment)
|
|||
RunCode("for (var a = 0; a == 1;) {}");
|
||||
RunCode("for (var a = 0; a != 0;) {}");
|
||||
}
|
||||
{
|
||||
EXPECT_WARNING(suspicious_assignment);
|
||||
RunCode("var a = 0; while (a = 0) {}");
|
||||
}
|
||||
{
|
||||
EXPECT_WARNING(suspicious_assignment).Times(0);
|
||||
RunCode("var a = 0; while (a == 1) {}");
|
||||
RunCode("var a = 0; while (a *= 1) {}");
|
||||
}
|
||||
{
|
||||
EXPECT_WARNING(suspicious_assignment);
|
||||
RunCode("var a = 0; return a = 0;");
|
||||
|
|
Loading…
Reference in New Issue