Disallow initializing void * with ptr to const.
This commit is contained in:
7
expr.cpp
7
expr.cpp
@@ -339,7 +339,14 @@ lDoTypeConv(const Type *fromType, const Type *toType, Expr **expr,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (PointerType::IsVoidPointer(toPointerType)) {
|
else if (PointerType::IsVoidPointer(toPointerType)) {
|
||||||
|
if (fromPointerType->GetBaseType()->IsConstType()) {
|
||||||
|
if (!failureOk)
|
||||||
|
Error(pos, "Can't convert pointer to const \"%s\" to void pointer.",
|
||||||
|
fromPointerType->GetString().c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// any pointer type can be converted to a void *
|
// any pointer type can be converted to a void *
|
||||||
|
// ...almost. #731
|
||||||
goto typecast_ok;
|
goto typecast_ok;
|
||||||
}
|
}
|
||||||
else if (PointerType::IsVoidPointer(fromPointerType) &&
|
else if (PointerType::IsVoidPointer(fromPointerType) &&
|
||||||
|
|||||||
Reference in New Issue
Block a user