Fix FP constVariable with reference to std::array (#4777)

This commit is contained in:
chrchr-github 2023-02-08 08:25:43 +01:00 committed by GitHub
parent 66758d65f9
commit 271ccbc8f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -6037,7 +6037,7 @@ void SymbolDatabase::setValueType(Token* tok, const Variable& var, SourceLocatio
valuetype.setDebugPath(tok, loc);
if (var.nameToken())
valuetype.bits = var.nameToken()->bits();
valuetype.pointer = var.dimensions().size();
valuetype.pointer = (var.valueType() && var.valueType()->container) ? 0 : var.dimensions().size();
valuetype.typeScope = var.typeScope();
if (var.valueType()) {
valuetype.container = var.valueType()->container;

View File

@ -3347,6 +3347,13 @@ private:
ASSERT_EQUALS("[test.cpp:1]: (style) Parameter 'p0' can be declared as pointer to const\n"
"[test.cpp:1]: (style) Parameter 'p1' can be declared as pointer to const\n",
errout.str());
check("void f() {\n"
" std::array<int, 1> a{}, b{};\n"
" const std::array<int, 1>& r = a;\n"
" if (r == b) {}\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void switchRedundantAssignmentTest() {