Fixed #7376 (ValueType: wrong type for container element)
This commit is contained in:
parent
37afc57a2a
commit
397480f929
|
@ -4149,7 +4149,7 @@ static void setValueType(Token *tok, const ValueType &valuetype, bool cpp, Value
|
|||
return;
|
||||
}
|
||||
|
||||
if (parent->str() == "[" && valuetype.pointer > 0U) {
|
||||
if (parent->str() == "[" && (!cpp || parent->astOperand1() == tok) && valuetype.pointer > 0U) {
|
||||
ValueType vt(valuetype);
|
||||
vt.pointer -= 1U;
|
||||
setValueType(parent, vt, cpp, defaultSignedness, lib);
|
||||
|
|
|
@ -3330,6 +3330,8 @@ private:
|
|||
ASSERT_EQUALS("void * *", typeOf("void * x[10]; a = x + 0;", "+"));
|
||||
ASSERT_EQUALS("signed int *", typeOf("int x[10]; a = x + 1;", "+"));
|
||||
ASSERT_EQUALS("signed int", typeOf("int x[10]; a = x[0] + 1;", "+"));
|
||||
ASSERT_EQUALS("", typeOf("a = x[\"hello\"];", "[", "test.cpp"));
|
||||
ASSERT_EQUALS("const char", typeOf("a = x[\"hello\"];", "[", "test.c"));
|
||||
|
||||
// cast..
|
||||
ASSERT_EQUALS("void *", typeOf("a = (void *)0;", "("));
|
||||
|
|
Loading…
Reference in New Issue