Fix FP functionConst with extra parentheses (#3722)

This commit is contained in:
chrchr-github 2022-01-18 20:21:25 +01:00 committed by GitHub
parent cb5a50c6a7
commit ca2e0ca287
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -2135,6 +2135,8 @@ bool CheckClass::checkConstFunc(const Scope *scope, const Function *func, bool&
return false;
const Token* lhs = tok1->previous();
if (lhs->str() == "(" && tok1->astParent() && tok1->astParent()->astParent())
lhs = tok1->astParent()->astParent();
if (lhs->str() == "&") {
lhs = lhs->previous();
if (lhs->isAssignmentOp() && lhs->previous()->variable()) {

View File

@ -445,7 +445,7 @@ private:
"};");
ASSERT_EQUALS("[test.cpp:1]: (style) Struct 'A' has a constructor with 1 argument that is not explicit.\n", errout.str());
checkExplicitConstructors("struct Foo {\n"
checkExplicitConstructors("struct Foo {\n" // #10515
" template <typename T>\n"
" explicit constexpr Foo(T) {}\n"
"};\n"
@ -5797,6 +5797,14 @@ private:
" void g() { bar.f(k); }\n"
"};\n");
ASSERT_EQUALS("", errout.str());
checkConst("struct S {\n"
" A a;\n"
" void f(int j, int*& p) {\n"
" p = &(((a[j])));\n"
" }\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
void const_handleDefaultParameters() {