diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 39f18b904..713f979b9 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -6419,12 +6419,18 @@ void SymbolDatabase::setValueType(Token* tok, const ValueType& valuetype, Source } } else if (ternary) { if (vt1->pointer != 0U && vt2 && vt2->pointer == 0U) { - setValueType(parent, *vt2); + if (vt2->isPrimitive()) + setValueType(parent, *vt1); + else + setValueType(parent, *vt2); return; } if (vt1->pointer == 0U && vt2 && vt2->pointer != 0U) { - setValueType(parent, *vt1); + if (vt1->isPrimitive()) + setValueType(parent, *vt2); + else + setValueType(parent, *vt1); return; } } diff --git a/test/test64bit.cpp b/test/test64bit.cpp index c6d560259..bd754967b 100644 --- a/test/test64bit.cpp +++ b/test/test64bit.cpp @@ -152,6 +152,11 @@ private: " std::array a = S::g(S::E::E0);\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + check("char* f(char* p) {\n" + " return p ? p : 0;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void structmember() {