diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 315ecb4ae..90e374c26 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -3675,6 +3675,11 @@ static void setValueType(Token *tok, const ValueType &valuetype) if (!parent->astOperand1() || !parent->astOperand1()->valueType()) return; + if (Token::Match(parent, "<<|>>")) { + setValueType(parent,valuetype); + return; + } + if (parent->str() == "[" && valuetype.pointer > 0U) { ValueType vt(valuetype); vt.pointer -= 1U; diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 0bbe94a5a..fdd89b854 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -3061,6 +3061,10 @@ private: ASSERT_EQUALS("long double *", typeOf("long double x; dostuff(&x,1);", "& x ,")); ASSERT_EQUALS("int", typeOf("struct X {int i;}; void f(struct X x) { x.i }", ".")); + // shift => result has same type as lhs + ASSERT_EQUALS("int", typeOf("int x; a = x << 1U;", "<<")); + ASSERT_EQUALS("int", typeOf("int x; a = x >> 1U;", ">>")); + // array.. ASSERT_EQUALS("void * *", typeOf("void * x[10]; a = x + 0;", "+")); ASSERT_EQUALS("int *", typeOf("int x[10]; a = x + 1;", "+"));