Merge pull request #14201 from ethereum/fix-hidden-overload-warning-in-types

Fix hidden-overload in Types and remove CMake hacks
This commit is contained in:
Daniel 2023-05-09 20:47:26 +02:00 committed by GitHub
commit a02a7206d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 17 deletions

View File

@ -65,16 +65,10 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
if(WEXTRA_SEMI)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wextra-semi>)
endif()
# TODO: This is a temporary workaround. The underlying warning should be addressed and this workaround removed ASAP.
check_cxx_compiler_flag(-Wno-error=overloaded-virtual=1 WNO_ERROR_OVERLOADED_VIRTUAL)
if (WNO_ERROR_OVERLOADED_VIRTUAL)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-error=overloaded-virtual=1>)
endif()
# TODO: This is a temporary workaround. The underlying warning should be addressed and this workaround removed ASAP.
# Once https://github.com/fmtlib/fmt/issues/3415 is addressed, this can be fixed by bumping the fmtlib version.
check_cxx_compiler_flag(-Wno-error=dangling-reference WNO_ERROR_DANGLING_REFERENCE)
if (WNO_ERROR_DANGLING_REFERENCE)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-error=dangling-reference>)
# See https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=6b927b1297e66e26e62e722bf15c921dcbbd25b9
check_cxx_compiler_flag(-Wno-dangling-reference WNO_DANGLING_REFERENCE)
if (WNO_DANGLING_REFERENCE)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-dangling-reference>)
endif()

View File

@ -1694,7 +1694,7 @@ bool ArrayType::operator==(Type const& _other) const
return false;
ArrayType const& other = dynamic_cast<ArrayType const&>(_other);
if (
!ReferenceType::operator==(other) ||
!equals(other) ||
other.isByteArray() != isByteArray() ||
other.isString() != isString() ||
other.isDynamicallySized() != isDynamicallySized()
@ -2204,7 +2204,7 @@ bool StructType::operator==(Type const& _other) const
if (_other.category() != category())
return false;
StructType const& other = dynamic_cast<StructType const&>(_other);
return ReferenceType::operator==(other) && other.m_struct == m_struct;
return equals(other) && other.m_struct == m_struct;
}

View File

@ -803,7 +803,7 @@ public:
/// if the type has an interfaceType.
virtual BoolResult validForLocation(DataLocation _loc) const = 0;
bool operator==(ReferenceType const& _other) const
bool equals(ReferenceType const& _other) const
{
return location() == _other.location() && isPointer() == _other.isPointer();
}

View File

@ -1833,7 +1833,7 @@ string YulUtilFunctions::clearStorageStructFunction(StructType const& _type)
string YulUtilFunctions::copyArrayToStorageFunction(ArrayType const& _fromType, ArrayType const& _toType)
{
solAssert(
*_fromType.copyForLocation(_toType.location(), _toType.isPointer()) == dynamic_cast<ReferenceType const&>(_toType),
(*_fromType.copyForLocation(_toType.location(), _toType.isPointer())).equals(dynamic_cast<ReferenceType const&>(_toType)),
""
);
if (!_toType.isDynamicallySized())
@ -1930,7 +1930,7 @@ string YulUtilFunctions::copyArrayToStorageFunction(ArrayType const& _fromType,
string YulUtilFunctions::copyByteArrayToStorageFunction(ArrayType const& _fromType, ArrayType const& _toType)
{
solAssert(
*_fromType.copyForLocation(_toType.location(), _toType.isPointer()) == dynamic_cast<ReferenceType const&>(_toType),
(*_fromType.copyForLocation(_toType.location(), _toType.isPointer())).equals(dynamic_cast<ReferenceType const&>(_toType)),
""
);
solAssert(_fromType.isByteArrayOrString(), "");
@ -2840,10 +2840,10 @@ string YulUtilFunctions::updateStorageValueFunction(
.render();
}
solAssert(*toReferenceType->copyForLocation(
solAssert((*toReferenceType->copyForLocation(
fromReferenceType->location(),
fromReferenceType->isPointer()
).get() == *fromReferenceType, "");
).get()).equals(*fromReferenceType), "");
if (fromReferenceType->category() == Type::Category::ArraySlice)
solAssert(toReferenceType->category() == Type::Category::Array, "");