Skip to content

Commit e8c3a80

Browse files
Improve --check-library error message (#4755)
1 parent 9acc965 commit e8c3a80

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

lib/token.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2300,19 +2300,19 @@ std::pair<const Token*, const Token*> Token::typeDecl(const Token* tok, bool poi
23002300
if (vt && vt->containerTypeToken)
23012301
return { vt->containerTypeToken, vt->containerTypeToken->linkAt(-1) };
23022302
}
2303-
if (pointedToType && astIsSmartPointer(var->nameToken())) {
2304-
const ValueType* vt = var->valueType();
2305-
if (vt && vt->smartPointerTypeToken)
2306-
return { vt->smartPointerTypeToken, vt->smartPointerTypeToken->linkAt(-1) };
2307-
}
2308-
if (pointedToType && astIsIterator(var->nameToken())) {
2309-
const ValueType* vt = var->valueType();
2310-
if (vt && vt->containerTypeToken)
2311-
return { vt->containerTypeToken, vt->containerTypeToken->linkAt(-1) };
2312-
}
2313-
if (result.first)
2314-
return result;
23152303
}
2304+
if (pointedToType && astIsSmartPointer(var->nameToken())) {
2305+
const ValueType* vt = var->valueType();
2306+
if (vt && vt->smartPointerTypeToken)
2307+
return { vt->smartPointerTypeToken, vt->smartPointerTypeToken->linkAt(-1) };
2308+
}
2309+
if (pointedToType && astIsIterator(var->nameToken())) {
2310+
const ValueType* vt = var->valueType();
2311+
if (vt && vt->containerTypeToken)
2312+
return { vt->containerTypeToken, vt->containerTypeToken->linkAt(-1) };
2313+
}
2314+
if (result.first)
2315+
return result;
23162316
return {var->typeStartToken(), var->typeEndToken()->next()};
23172317
} else if (Token::simpleMatch(tok, "return")) {
23182318
const Scope* scope = tok->scope();

test/testfunctions.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,6 +1949,16 @@ class TestFunctions : public TestFixture {
19491949
"[test.cpp:5]: (information) --check-library: There is no matching configuration for function auto::push_back()\n",
19501950
errout.str());
19511951

1952+
check("struct F { void g(int); };\n"
1953+
"void f(std::list<F>& l) {\n"
1954+
" std::list<F>::iterator it;\n"
1955+
" for (it = l.begin(); it != l.end(); ++it)\n"
1956+
" it->g(0);\n"
1957+
"}\n");
1958+
TODO_ASSERT_EQUALS("",
1959+
"[test.cpp:5]: (information) --check-library: There is no matching configuration for function F::g()\n",
1960+
errout.str());
1961+
19521962
settings = settings_old;
19531963
}
19541964

0 commit comments

Comments
 (0)