Fix #11510 FP CastIntegerToAddressAtReturn with ternary operator (#4732)

This commit is contained in:
chrchr-github 2023-01-26 22:09:55 +01:00 committed by GitHub
parent e5572835c0
commit 3a8d9b8c87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -6419,12 +6419,18 @@ void SymbolDatabase::setValueType(Token* tok, const ValueType& valuetype, Source
} }
} else if (ternary) { } else if (ternary) {
if (vt1->pointer != 0U && vt2 && vt2->pointer == 0U) { if (vt1->pointer != 0U && vt2 && vt2->pointer == 0U) {
setValueType(parent, *vt2); if (vt2->isPrimitive())
setValueType(parent, *vt1);
else
setValueType(parent, *vt2);
return; return;
} }
if (vt1->pointer == 0U && vt2 && vt2->pointer != 0U) { if (vt1->pointer == 0U && vt2 && vt2->pointer != 0U) {
setValueType(parent, *vt1); if (vt1->isPrimitive())
setValueType(parent, *vt2);
else
setValueType(parent, *vt1);
return; return;
} }
} }

View File

@ -152,6 +152,11 @@ private:
" std::array<double, 1> a = S::g(S::E::E0);\n" " std::array<double, 1> a = S::g(S::E::E0);\n"
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
check("char* f(char* p) {\n"
" return p ? p : 0;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
} }
void structmember() { void structmember() {