Fixed crash on range-based for-loop

This commit is contained in:
PKEuS 2015-01-03 22:36:39 +01:00
parent 7ece58c3a0
commit 11fa185cae
2 changed files with 8 additions and 0 deletions

View File

@ -313,6 +313,9 @@ void CheckStl::stlOutOfBounds()
tok = tok->linkAt(1)->tokAt(2);
} else
tok = tok->next();
if (!tok)
continue;
tok = tok->next();
// check if the for loop condition is wrong

View File

@ -577,6 +577,11 @@ private:
" foo[ii] = 0;\n"
"}");
ASSERT_EQUALS("", errout.str());
check("void foo() {\n"
" for (B b : D()) {}\n" // Don't crash on range-based for-loop
"}");
ASSERT_EQUALS("", errout.str());
}
void STLSizeNoErr() {