ValueType: Handle function pointers

This commit is contained in:
Daniel Marjamäki 2016-12-04 16:02:50 +01:00
parent abf59af87d
commit c12cb69cc2
2 changed files with 7 additions and 0 deletions

View File

@ -4297,6 +4297,12 @@ static void setValueType(Token *tok, const ValueType &valuetype, bool cpp, Value
setValueType(parent, vt, cpp, defaultSignedness, settings);
return;
}
if (Token::Match(parent->previous(), "%name% (") && parent->astOperand1() == tok && valuetype.pointer > 0U) {
ValueType vt(valuetype);
vt.pointer -= 1U;
setValueType(parent, vt, cpp, defaultSignedness, settings);
return;
}
if (parent->str() == "*" && !parent->astOperand2() && valuetype.pointer > 0U) {
ValueType vt(valuetype);
vt.pointer -= 1U;

View File

@ -4016,6 +4016,7 @@ private:
ASSERT_EQUALS("signed int", typeOf("int a(int); a(5);", "( 5"));
ASSERT_EQUALS("signed int", typeOf("auto a(int) -> int; a(5);", "( 5"));
ASSERT_EQUALS("unsigned long", typeOf("sizeof(x);", "("));
ASSERT_EQUALS("signed int", typeOf("int (*a)(int); a(5);", "( 5"));
// struct member..
ASSERT_EQUALS("signed int", typeOf("struct AB { int a; int b; } ab; x = ab.a;", "."));