make result of <<|>> an xvalue (#2775)
This commit is contained in:
parent
7d51baa2f0
commit
9712c136bd
|
@ -5355,12 +5355,15 @@ void SymbolDatabase::setValueType(Token *tok, const ValueType &valuetype)
|
||||||
|
|
||||||
if (vt1 && Token::Match(parent, "<<|>>")) {
|
if (vt1 && Token::Match(parent, "<<|>>")) {
|
||||||
if (!mIsCpp || (vt2 && vt2->isIntegral())) {
|
if (!mIsCpp || (vt2 && vt2->isIntegral())) {
|
||||||
if (vt1->type < ValueType::Type::BOOL || vt1->type >= ValueType::Type::INT)
|
if (vt1->type < ValueType::Type::BOOL || vt1->type >= ValueType::Type::INT) {
|
||||||
setValueType(parent, *vt1);
|
ValueType vt(*vt1);
|
||||||
else {
|
vt.reference = Reference::None;
|
||||||
|
setValueType(parent, vt);
|
||||||
|
} else {
|
||||||
ValueType vt(*vt1);
|
ValueType vt(*vt1);
|
||||||
vt.type = ValueType::Type::INT; // Integer promotion
|
vt.type = ValueType::Type::INT; // Integer promotion
|
||||||
vt.sign = ValueType::Sign::SIGNED;
|
vt.sign = ValueType::Sign::SIGNED;
|
||||||
|
vt.reference = Reference::None;
|
||||||
setValueType(parent, vt);
|
setValueType(parent, vt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6814,6 +6814,7 @@ private:
|
||||||
ASSERT_EQUALS("A::BC *", typeOf("namespace A { struct BC { int b; int c; }; }; struct A::BC abc; x=&abc;", "&"));
|
ASSERT_EQUALS("A::BC *", typeOf("namespace A { struct BC { int b; int c; }; }; struct A::BC abc; x=&abc;", "&"));
|
||||||
ASSERT_EQUALS("A::BC *", typeOf("namespace A { struct BC { int b; int c; }; }; struct A::BC *abc; x=abc+1;", "+"));
|
ASSERT_EQUALS("A::BC *", typeOf("namespace A { struct BC { int b; int c; }; }; struct A::BC *abc; x=abc+1;", "+"));
|
||||||
ASSERT_EQUALS("signed int", typeOf("auto a(int& x, int& y) { return x + y; }", "+"));
|
ASSERT_EQUALS("signed int", typeOf("auto a(int& x, int& y) { return x + y; }", "+"));
|
||||||
|
ASSERT_EQUALS("signed int", typeOf("auto a(int& x) { return x << 1; }", "<<"));
|
||||||
ASSERT_EQUALS("signed int", typeOf("void a(int& x, int& y) { x = y; }", "=")); //Debatably this should be a signed int & but we'll stick with the current behavior for now
|
ASSERT_EQUALS("signed int", typeOf("void a(int& x, int& y) { x = y; }", "=")); //Debatably this should be a signed int & but we'll stick with the current behavior for now
|
||||||
ASSERT_EQUALS("signed int", typeOf("auto a(int* y) { return *y; }", "*")); //Debatably this should be a signed int & but we'll stick with the current behavior for now
|
ASSERT_EQUALS("signed int", typeOf("auto a(int* y) { return *y; }", "*")); //Debatably this should be a signed int & but we'll stick with the current behavior for now
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue