parent
e247e818ec
commit
179d26f06b
|
@ -2878,6 +2878,8 @@ void CheckStl::useStlAlgorithm()
|
|||
loopVar = splitTok->previous();
|
||||
if (loopVar->varId() == 0)
|
||||
continue;
|
||||
if (Token::simpleMatch(splitTok->astOperand2(), "{"))
|
||||
continue;
|
||||
}
|
||||
else { // iterator-based loop?
|
||||
const Token* initTok = getInitTok(tok);
|
||||
|
|
|
@ -5437,6 +5437,13 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:2]: (style) Consider using std::any_of algorithm instead of a raw loop.\n",
|
||||
errout.str());
|
||||
|
||||
check("void f() {\n" // #12064
|
||||
" for (const auto& animal : { \"cat\", \"bat\", \"tiger\", \"rat\" })\n"
|
||||
" if (std::strlen(animal) > 4)\n"
|
||||
" throw 1;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void loopAlgoMinMax() {
|
||||
|
|
Loading…
Reference in New Issue