mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
No delete on storage pointers.
This commit is contained in:
parent
ca497f5d10
commit
03edf74e62
29
Types.cpp
29
Types.cpp
@ -671,6 +671,23 @@ TypePointer ContractType::unaryOperatorResult(Token::Value _operator) const
|
||||
return _operator == Token::Delete ? make_shared<VoidType>() : TypePointer();
|
||||
}
|
||||
|
||||
TypePointer ReferenceType::unaryOperatorResult(Token::Value _operator) const
|
||||
{
|
||||
if (_operator != Token::Delete)
|
||||
return TypePointer();
|
||||
// delete can be used on everything except calldata references or storage pointers
|
||||
// (storage references are ok)
|
||||
switch (location())
|
||||
{
|
||||
case DataLocation::CallData:
|
||||
return TypePointer();
|
||||
case DataLocation::Memory:
|
||||
return make_shared<VoidType>();
|
||||
case DataLocation::Storage:
|
||||
return m_isPointer ? TypePointer() : make_shared<VoidType>();
|
||||
}
|
||||
}
|
||||
|
||||
TypePointer ReferenceType::copyForLocationIfReference(DataLocation _location, TypePointer const& _type)
|
||||
{
|
||||
if (auto type = dynamic_cast<ReferenceType const*>(_type.get()))
|
||||
@ -738,13 +755,6 @@ bool ArrayType::isImplicitlyConvertibleTo(const Type& _convertTo) const
|
||||
}
|
||||
}
|
||||
|
||||
TypePointer ArrayType::unaryOperatorResult(Token::Value _operator) const
|
||||
{
|
||||
if (_operator == Token::Delete)
|
||||
return make_shared<VoidType>();
|
||||
return TypePointer();
|
||||
}
|
||||
|
||||
bool ArrayType::operator==(Type const& _other) const
|
||||
{
|
||||
if (_other.getCategory() != getCategory())
|
||||
@ -962,11 +972,6 @@ bool StructType::isImplicitlyConvertibleTo(const Type& _convertTo) const
|
||||
return this->m_struct == convertTo.m_struct;
|
||||
}
|
||||
|
||||
TypePointer StructType::unaryOperatorResult(Token::Value _operator) const
|
||||
{
|
||||
return _operator == Token::Delete ? make_shared<VoidType>() : TypePointer();
|
||||
}
|
||||
|
||||
bool StructType::operator==(Type const& _other) const
|
||||
{
|
||||
if (_other.getCategory() != getCategory())
|
||||
|
3
Types.h
3
Types.h
@ -376,6 +376,7 @@ public:
|
||||
explicit ReferenceType(DataLocation _location): m_location(_location) {}
|
||||
DataLocation location() const { return m_location; }
|
||||
|
||||
virtual TypePointer unaryOperatorResult(Token::Value _operator) const override;
|
||||
virtual unsigned memoryHeadSize() const override { return 32; }
|
||||
|
||||
/// @returns a copy of this type with location (recursively) changed to @a _location,
|
||||
@ -444,7 +445,6 @@ public:
|
||||
{}
|
||||
|
||||
virtual bool isImplicitlyConvertibleTo(Type const& _convertTo) const override;
|
||||
virtual TypePointer unaryOperatorResult(Token::Value _operator) const override;
|
||||
virtual bool operator==(const Type& _other) const override;
|
||||
virtual unsigned getCalldataEncodedSize(bool _padded) const override;
|
||||
virtual bool isDynamicallySized() const override { return m_hasDynamicLength; }
|
||||
@ -545,7 +545,6 @@ public:
|
||||
//@todo only storage until we have non-storage structs
|
||||
ReferenceType(DataLocation::Storage), m_struct(_struct) {}
|
||||
virtual bool isImplicitlyConvertibleTo(const Type& _convertTo) const override;
|
||||
virtual TypePointer unaryOperatorResult(Token::Value _operator) const override;
|
||||
virtual bool operator==(Type const& _other) const override;
|
||||
virtual unsigned getCalldataEncodedSize(bool _padded) const override;
|
||||
virtual u256 getStorageSize() const override;
|
||||
|
Loading…
Reference in New Issue
Block a user