Fix array typecasting.

Since a C/C++ array is essentially pointer math, the derived type
needs to take this into account, otherwise the array indices wind
up being based off the address of the variable itself rather than
the array it points to.
This commit is contained in:
Rene Gollent 2013-04-14 10:50:22 -04:00
parent d12519423f
commit 3fe982232b

View File

@ -111,7 +111,6 @@ CppLanguage::ParseTypeExpression(const BString &expression,
_resultType = baseType;
#if 0
if (!arraySpecifier.IsEmpty()) {
ArrayType* arrayType = NULL;
@ -139,9 +138,18 @@ CppLanguage::ParseTypeExpression(const BString &expression,
} while (startIndex >= 0);
_resultType = arrayType;
// since a C/C++ array is essentially pointer math,
// the resulting array has to be wrapped in a pointer to
// ensure the element addresses wind up being against the
// correct address.
AddressType* addressType = NULL;
result = arrayType->CreateDerivedAddressType(DERIVED_TYPE_POINTER,
addressType);
if (result != B_OK)
return result;
_resultType = addressType;
}
#endif
typeRef.Detach();