Fix #11432 FP passedByValue for overriden function (#4632)

This commit is contained in:
chrchr-github 2022-12-12 21:52:58 +01:00 committed by GitHub
parent 7aae78fed3
commit 3f5054035d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -1332,7 +1332,7 @@ void CheckOther::checkPassByReference()
}
// Check if variable could be const
if (!var->scope() || var->scope()->function->hasVirtualSpecifier())
if (!var->scope() || var->scope()->function->isImplicitlyVirtual())
continue;
if (canBeConst(var, mSettings)) {

View File

@ -1970,6 +1970,15 @@ private:
"int* f(U u) { return u.b; }\n");
ASSERT_EQUALS("", errout.str());
check("struct B { virtual int f(std::string s) = 0; };\n" // #11432
"struct D1 : B {\n"
" int f(std::string s) override { s += 'a'; return s.size(); }\n"
"}\n"
"struct D2 : B {\n"
" int f(std::string s) override { return s.size(); }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
Settings settings1;
settings1.platform(Settings::Win64);
check("using ui64 = unsigned __int64;\n"