mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge remote-tracking branch 'origin/develop' into breaking
This commit is contained in:
commit
561280a5cc
@ -36,7 +36,6 @@ set -e
|
|||||||
|
|
||||||
OPTIMIZE=${OPTIMIZE:-"0"}
|
OPTIMIZE=${OPTIMIZE:-"0"}
|
||||||
EVM=${EVM:-"invalid"}
|
EVM=${EVM:-"invalid"}
|
||||||
WORKDIR=${CIRCLE_WORKING_DIRECTORY:-.}
|
|
||||||
REPODIR="$(realpath $(dirname $0)/..)"
|
REPODIR="$(realpath $(dirname $0)/..)"
|
||||||
|
|
||||||
source "${REPODIR}/scripts/common.sh"
|
source "${REPODIR}/scripts/common.sh"
|
||||||
|
@ -80,6 +80,6 @@ done
|
|||||||
|
|
||||||
if (($STEP != $STEPS + 1))
|
if (($STEP != $STEPS + 1))
|
||||||
then
|
then
|
||||||
echo "Step counter not properly adjusted!" >2
|
echo "Step counter not properly adjusted!" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -55,6 +55,7 @@ Compiler Features:
|
|||||||
* SMTChecker: Support getters.
|
* SMTChecker: Support getters.
|
||||||
* SMTChecker: Support named arguments in function calls.
|
* SMTChecker: Support named arguments in function calls.
|
||||||
* SMTChecker: Support struct constructor.
|
* SMTChecker: Support struct constructor.
|
||||||
|
* SMTChecker: Create underflow and overflow verification targets for increment/decrement in the CHC engine.
|
||||||
* Standard-Json: Move the recently introduced ``modelCheckerSettings`` key to ``settings.modelChecker``.
|
* Standard-Json: Move the recently introduced ``modelCheckerSettings`` key to ``settings.modelChecker``.
|
||||||
* Standard-Json: Properly filter the requested output artifacts.
|
* Standard-Json: Properly filter the requested output artifacts.
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
|
|||||||
add_compile_options(-Wextra)
|
add_compile_options(-Wextra)
|
||||||
add_compile_options(-Werror)
|
add_compile_options(-Werror)
|
||||||
add_compile_options(-pedantic)
|
add_compile_options(-pedantic)
|
||||||
|
add_compile_options(-Wmissing-declarations)
|
||||||
add_compile_options(-Wno-unknown-pragmas)
|
add_compile_options(-Wno-unknown-pragmas)
|
||||||
add_compile_options(-Wimplicit-fallthrough)
|
add_compile_options(-Wimplicit-fallthrough)
|
||||||
add_compile_options(-Wsign-conversion)
|
add_compile_options(-Wsign-conversion)
|
||||||
@ -56,6 +57,14 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
|
|||||||
eth_add_cxx_compiler_flag_if_supported(
|
eth_add_cxx_compiler_flag_if_supported(
|
||||||
$<$<COMPILE_LANGUAGE:CXX>:-Wextra-semi>
|
$<$<COMPILE_LANGUAGE:CXX>:-Wextra-semi>
|
||||||
)
|
)
|
||||||
|
eth_add_cxx_compiler_flag_if_supported(-Wfinal-dtor-non-final-class)
|
||||||
|
eth_add_cxx_compiler_flag_if_supported(-Wnewline-eof)
|
||||||
|
eth_add_cxx_compiler_flag_if_supported(-Wsuggest-destructor-override)
|
||||||
|
eth_add_cxx_compiler_flag_if_supported(-Wunreachable-code-break)
|
||||||
|
eth_add_cxx_compiler_flag_if_supported(-Wduplicated-cond)
|
||||||
|
eth_add_cxx_compiler_flag_if_supported(-Wduplicate-enum)
|
||||||
|
eth_add_cxx_compiler_flag_if_supported(-Wlogical-op)
|
||||||
|
eth_add_cxx_compiler_flag_if_supported(-Wno-unknown-attributes)
|
||||||
|
|
||||||
# Configuration-specific compiler settings.
|
# Configuration-specific compiler settings.
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -DETH_DEBUG")
|
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -DETH_DEBUG")
|
||||||
@ -65,11 +74,8 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
|
|||||||
|
|
||||||
# Additional GCC-specific compiler settings.
|
# Additional GCC-specific compiler settings.
|
||||||
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
|
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
|
||||||
|
|
||||||
# Check that we've got GCC 8.0 or newer.
|
# Check that we've got GCC 8.0 or newer.
|
||||||
execute_process(
|
if (NOT (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0))
|
||||||
COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
|
|
||||||
if (NOT (GCC_VERSION VERSION_GREATER 8.0 OR GCC_VERSION VERSION_EQUAL 8.0))
|
|
||||||
message(FATAL_ERROR "${PROJECT_NAME} requires g++ 8.0 or greater.")
|
message(FATAL_ERROR "${PROJECT_NAME} requires g++ 8.0 or greater.")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
@ -78,6 +84,11 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
|
|||||||
|
|
||||||
# Additional Clang-specific compiler settings.
|
# Additional Clang-specific compiler settings.
|
||||||
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||||
|
# Check that we've got clang 7.0 or newer.
|
||||||
|
if (NOT (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 7.0))
|
||||||
|
message(FATAL_ERROR "${PROJECT_NAME} requires clang++ 7.0 or greater.")
|
||||||
|
endif ()
|
||||||
|
|
||||||
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
|
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
|
||||||
# Set stack size to 32MB - by default Apple's clang defines a stack size of 8MB.
|
# Set stack size to 32MB - by default Apple's clang defines a stack size of 8MB.
|
||||||
# Normally 16MB is enough to run all tests, but it will exceed the stack, if -DSANITIZE=address is used.
|
# Normally 16MB is enough to run all tests, but it will exceed the stack, if -DSANITIZE=address is used.
|
||||||
|
@ -30,7 +30,7 @@ Not all types for constants and immutables are implemented at this time. The onl
|
|||||||
::
|
::
|
||||||
|
|
||||||
// SPDX-License-Identifier: GPL-3.0
|
// SPDX-License-Identifier: GPL-3.0
|
||||||
pragma solidity >0.7.2 <0.9.0;
|
pragma solidity >=0.7.4;
|
||||||
|
|
||||||
uint constant X = 32**22 + 8;
|
uint constant X = 32**22 + 8;
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ registering with a username and password, all you need is an Ethereum keypair.
|
|||||||
::
|
::
|
||||||
|
|
||||||
// SPDX-License-Identifier: GPL-3.0
|
// SPDX-License-Identifier: GPL-3.0
|
||||||
pragma solidity >0.5.99 <0.9.0;
|
pragma solidity >=0.7.0 <0.9.0;
|
||||||
|
|
||||||
contract Coin {
|
contract Coin {
|
||||||
// The keyword "public" makes variables
|
// The keyword "public" makes variables
|
||||||
|
@ -49,7 +49,7 @@ The following example shows a contract and a function using all available tags.
|
|||||||
.. code:: Solidity
|
.. code:: Solidity
|
||||||
|
|
||||||
// SPDX-License-Identifier: GPL-3.0
|
// SPDX-License-Identifier: GPL-3.0
|
||||||
pragma solidity >0.6.10 <0.9.0;
|
pragma solidity >=0.6.12 <0.9.0;
|
||||||
|
|
||||||
/// @title A simulator for trees
|
/// @title A simulator for trees
|
||||||
/// @author Larry A. Gardner
|
/// @author Larry A. Gardner
|
||||||
|
@ -1065,6 +1065,10 @@ No::
|
|||||||
|
|
||||||
and in ``Congress.sol``::
|
and in ``Congress.sol``::
|
||||||
|
|
||||||
|
// SPDX-License-Identifier: GPL-3.0
|
||||||
|
pragma solidity ^0.7.0;
|
||||||
|
|
||||||
|
|
||||||
import "./owned.sol";
|
import "./owned.sol";
|
||||||
|
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ individual elements:
|
|||||||
::
|
::
|
||||||
|
|
||||||
// SPDX-License-Identifier: GPL-3.0
|
// SPDX-License-Identifier: GPL-3.0
|
||||||
pragma solidity >=0.4.0 <0.9.0;
|
pragma solidity >=0.4.16 <0.9.0;
|
||||||
|
|
||||||
contract C {
|
contract C {
|
||||||
function f() public pure {
|
function f() public pure {
|
||||||
|
@ -116,6 +116,8 @@ std::string friendlyName(Token tok)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
int parseSize(string::const_iterator _begin, string::const_iterator _end)
|
int parseSize(string::const_iterator _begin, string::const_iterator _end)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -128,6 +130,7 @@ int parseSize(string::const_iterator _begin, string::const_iterator _end)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static Token keywordByName(string const& _name)
|
static Token keywordByName(string const& _name)
|
||||||
{
|
{
|
||||||
|
@ -34,6 +34,8 @@ using namespace std;
|
|||||||
namespace solidity::frontend
|
namespace solidity::frontend
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
/// Magic variables get negative ids for easy differentiation
|
/// Magic variables get negative ids for easy differentiation
|
||||||
int magicVariableToID(std::string const& _name)
|
int magicVariableToID(std::string const& _name)
|
||||||
{
|
{
|
||||||
@ -103,6 +105,8 @@ inline vector<shared_ptr<MagicVariableDeclaration const>> constructMagicVariable
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
GlobalContext::GlobalContext(): m_magicVariables{constructMagicVariables()}
|
GlobalContext::GlobalContext(): m_magicVariables{constructMagicVariables()}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -2179,7 +2179,8 @@ void TypeChecker::typeCheckFunctionGeneralChecks(
|
|||||||
for (size_t i = 0; i < paramArgMap.size(); ++i)
|
for (size_t i = 0; i < paramArgMap.size(); ++i)
|
||||||
{
|
{
|
||||||
solAssert(!!paramArgMap[i], "unmapped parameter");
|
solAssert(!!paramArgMap[i], "unmapped parameter");
|
||||||
if (!type(*paramArgMap[i])->isImplicitlyConvertibleTo(*parameterTypes[i]))
|
BoolResult result = type(*paramArgMap[i])->isImplicitlyConvertibleTo(*parameterTypes[i]);
|
||||||
|
if (!result)
|
||||||
{
|
{
|
||||||
auto [errorId, description] = [&]() -> tuple<ErrorId, string> {
|
auto [errorId, description] = [&]() -> tuple<ErrorId, string> {
|
||||||
string msg =
|
string msg =
|
||||||
@ -2189,6 +2190,8 @@ void TypeChecker::typeCheckFunctionGeneralChecks(
|
|||||||
" to " +
|
" to " +
|
||||||
parameterTypes[i]->toString() +
|
parameterTypes[i]->toString() +
|
||||||
" requested.";
|
" requested.";
|
||||||
|
if (!result.message().empty())
|
||||||
|
msg += " " + result.message();
|
||||||
if (
|
if (
|
||||||
_functionType->kind() == FunctionType::Kind::BareCall ||
|
_functionType->kind() == FunctionType::Kind::BareCall ||
|
||||||
_functionType->kind() == FunctionType::Kind::BareCallCode ||
|
_functionType->kind() == FunctionType::Kind::BareCallCode ||
|
||||||
|
@ -2901,6 +2901,13 @@ BoolResult FunctionType::isImplicitlyConvertibleTo(Type const& _convertTo) const
|
|||||||
|
|
||||||
FunctionType const& convertTo = dynamic_cast<FunctionType const&>(_convertTo);
|
FunctionType const& convertTo = dynamic_cast<FunctionType const&>(_convertTo);
|
||||||
|
|
||||||
|
// These two checks are duplicated in equalExcludingStateMutability, but are added here for error reporting.
|
||||||
|
if (convertTo.bound() != bound())
|
||||||
|
return BoolResult::err("Bound functions can not be converted to non-bound functions.");
|
||||||
|
|
||||||
|
if (convertTo.kind() != kind())
|
||||||
|
return BoolResult::err("Special functions can not be converted to function types.");
|
||||||
|
|
||||||
if (!equalExcludingStateMutability(convertTo))
|
if (!equalExcludingStateMutability(convertTo))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -51,28 +51,12 @@ public:
|
|||||||
);
|
);
|
||||||
/// @returns Entire assembly.
|
/// @returns Entire assembly.
|
||||||
evmasm::Assembly const& assembly() const { return m_context.assembly(); }
|
evmasm::Assembly const& assembly() const { return m_context.assembly(); }
|
||||||
|
/// @returns Runtime assembly.
|
||||||
|
evmasm::Assembly const& runtimeAssembly() const { return m_context.assembly().sub(m_runtimeSub); }
|
||||||
/// @returns Entire assembly as a shared pointer to non-const.
|
/// @returns Entire assembly as a shared pointer to non-const.
|
||||||
std::shared_ptr<evmasm::Assembly> assemblyPtr() const { return m_context.assemblyPtr(); }
|
std::shared_ptr<evmasm::Assembly> assemblyPtr() const { return m_context.assemblyPtr(); }
|
||||||
/// @returns Runtime assembly.
|
/// @returns Runtime assembly as a shared pointer.
|
||||||
std::shared_ptr<evmasm::Assembly> runtimeAssemblyPtr() const;
|
std::shared_ptr<evmasm::Assembly> runtimeAssemblyPtr() const;
|
||||||
/// @returns The entire assembled object (with constructor).
|
|
||||||
evmasm::LinkerObject assembledObject() const { return m_context.assembledObject(); }
|
|
||||||
/// @returns Only the runtime object (without constructor).
|
|
||||||
evmasm::LinkerObject runtimeObject() const { return m_context.assembledRuntimeObject(m_runtimeSub); }
|
|
||||||
/// @arg _sourceCodes is the map of input files to source code strings
|
|
||||||
std::string assemblyString(StringMap const& _sourceCodes = StringMap()) const
|
|
||||||
{
|
|
||||||
return m_context.assemblyString(_sourceCodes);
|
|
||||||
}
|
|
||||||
/// @arg _sourceCodes is the map of input files to source code strings
|
|
||||||
Json::Value assemblyJSON(std::map<std::string, unsigned> const& _indices = std::map<std::string, unsigned>()) const
|
|
||||||
{
|
|
||||||
return m_context.assemblyJSON(_indices);
|
|
||||||
}
|
|
||||||
/// @returns Assembly items of the normal compiler context
|
|
||||||
evmasm::AssemblyItems const& assemblyItems() const { return m_context.assembly().items(); }
|
|
||||||
/// @returns Assembly items of the runtime compiler context
|
|
||||||
evmasm::AssemblyItems const& runtimeAssemblyItems() const { return m_context.assembly().sub(m_runtimeSub).items(); }
|
|
||||||
|
|
||||||
std::string generatedYulUtilityCode() const { return m_context.generatedYulUtilityCode(); }
|
std::string generatedYulUtilityCode() const { return m_context.generatedYulUtilityCode(); }
|
||||||
std::string runtimeGeneratedYulUtilityCode() const { return m_runtimeContext.generatedYulUtilityCode(); }
|
std::string runtimeGeneratedYulUtilityCode() const { return m_runtimeContext.generatedYulUtilityCode(); }
|
||||||
|
@ -557,13 +557,6 @@ void CompilerContext::optimizeYul(yul::Object& _object, yul::EVMDialect const& _
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
LinkerObject const& CompilerContext::assembledObject() const
|
|
||||||
{
|
|
||||||
LinkerObject const& object = m_asm->assemble();
|
|
||||||
solAssert(object.immutableReferences.empty(), "Leftover immutables.");
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
|
|
||||||
string CompilerContext::revertReasonIfDebug(string const& _message)
|
string CompilerContext::revertReasonIfDebug(string const& _message)
|
||||||
{
|
{
|
||||||
return YulUtilFunctions::revertReasonIfDebug(m_revertStrings, _message);
|
return YulUtilFunctions::revertReasonIfDebug(m_revertStrings, _message);
|
||||||
|
@ -291,21 +291,6 @@ public:
|
|||||||
/// Should be avoided except when adding sub-assemblies.
|
/// Should be avoided except when adding sub-assemblies.
|
||||||
std::shared_ptr<evmasm::Assembly> assemblyPtr() const { return m_asm; }
|
std::shared_ptr<evmasm::Assembly> assemblyPtr() const { return m_asm; }
|
||||||
|
|
||||||
/// @arg _sourceCodes is the map of input files to source code strings
|
|
||||||
std::string assemblyString(StringMap const& _sourceCodes = StringMap()) const
|
|
||||||
{
|
|
||||||
return m_asm->assemblyString(_sourceCodes);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @arg _sourceCodes is the map of input files to source code strings
|
|
||||||
Json::Value assemblyJSON(std::map<std::string, unsigned> const& _indicies = std::map<std::string, unsigned>()) const
|
|
||||||
{
|
|
||||||
return m_asm->assemblyJSON(_indicies);
|
|
||||||
}
|
|
||||||
|
|
||||||
evmasm::LinkerObject const& assembledObject() const;
|
|
||||||
evmasm::LinkerObject const& assembledRuntimeObject(size_t _subIndex) const { return m_asm->sub(_subIndex).assemble(); }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class to pop the visited nodes stack when a scope closes
|
* Helper class to pop the visited nodes stack when a scope closes
|
||||||
*/
|
*/
|
||||||
|
@ -1731,8 +1731,9 @@ string YulUtilFunctions::copyByteArrayToStorageFunction(ArrayType const& _fromTy
|
|||||||
|
|
||||||
let oldLen := <byteArrayLength>(sload(slot))
|
let oldLen := <byteArrayLength>(sload(slot))
|
||||||
|
|
||||||
|
let srcOffset := 0
|
||||||
<?fromMemory>
|
<?fromMemory>
|
||||||
src := add(src, 0x20)
|
srcOffset := 0x20
|
||||||
</fromMemory>
|
</fromMemory>
|
||||||
|
|
||||||
// This is not needed in all branches.
|
// This is not needed in all branches.
|
||||||
@ -1750,14 +1751,16 @@ string YulUtilFunctions::copyByteArrayToStorageFunction(ArrayType const& _fromTy
|
|||||||
switch gt(newLen, 31)
|
switch gt(newLen, 31)
|
||||||
case 1 {
|
case 1 {
|
||||||
let loopEnd := and(newLen, not(0x1f))
|
let loopEnd := and(newLen, not(0x1f))
|
||||||
|
<?fromStorage> src := <srcDataLocation>(src) </fromStorage>
|
||||||
let dstPtr := dstDataArea
|
let dstPtr := dstDataArea
|
||||||
let i := 0
|
let i := 0
|
||||||
for { } lt(i, loopEnd) { i := add(i, 32) } {
|
for { } lt(i, loopEnd) { i := add(i, 0x20) } {
|
||||||
sstore(dstPtr, <read>(add(src, i)))
|
sstore(dstPtr, <read>(add(src, srcOffset)))
|
||||||
dstPtr := add(dstPtr, 1)
|
dstPtr := add(dstPtr, 1)
|
||||||
|
srcOffset := add(srcOffset, <srcIncrement>)
|
||||||
}
|
}
|
||||||
if lt(loopEnd, newLen) {
|
if lt(loopEnd, newLen) {
|
||||||
let lastValue := <read>(add(src, i))
|
let lastValue := <read>(add(src, srcOffset))
|
||||||
sstore(dstPtr, <maskBytes>(lastValue, and(newLen, 0x1f)))
|
sstore(dstPtr, <maskBytes>(lastValue, and(newLen, 0x1f)))
|
||||||
}
|
}
|
||||||
sstore(slot, add(mul(newLen, 2), 1))
|
sstore(slot, add(mul(newLen, 2), 1))
|
||||||
@ -1765,7 +1768,7 @@ string YulUtilFunctions::copyByteArrayToStorageFunction(ArrayType const& _fromTy
|
|||||||
default {
|
default {
|
||||||
let value := 0
|
let value := 0
|
||||||
if newLen {
|
if newLen {
|
||||||
value := <read>(src)
|
value := <read>(add(src, srcOffset))
|
||||||
}
|
}
|
||||||
sstore(slot, <byteArrayCombineShort>(value, newLen))
|
sstore(slot, <byteArrayCombineShort>(value, newLen))
|
||||||
}
|
}
|
||||||
@ -1781,7 +1784,10 @@ string YulUtilFunctions::copyByteArrayToStorageFunction(ArrayType const& _fromTy
|
|||||||
templ("panic", panicFunction(PanicCode::ResourceError));
|
templ("panic", panicFunction(PanicCode::ResourceError));
|
||||||
templ("byteArrayLength", extractByteArrayLengthFunction());
|
templ("byteArrayLength", extractByteArrayLengthFunction());
|
||||||
templ("dstDataLocation", arrayDataAreaFunction(_toType));
|
templ("dstDataLocation", arrayDataAreaFunction(_toType));
|
||||||
|
if (fromStorage)
|
||||||
|
templ("srcDataLocation", arrayDataAreaFunction(_fromType));
|
||||||
templ("clearStorageRange", clearStorageRangeFunction(*_toType.baseType()));
|
templ("clearStorageRange", clearStorageRangeFunction(*_toType.baseType()));
|
||||||
|
templ("srcIncrement", to_string(fromStorage ? 1 : 0x20));
|
||||||
templ("read", fromStorage ? "sload" : fromCalldata ? "calldataload" : "mload");
|
templ("read", fromStorage ? "sload" : fromCalldata ? "calldataload" : "mload");
|
||||||
templ("maskBytes", maskBytesFunctionDynamic());
|
templ("maskBytes", maskBytesFunctionDynamic());
|
||||||
templ("byteArrayCombineShort", shortByteArrayEncodeUsedAreaSetLengthFunction());
|
templ("byteArrayCombineShort", shortByteArrayEncodeUsedAreaSetLengthFunction());
|
||||||
|
@ -356,27 +356,12 @@ void BMC::endVisit(UnaryOperation const& _op)
|
|||||||
)
|
)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (_op.getOperator())
|
if (_op.getOperator() == Token::Sub && smt::isInteger(*_op.annotation().type))
|
||||||
{
|
|
||||||
case Token::Inc: // ++ (pre- or postfix)
|
|
||||||
case Token::Dec: // -- (pre- or postfix)
|
|
||||||
addVerificationTarget(
|
addVerificationTarget(
|
||||||
VerificationTarget::Type::UnderOverflow,
|
VerificationTarget::Type::UnderOverflow,
|
||||||
expr(_op),
|
expr(_op),
|
||||||
&_op
|
&_op
|
||||||
);
|
);
|
||||||
break;
|
|
||||||
case Token::Sub: // -
|
|
||||||
if (_op.annotation().type->category() == Type::Category::Integer)
|
|
||||||
addVerificationTarget(
|
|
||||||
VerificationTarget::Type::UnderOverflow,
|
|
||||||
expr(_op),
|
|
||||||
&_op
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BMC::endVisit(FunctionCall const& _funCall)
|
void BMC::endVisit(FunctionCall const& _funCall)
|
||||||
|
@ -164,11 +164,11 @@ void CHC::endVisit(ContractDefinition const& _contract)
|
|||||||
if (base != &_contract)
|
if (base != &_contract)
|
||||||
{
|
{
|
||||||
m_callGraph[&_contract].insert(base);
|
m_callGraph[&_contract].insert(base);
|
||||||
vector<ASTPointer<Expression>> const& args = baseArgs.count(base) ? baseArgs.at(base) : decltype(args){};
|
|
||||||
|
|
||||||
auto baseConstructor = base->constructor();
|
auto baseConstructor = base->constructor();
|
||||||
if (baseConstructor && !args.empty())
|
if (baseConstructor && baseArgs.count(base))
|
||||||
{
|
{
|
||||||
|
vector<ASTPointer<Expression>> const& args = baseArgs.at(base);
|
||||||
auto const& params = baseConstructor->parameters();
|
auto const& params = baseConstructor->parameters();
|
||||||
solAssert(params.size() == args.size(), "");
|
solAssert(params.size() == args.size(), "");
|
||||||
for (unsigned i = 0; i < params.size(); ++i)
|
for (unsigned i = 0; i < params.size(); ++i)
|
||||||
|
@ -512,7 +512,13 @@ void SMTEncoder::endVisit(UnaryOperation const& _op)
|
|||||||
auto decl = identifierToVariable(*identifier);
|
auto decl = identifierToVariable(*identifier);
|
||||||
solAssert(decl, "");
|
solAssert(decl, "");
|
||||||
auto innerValue = currentValue(*decl);
|
auto innerValue = currentValue(*decl);
|
||||||
auto newValue = _op.getOperator() == Token::Inc ? innerValue + 1 : innerValue - 1;
|
auto newValue = arithmeticOperation(
|
||||||
|
_op.getOperator() == Token::Inc ? Token::Add : Token::Sub,
|
||||||
|
innerValue,
|
||||||
|
smtutil::Expression(size_t(1)),
|
||||||
|
_op.annotation().type,
|
||||||
|
_op
|
||||||
|
).first;
|
||||||
defineExpr(_op, _op.isPrefixOperation() ? newValue : innerValue);
|
defineExpr(_op, _op.isPrefixOperation() ? newValue : innerValue);
|
||||||
assignment(*decl, newValue);
|
assignment(*decl, newValue);
|
||||||
}
|
}
|
||||||
@ -522,7 +528,13 @@ void SMTEncoder::endVisit(UnaryOperation const& _op)
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
auto innerValue = expr(*subExpr);
|
auto innerValue = expr(*subExpr);
|
||||||
auto newValue = _op.getOperator() == Token::Inc ? innerValue + 1 : innerValue - 1;
|
auto newValue = arithmeticOperation(
|
||||||
|
_op.getOperator() == Token::Inc ? Token::Add : Token::Sub,
|
||||||
|
innerValue,
|
||||||
|
smtutil::Expression(size_t(1)),
|
||||||
|
_op.annotation().type,
|
||||||
|
_op
|
||||||
|
).first;
|
||||||
defineExpr(_op, _op.isPrefixOperation() ? newValue : innerValue);
|
defineExpr(_op, _op.isPrefixOperation() ? newValue : innerValue);
|
||||||
indexOrMemberAssignment(*subExpr, newValue);
|
indexOrMemberAssignment(*subExpr, newValue);
|
||||||
}
|
}
|
||||||
|
@ -399,4 +399,4 @@ smtutil::Expression SymbolicStructVariable::assignAllMembers(vector<smtutil::Exp
|
|||||||
m_context.addAssertion(_memberValues[i] == member(structMembers[i]->name()));
|
m_context.addAssertion(_memberValues[i] == member(structMembers[i]->name()));
|
||||||
|
|
||||||
return currentValue();
|
return currentValue();
|
||||||
}
|
}
|
||||||
|
@ -627,7 +627,7 @@ evmasm::AssemblyItems const* CompilerStack::assemblyItems(string const& _contrac
|
|||||||
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Compilation was not successful."));
|
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Compilation was not successful."));
|
||||||
|
|
||||||
Contract const& currentContract = contract(_contractName);
|
Contract const& currentContract = contract(_contractName);
|
||||||
return currentContract.compiler ? &contract(_contractName).compiler->assemblyItems() : nullptr;
|
return currentContract.evmAssembly ? ¤tContract.evmAssembly->items() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
evmasm::AssemblyItems const* CompilerStack::runtimeAssemblyItems(string const& _contractName) const
|
evmasm::AssemblyItems const* CompilerStack::runtimeAssemblyItems(string const& _contractName) const
|
||||||
@ -636,7 +636,7 @@ evmasm::AssemblyItems const* CompilerStack::runtimeAssemblyItems(string const& _
|
|||||||
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Compilation was not successful."));
|
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Compilation was not successful."));
|
||||||
|
|
||||||
Contract const& currentContract = contract(_contractName);
|
Contract const& currentContract = contract(_contractName);
|
||||||
return currentContract.compiler ? &contract(_contractName).compiler->runtimeAssemblyItems() : nullptr;
|
return currentContract.evmRuntimeAssembly ? ¤tContract.evmRuntimeAssembly->items() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Json::Value CompilerStack::generatedSources(string const& _contractName, bool _runtime) const
|
Json::Value CompilerStack::generatedSources(string const& _contractName, bool _runtime) const
|
||||||
@ -790,8 +790,8 @@ string CompilerStack::assemblyString(string const& _contractName, StringMap _sou
|
|||||||
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Compilation was not successful."));
|
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Compilation was not successful."));
|
||||||
|
|
||||||
Contract const& currentContract = contract(_contractName);
|
Contract const& currentContract = contract(_contractName);
|
||||||
if (currentContract.compiler)
|
if (currentContract.evmAssembly)
|
||||||
return currentContract.compiler->assemblyString(_sourceCodes);
|
return currentContract.evmAssembly->assemblyString(_sourceCodes);
|
||||||
else
|
else
|
||||||
return string();
|
return string();
|
||||||
}
|
}
|
||||||
@ -803,8 +803,8 @@ Json::Value CompilerStack::assemblyJSON(string const& _contractName) const
|
|||||||
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Compilation was not successful."));
|
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Compilation was not successful."));
|
||||||
|
|
||||||
Contract const& currentContract = contract(_contractName);
|
Contract const& currentContract = contract(_contractName);
|
||||||
if (currentContract.compiler)
|
if (currentContract.evmAssembly)
|
||||||
return currentContract.compiler->assemblyJSON(sourceIndices());
|
return currentContract.evmAssembly->assemblyJSON(sourceIndices());
|
||||||
else
|
else
|
||||||
return Json::Value();
|
return Json::Value();
|
||||||
}
|
}
|
||||||
@ -977,7 +977,7 @@ size_t CompilerStack::functionEntryPoint(
|
|||||||
evmasm::AssemblyItem tag = compiler->functionEntryLabel(_function);
|
evmasm::AssemblyItem tag = compiler->functionEntryLabel(_function);
|
||||||
if (tag.type() == evmasm::UndefinedItem)
|
if (tag.type() == evmasm::UndefinedItem)
|
||||||
return 0;
|
return 0;
|
||||||
evmasm::AssemblyItems const& items = compiler->runtimeAssemblyItems();
|
evmasm::AssemblyItems const& items = compiler->runtimeAssembly().items();
|
||||||
for (size_t i = 0; i < items.size(); ++i)
|
for (size_t i = 0; i < items.size(); ++i)
|
||||||
if (items.at(i).type() == evmasm::Tag && items.at(i).data() == tag.data())
|
if (items.at(i).type() == evmasm::Tag && items.at(i).data() == tag.data())
|
||||||
return i;
|
return i;
|
||||||
@ -1200,20 +1200,25 @@ void CompilerStack::compileContract(
|
|||||||
solAssert(false, "Optimizer exception during compilation");
|
solAssert(false, "Optimizer exception during compilation");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compiledContract.evmAssembly = compiler->assemblyPtr();
|
||||||
|
solAssert(compiledContract.evmAssembly, "");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Assemble deployment (incl. runtime) object.
|
// Assemble deployment (incl. runtime) object.
|
||||||
compiledContract.object = compiler->assembledObject();
|
compiledContract.object = compiledContract.evmAssembly->assemble();
|
||||||
}
|
}
|
||||||
catch(evmasm::AssemblyException const&)
|
catch(evmasm::AssemblyException const&)
|
||||||
{
|
{
|
||||||
solAssert(false, "Assembly exception for bytecode");
|
solAssert(false, "Assembly exception for bytecode");
|
||||||
}
|
}
|
||||||
|
solAssert(compiledContract.object.immutableReferences.empty(), "Leftover immutables.");
|
||||||
|
|
||||||
|
compiledContract.evmRuntimeAssembly = compiler->runtimeAssemblyPtr();
|
||||||
|
solAssert(compiledContract.evmRuntimeAssembly, "");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Assemble runtime object.
|
// Assemble runtime object.
|
||||||
compiledContract.runtimeObject = compiler->runtimeObject();
|
compiledContract.runtimeObject = compiledContract.evmRuntimeAssembly->assemble();
|
||||||
}
|
}
|
||||||
catch(evmasm::AssemblyException const&)
|
catch(evmasm::AssemblyException const&)
|
||||||
{
|
{
|
||||||
|
@ -358,6 +358,8 @@ private:
|
|||||||
{
|
{
|
||||||
ContractDefinition const* contract = nullptr;
|
ContractDefinition const* contract = nullptr;
|
||||||
std::shared_ptr<Compiler> compiler;
|
std::shared_ptr<Compiler> compiler;
|
||||||
|
std::shared_ptr<evmasm::Assembly> evmAssembly;
|
||||||
|
std::shared_ptr<evmasm::Assembly> evmRuntimeAssembly;
|
||||||
evmasm::LinkerObject object; ///< Deployment object (includes the runtime sub-object).
|
evmasm::LinkerObject object; ///< Deployment object (includes the runtime sub-object).
|
||||||
evmasm::LinkerObject runtimeObject; ///< Runtime object.
|
evmasm::LinkerObject runtimeObject; ///< Runtime object.
|
||||||
std::string yulIR; ///< Experimental Yul IR code.
|
std::string yulIR; ///< Experimental Yul IR code.
|
||||||
|
@ -48,6 +48,7 @@ public:
|
|||||||
|
|
||||||
/// The size of the container.
|
/// The size of the container.
|
||||||
enum { size = N };
|
enum { size = N };
|
||||||
|
static_assert(N != 0);
|
||||||
|
|
||||||
/// Method to convert from a string.
|
/// Method to convert from a string.
|
||||||
enum ConstructFromStringType { FromHex, FromBinary };
|
enum ConstructFromStringType { FromHex, FromBinary };
|
||||||
@ -59,7 +60,13 @@ public:
|
|||||||
explicit FixedHash() { m_data.fill(0); }
|
explicit FixedHash() { m_data.fill(0); }
|
||||||
|
|
||||||
/// Construct from another hash, filling with zeroes or cropping as necessary.
|
/// Construct from another hash, filling with zeroes or cropping as necessary.
|
||||||
template <unsigned M> explicit FixedHash(FixedHash<M> const& _h, ConstructFromHashType _t = AlignLeft) { m_data.fill(0); unsigned c = std::min(M, N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _h[_t == AlignRight ? M - 1 - i : i]; }
|
template <unsigned M> explicit FixedHash(FixedHash<M> const& _h, ConstructFromHashType _t = AlignLeft)
|
||||||
|
{
|
||||||
|
m_data.fill(0);
|
||||||
|
unsigned c = std::min(M, N);
|
||||||
|
for (unsigned i = 0; i < c; ++i)
|
||||||
|
m_data[_t == AlignRight ? N - 1 - i : i] = _h[_t == AlignRight ? M - 1 - i : i];
|
||||||
|
}
|
||||||
|
|
||||||
/// Convert from the corresponding arithmetic type.
|
/// Convert from the corresponding arithmetic type.
|
||||||
FixedHash(Arith const& _arith) { toBigEndian(_arith, m_data); }
|
FixedHash(Arith const& _arith) { toBigEndian(_arith, m_data); }
|
||||||
@ -104,8 +111,10 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Explicitly construct, copying from a string.
|
/// Explicitly construct, copying from a string.
|
||||||
explicit FixedHash(std::string const& _s, ConstructFromStringType _t = FromHex, ConstructFromHashType _ht = FailIfDifferent): FixedHash(_t == FromHex ? fromHex(_s, WhenError::Throw) : solidity::util::asBytes(_s), _ht) {}
|
explicit FixedHash(std::string const& _s, ConstructFromStringType _t = FromHex, ConstructFromHashType _ht = FailIfDifferent):
|
||||||
|
FixedHash(_t == FromHex ? fromHex(_s, WhenError::Throw) : solidity::util::asBytes(_s), _ht)
|
||||||
|
{}
|
||||||
|
|
||||||
/// Convert to arithmetic type.
|
/// Convert to arithmetic type.
|
||||||
operator Arith() const { return fromBigEndian<Arith>(m_data); }
|
operator Arith() const { return fromBigEndian<Arith>(m_data); }
|
||||||
@ -114,7 +123,16 @@ public:
|
|||||||
bool operator==(FixedHash const& _c) const { return m_data == _c.m_data; }
|
bool operator==(FixedHash const& _c) const { return m_data == _c.m_data; }
|
||||||
bool operator!=(FixedHash const& _c) const { return m_data != _c.m_data; }
|
bool operator!=(FixedHash const& _c) const { return m_data != _c.m_data; }
|
||||||
/// Required to sort objects of this type or use them as map keys.
|
/// Required to sort objects of this type or use them as map keys.
|
||||||
bool operator<(FixedHash const& _c) const { for (unsigned i = 0; i < N; ++i) if (m_data[i] < _c.m_data[i]) return true; else if (m_data[i] > _c.m_data[i]) return false; return false; }
|
bool operator<(FixedHash const& _c) const {
|
||||||
|
for (unsigned i = 0; i < N; ++i)
|
||||||
|
{
|
||||||
|
if (m_data[i] < _c.m_data[i])
|
||||||
|
return true;
|
||||||
|
else if (m_data[i] > _c.m_data[i])
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/// @returns a particular byte from the hash.
|
/// @returns a particular byte from the hash.
|
||||||
uint8_t& operator[](unsigned _i) { return m_data[_i]; }
|
uint8_t& operator[](unsigned _i) { return m_data[_i]; }
|
||||||
|
@ -76,8 +76,6 @@ bool isWellFormed(unsigned char byte1, unsigned char byte2)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool validateUTF8(unsigned char const* _input, size_t _length, size_t& _invalidPosition)
|
bool validateUTF8(unsigned char const* _input, size_t _length, size_t& _invalidPosition)
|
||||||
{
|
{
|
||||||
bool valid = true;
|
bool valid = true;
|
||||||
@ -134,6 +132,8 @@ bool validateUTF8(unsigned char const* _input, size_t _length, size_t& _invalidP
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool validateUTF8(std::string const& _input, size_t& _invalidPosition)
|
bool validateUTF8(std::string const& _input, size_t& _invalidPosition)
|
||||||
{
|
{
|
||||||
return validateUTF8(reinterpret_cast<unsigned char const*>(_input.c_str()), _input.length(), _invalidPosition);
|
return validateUTF8(reinterpret_cast<unsigned char const*>(_input.c_str()), _input.length(), _invalidPosition);
|
||||||
|
@ -36,4 +36,4 @@ void FunctionCallFinder::operator()(FunctionCall& _functionCall)
|
|||||||
ASTModifier::operator()(_functionCall);
|
ASTModifier::operator()(_functionCall);
|
||||||
if (_functionCall.functionName.name == m_functionName)
|
if (_functionCall.functionName.name == m_functionName)
|
||||||
m_calls.emplace_back(&_functionCall);
|
m_calls.emplace_back(&_functionCall);
|
||||||
}
|
}
|
||||||
|
@ -129,4 +129,4 @@ private:
|
|||||||
NameDispenser& m_nameDispenser;
|
NameDispenser& m_nameDispenser;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ do
|
|||||||
NSOURCES=$((NSOURCES - 1))
|
NSOURCES=$((NSOURCES - 1))
|
||||||
for i in $OUTPUT;
|
for i in $OUTPUT;
|
||||||
do
|
do
|
||||||
testImportExportEquivalence $i $OUTPUT
|
testImportExportEquivalence "$i" "$OUTPUT"
|
||||||
NSOURCES=$((NSOURCES + 1))
|
NSOURCES=$((NSOURCES + 1))
|
||||||
done
|
done
|
||||||
elif [ ${SPLITSOURCES_RC} == 1 ]
|
elif [ ${SPLITSOURCES_RC} == 1 ]
|
||||||
|
@ -49,7 +49,6 @@ function compileFull()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
local files="$*"
|
local files="$*"
|
||||||
local output
|
|
||||||
|
|
||||||
local stderr_path=$(mktemp)
|
local stderr_path=$(mktemp)
|
||||||
|
|
||||||
@ -71,7 +70,7 @@ function compileFull()
|
|||||||
printError "Was failure: $exit_code"
|
printError "Was failure: $exit_code"
|
||||||
echo "$errors"
|
echo "$errors"
|
||||||
printError "While calling:"
|
printError "While calling:"
|
||||||
echo "\"$SOLC\" $ARGS $files"
|
echo "\"$SOLC\" $args $files"
|
||||||
printError "Inside directory:"
|
printError "Inside directory:"
|
||||||
pwd
|
pwd
|
||||||
false
|
false
|
||||||
|
@ -65,7 +65,7 @@ function getAllAvailableVersions()
|
|||||||
{
|
{
|
||||||
allVersions=()
|
allVersions=()
|
||||||
local allListedVersions=( $(
|
local allListedVersions=( $(
|
||||||
wget -q -O- https://ethereum.github.io/solc-bin/bin/list.txt |
|
wget -q -O- https://binaries.soliditylang.org/bin/list.txt |
|
||||||
grep -Po '(?<=soljson-v)\d+.\d+.\d+(?=\+commit)' |
|
grep -Po '(?<=soljson-v)\d+.\d+.\d+(?=\+commit)' |
|
||||||
sort -V
|
sort -V
|
||||||
) )
|
) )
|
||||||
@ -108,7 +108,7 @@ function findMinimalVersion()
|
|||||||
do
|
do
|
||||||
if versionGreater "$ver" "$pragmaVersion"
|
if versionGreater "$ver" "$pragmaVersion"
|
||||||
then
|
then
|
||||||
minVersion="$ver"
|
version="$ver"
|
||||||
break
|
break
|
||||||
elif ([ $greater == false ]) && versionEqual "$ver" "$pragmaVersion"
|
elif ([ $greater == false ]) && versionEqual "$ver" "$pragmaVersion"
|
||||||
then
|
then
|
||||||
@ -117,9 +117,10 @@ function findMinimalVersion()
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -z version ]
|
if [ -z "$version" ]
|
||||||
then
|
then
|
||||||
printError "No release $sign$pragmaVersion was listed in available releases!"
|
printError "No release $sign$pragmaVersion was listed in available releases!"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,4 +28,4 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
grep -oP "PROJECT_VERSION \"?\K[0-9.]+(?=\")"? $(dirname "$0")/../CMakeLists.txt
|
grep -oP "PROJECT_VERSION \"?\K[0-9.]+(?=\")?" $(dirname "$0")/../CMakeLists.txt
|
||||||
|
@ -27,7 +27,6 @@ if test -f $BIN/cmake && ($BIN/cmake --version | grep -q "$VERSION"); then
|
|||||||
else
|
else
|
||||||
FILE=cmake-$VERSION-$OS-x86_64.tar.gz
|
FILE=cmake-$VERSION-$OS-x86_64.tar.gz
|
||||||
URL=https://cmake.org/files/v$VERSION_MAJOR.$VERSION_MINOR/$FILE
|
URL=https://cmake.org/files/v$VERSION_MAJOR.$VERSION_MINOR/$FILE
|
||||||
ERROR=0
|
|
||||||
TMPFILE=$(mktemp --tmpdir cmake-$VERSION-$OS-x86_64.XXXXXXXX.tar.gz)
|
TMPFILE=$(mktemp --tmpdir cmake-$VERSION-$OS-x86_64.XXXXXXXX.tar.gz)
|
||||||
echo "Downloading CMake ($URL)..."
|
echo "Downloading CMake ($URL)..."
|
||||||
wget "$URL" -O "$TMPFILE" -nv
|
wget "$URL" -O "$TMPFILE" -nv
|
||||||
|
@ -113,7 +113,6 @@ wget -O ./solc/deps/downloads/jsoncpp-1.9.3.tar.gz https://github.com/open-sourc
|
|||||||
cd solc
|
cd solc
|
||||||
version=$($(dirname "$0")/get_version.sh)
|
version=$($(dirname "$0")/get_version.sh)
|
||||||
commithash=$(git rev-parse --short=8 HEAD)
|
commithash=$(git rev-parse --short=8 HEAD)
|
||||||
committimestamp=$(git show --format=%ci HEAD | head -n 1)
|
|
||||||
commitdate=$(git show --format=%ci HEAD | head -n 1 | cut - -b1-10 | sed -e 's/-0?/./' | sed -e 's/-0?/./')
|
commitdate=$(git show --format=%ci HEAD | head -n 1 | cut - -b1-10 | sed -e 's/-0?/./' | sed -e 's/-0?/./')
|
||||||
|
|
||||||
echo "$commithash" > commit_hash.txt
|
echo "$commithash" > commit_hash.txt
|
||||||
|
@ -109,9 +109,9 @@ do
|
|||||||
then
|
then
|
||||||
if [ -n "$optimize" ]
|
if [ -n "$optimize" ]
|
||||||
then
|
then
|
||||||
log=--logger=JUNIT,error,$log_directory/opt_$vm.xml $testargs
|
log=--logger=JUNIT,error,$log_directory/opt_$vm.xml
|
||||||
else
|
else
|
||||||
log=--logger=JUNIT,error,$log_directory/noopt_$vm.xml $testargs_no_opt
|
log=--logger=JUNIT,error,$log_directory/noopt_$vm.xml
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
TAG="$1"
|
|
||||||
SOLJSON_JS="$2"
|
|
||||||
|
|
||||||
# If we ever want to patch the binaries e.g. for compatibility with older solc-js versions,
|
# If we ever want to patch the binaries e.g. for compatibility with older solc-js versions,
|
||||||
# we can do that here.
|
# we can do that here.
|
||||||
|
#
|
||||||
|
# This script gets the following parameters:
|
||||||
|
# - TAG
|
||||||
|
# - SOLJSON_JS
|
||||||
|
@ -91,6 +91,9 @@ namespace solidity::frontend
|
|||||||
|
|
||||||
bool g_hasOutput = false;
|
bool g_hasOutput = false;
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
std::ostream& sout()
|
std::ostream& sout()
|
||||||
{
|
{
|
||||||
g_hasOutput = true;
|
g_hasOutput = true;
|
||||||
@ -104,6 +107,8 @@ std::ostream& serr(bool _used = true)
|
|||||||
return cerr;
|
return cerr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#define cout
|
#define cout
|
||||||
#define cerr
|
#define cerr
|
||||||
|
|
||||||
@ -326,6 +331,9 @@ static bool needsHumanTargetedStdout(po::variables_map const& _args)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
bool checkMutuallyExclusive(boost::program_options::variables_map const& args, std::string const& _optionA, std::string const& _optionB)
|
bool checkMutuallyExclusive(boost::program_options::variables_map const& args, std::string const& _optionA, std::string const& _optionB)
|
||||||
{
|
{
|
||||||
if (args.count(_optionA) && args.count(_optionB))
|
if (args.count(_optionA) && args.count(_optionB))
|
||||||
@ -337,6 +345,8 @@ bool checkMutuallyExclusive(boost::program_options::variables_map const& args, s
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void CommandLineInterface::handleBinary(string const& _contract)
|
void CommandLineInterface::handleBinary(string const& _contract)
|
||||||
{
|
{
|
||||||
if (m_args.count(g_argBinary))
|
if (m_args.count(g_argBinary))
|
||||||
|
@ -29,6 +29,7 @@ detect_stray_source_files("${contracts_sources}" "contracts/")
|
|||||||
set(libsolutil_sources
|
set(libsolutil_sources
|
||||||
libsolutil/Checksum.cpp
|
libsolutil/Checksum.cpp
|
||||||
libsolutil/CommonData.cpp
|
libsolutil/CommonData.cpp
|
||||||
|
libsolutil/FixedHash.cpp
|
||||||
libsolutil/IndentedWriter.cpp
|
libsolutil/IndentedWriter.cpp
|
||||||
libsolutil/IpfsHash.cpp
|
libsolutil/IpfsHash.cpp
|
||||||
libsolutil/IterateReplacing.cpp
|
libsolutil/IterateReplacing.cpp
|
||||||
|
@ -30,6 +30,9 @@ namespace po = boost::program_options;
|
|||||||
namespace solidity::test
|
namespace solidity::test
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
/// If non-empty returns the value of the env. variable ETH_TEST_PATH, otherwise
|
/// If non-empty returns the value of the env. variable ETH_TEST_PATH, otherwise
|
||||||
/// it tries to find a path that contains the directories "libsolidity/syntaxTests"
|
/// it tries to find a path that contains the directories "libsolidity/syntaxTests"
|
||||||
/// and returns it if found.
|
/// and returns it if found.
|
||||||
@ -84,6 +87,8 @@ std::string envOrDefaultPath(std::string const& env_name, std::string const& lib
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
CommonOptions::CommonOptions(std::string _caption):
|
CommonOptions::CommonOptions(std::string _caption):
|
||||||
options(_caption,
|
options(_caption,
|
||||||
po::options_description::m_default_line_length,
|
po::options_description::m_default_line_length,
|
||||||
|
@ -148,6 +148,10 @@ void initializeOptions()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Prototype -- why isn't this declared in the boost headers?
|
||||||
|
// TODO: replace this with a (global) fixture.
|
||||||
|
test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] );
|
||||||
|
|
||||||
test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] )
|
test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] )
|
||||||
{
|
{
|
||||||
master_test_suite_t& master = framework::master_test_suite();
|
master_test_suite_t& master = framework::master_test_suite();
|
||||||
|
@ -206,7 +206,7 @@ function test_solc_assembly_output()
|
|||||||
local expected_object="object \"object\" { code "${expected}" }"
|
local expected_object="object \"object\" { code "${expected}" }"
|
||||||
|
|
||||||
output=$(echo "${input}" | "$SOLC" - ${solc_args} 2>/dev/null)
|
output=$(echo "${input}" | "$SOLC" - ${solc_args} 2>/dev/null)
|
||||||
empty=$(echo $output | sed -ne '/'"${expected_object}"'/p')
|
empty=$(echo "$output" | tr '\n' ' ' | tr -s ' ' | sed -ne "/${expected_object}/p")
|
||||||
if [ -z "$empty" ]
|
if [ -z "$empty" ]
|
||||||
then
|
then
|
||||||
printError "Incorrect assembly output. Expected: "
|
printError "Incorrect assembly output. Expected: "
|
||||||
@ -436,15 +436,18 @@ SOLTMPDIR=$(mktemp -d)
|
|||||||
# The contract should be compiled
|
# The contract should be compiled
|
||||||
if [[ "$result" != 0 ]]
|
if [[ "$result" != 0 ]]
|
||||||
then
|
then
|
||||||
|
printError "Failed to compile a simple contract from standard input"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# This should not fail
|
# This should not fail
|
||||||
set +e
|
set +e
|
||||||
output=$(echo '' | "$SOLC" --ast - 2>/dev/null)
|
output=$(echo '' | "$SOLC" --ast-json - 2>/dev/null)
|
||||||
|
result=$?
|
||||||
set -e
|
set -e
|
||||||
if [[ $? != 0 ]]
|
if [[ $result != 0 ]]
|
||||||
then
|
then
|
||||||
|
printError "Incorrect response to --ast-json option with empty stdin"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
|
@ -19,4 +19,4 @@ target_sources(evmc INTERFACE
|
|||||||
${PROJECT_SOURCE_DIR}/test/evmc/utils.h
|
${PROJECT_SOURCE_DIR}/test/evmc/utils.h
|
||||||
)
|
)
|
||||||
target_include_directories(evmc INTERFACE ${PROJECT_SOURCE_DIR}/test/)
|
target_include_directories(evmc INTERFACE ${PROJECT_SOURCE_DIR}/test/)
|
||||||
target_link_libraries(evmc INTERFACE evmc_loader)
|
target_link_libraries(evmc INTERFACE evmc_loader)
|
||||||
|
92
test/externalTests/README.md
Normal file
92
test/externalTests/README.md
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
## Solidity external tests
|
||||||
|
This directory contains scripts for compiling some of the popular open-source projects using the
|
||||||
|
current version of the compiler and running their test suites.
|
||||||
|
|
||||||
|
Since projects often do not use the latest compiler, we keep a fork of each of these projects
|
||||||
|
at https://github.com/solidity-external-tests/. If changes are needed to make a project work with the
|
||||||
|
latest version of the compiler, they are maintained as a branch on top of the upstream master branch.
|
||||||
|
This is especially important for testing our `breaking` branch because we can not realistically expect
|
||||||
|
external projects to be instantly compatible with a compiler version that has not been released yet.
|
||||||
|
Applying necessary changes ourselves gives us confidence that breaking changes are sane and that
|
||||||
|
these projects *can* be upgraded at all.
|
||||||
|
|
||||||
|
### Recommended workflow
|
||||||
|
|
||||||
|
#### Adding a new external project
|
||||||
|
1. Create a fork of the upstream repository in https://github.com/solidity-external-tests/. If the
|
||||||
|
project consists of several repositories, fork them all.
|
||||||
|
2. Remove all the branches except for main one (`master`, `develop`, `main`, etc). This branch is
|
||||||
|
going to be always kept up to date with the upstream repository and should not contain any extra
|
||||||
|
commits.
|
||||||
|
- If the project is not up to date with the latest compiler version but has a branch that is,
|
||||||
|
try to use that branch instead.
|
||||||
|
3. Create a new branch named after the main branch and the compiler version from our `develop`
|
||||||
|
branch. E.g. if the latest Solidity version is 0.7.5 and the main branch of the external project
|
||||||
|
is called `master`, create `master_070`. This is where we will be adding our own commits.
|
||||||
|
4. Create a script for compiling/testing the project and put it in `test/externalTests/` in the
|
||||||
|
Solidity repository.
|
||||||
|
- The script should apply workarounds necessary to make the project actually use the compiler
|
||||||
|
binary it receives as a parameter and possibly add generic workarounds that should
|
||||||
|
work across different versions of the upstream project.
|
||||||
|
- Very specific workarounds that may easily break with every upstream change are better done as
|
||||||
|
commits in the newly added branch in the fork instead.
|
||||||
|
5. List the script in `test/externalTests.sh`.
|
||||||
|
6. Add the script to CircleCI configuration. Make sure to add both a compilation-only run and one that
|
||||||
|
also executes the test suite. If the latter takes a significant amount of time (say, more than
|
||||||
|
15 minutes) make it run nightly rather than on every PR.
|
||||||
|
7. Make sure that tests pass both on `develop` and on `breaking`. If the compiler from `breaking`
|
||||||
|
branch will not work without additional changes, add another branch, called after it in turn,
|
||||||
|
and add necessary workarounds there. Continuing the example above, the new branch would be
|
||||||
|
called `master_080` and should be rebased on top of `master_070`.
|
||||||
|
- The fewer commits in these branches, the better. Ideally, any changes needed to make the compiler
|
||||||
|
work should be submitted upstream and our branches should just be tracking the main upstream
|
||||||
|
branch without any extra commits.
|
||||||
|
|
||||||
|
#### Updating external projects for a PR that introduces breaking changes in the compiler
|
||||||
|
If a PR to our `breaking` branch introduces changes that will make an external project no longer
|
||||||
|
compile or pass its tests, the fork needs to be modified:
|
||||||
|
- If a branch specific to the compiler version from `breaking` does not exist yet:
|
||||||
|
1. Create the branch. It should be based on the version-specific branch used on `develop`.
|
||||||
|
2. Make your PR modify the project script in `test/externalScripts/` to use the new branch.
|
||||||
|
3. You are free to add any changes you need in the new branch since it will not interfere with
|
||||||
|
tests on `breaking`.
|
||||||
|
4. Work on your PR until it is approved and merged into `breaking`.
|
||||||
|
- If the branch already exists and our CI depends on it:
|
||||||
|
1. If the external project after your changes can still work with `breaking` even without your PR or
|
||||||
|
if you know that the PR is straightforward and will be merged immediately without interfering
|
||||||
|
with tests on `breaking` for a significant amount of time, you can just push your modifications
|
||||||
|
to the branch directly and skip straight to steps 4. and 6.
|
||||||
|
2. Create a PR in the fork, targeting the existing version-specific branch.
|
||||||
|
3. In your PR to `breaking`, modify the corresponding script in `test/externalScripts/` to
|
||||||
|
use the branch from your PR in the fork.
|
||||||
|
4. Work on your PR until it is approved and ready to merge.
|
||||||
|
5. Merge the PR in the fork.
|
||||||
|
6. Discard your changes to the script and merge your PR into `breaking`.
|
||||||
|
|
||||||
|
#### Pulling upstream changes into a fork
|
||||||
|
1. Pull changes directly into the main branch in the fork. This should be straightforward thanks to
|
||||||
|
it not containing any of our customizations.
|
||||||
|
2. If the project has been updated to a newer Solidity version, abandon the current version-specific
|
||||||
|
branch used on `develop` (but do not delete it) and create a new one corresponding to the newer
|
||||||
|
version. Then update project script in `test/externalTests/` to use the new branch. E.g. if `develop` uses
|
||||||
|
`master_050` and the project has been updated to use Solidity 0.7.3, create `master_070`.
|
||||||
|
3. Otherwise, rebase the current version-specific branch on the main branch of the fork. This may require
|
||||||
|
tweaking some of the commits to apply our fixes in new places.
|
||||||
|
4. If we have a separate branch for `breaking`, rebase it on top of the one used on `develop`.
|
||||||
|
|
||||||
|
The above is the workflow to use when the update is straightforward and looks safe. In that case it is
|
||||||
|
fine to just modify the branches directly. If this is not the case, it is recommended to first perform the
|
||||||
|
operation on copies of these version-specific branches and test them by creating PRs on `develop` and
|
||||||
|
`breaking` to see if tests pass. The PRs should just modify project scripts in `test/externalScripts/`
|
||||||
|
to use the updated copies of the branches and can be discarded aferwards without being merged.
|
||||||
|
|
||||||
|
#### Changes needed after a breaking release of the compiler
|
||||||
|
When a non-backwards-compatible version becomes the most recent release, `breaking` branch
|
||||||
|
gets merged into `develop` which automatically results in a switch to the newer version-specific
|
||||||
|
branches if they exist. If no changes on our part were necessary, it is completely fine to keep using
|
||||||
|
e.g. the `master_060` of an external project in in Solidity 0.8.x.
|
||||||
|
|
||||||
|
Since each project is handled separately, this approach may result in a mix of version-specific branches
|
||||||
|
between different external projects. For example, in one project we could could have `master_050` on
|
||||||
|
both `develop` and `breaking` and in another `breaking` could use `master_080` while `develop` still
|
||||||
|
uses `master_060`.
|
@ -257,7 +257,7 @@ void ASTJSONTest::printSource(ostream& _stream, string const& _linePrefix, bool
|
|||||||
for (auto const& source: m_sources)
|
for (auto const& source: m_sources)
|
||||||
{
|
{
|
||||||
if (m_sources.size() > 1 || source.first != "a")
|
if (m_sources.size() > 1 || source.first != "a")
|
||||||
_stream << _linePrefix << sourceDelimiter << source.first << endl << endl;
|
_stream << _linePrefix << sourceDelimiter << source.first << " ====" << endl << endl;
|
||||||
stringstream stream(source.second);
|
stringstream stream(source.second);
|
||||||
string line;
|
string line;
|
||||||
while (getline(stream, line))
|
while (getline(stream, line))
|
||||||
|
@ -91,7 +91,7 @@ evmasm::AssemblyItems compileContract(std::shared_ptr<CharStream> _sourceCode)
|
|||||||
);
|
);
|
||||||
compiler.compileContract(*contract, map<ContractDefinition const*, shared_ptr<Compiler const>>{}, bytes());
|
compiler.compileContract(*contract, map<ContractDefinition const*, shared_ptr<Compiler const>>{}, bytes());
|
||||||
|
|
||||||
return compiler.runtimeAssemblyItems();
|
return compiler.runtimeAssembly().items();
|
||||||
}
|
}
|
||||||
BOOST_FAIL("No contract found in source.");
|
BOOST_FAIL("No contract found in source.");
|
||||||
return AssemblyItems();
|
return AssemblyItems();
|
||||||
|
@ -38,6 +38,9 @@ namespace solidity::frontend::test
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE(SemVerMatcher)
|
BOOST_AUTO_TEST_SUITE(SemVerMatcher)
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
SemVerMatchExpression parseExpression(string const& _input)
|
SemVerMatchExpression parseExpression(string const& _input)
|
||||||
{
|
{
|
||||||
Scanner scanner{CharStream(_input, "")};
|
Scanner scanner{CharStream(_input, "")};
|
||||||
@ -62,6 +65,8 @@ SemVerMatchExpression parseExpression(string const& _input)
|
|||||||
return expression;
|
return expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(positive_range)
|
BOOST_AUTO_TEST_CASE(positive_range)
|
||||||
{
|
{
|
||||||
// Positive range tests
|
// Positive range tests
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include <libsolidity/ast/TypeProvider.h>
|
#include <libsolidity/ast/TypeProvider.h>
|
||||||
#include <libsolidity/analysis/TypeChecker.h>
|
#include <libsolidity/analysis/TypeChecker.h>
|
||||||
#include <liblangutil/ErrorReporter.h>
|
#include <liblangutil/ErrorReporter.h>
|
||||||
|
#include <libevmasm/LinkerObject.h>
|
||||||
#include <test/Common.h>
|
#include <test/Common.h>
|
||||||
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
@ -161,7 +162,10 @@ bytes compileFirstExpression(
|
|||||||
context << context.functionEntryLabel(dynamic_cast<FunctionDefinition const&>(
|
context << context.functionEntryLabel(dynamic_cast<FunctionDefinition const&>(
|
||||||
resolveDeclaration(*sourceUnit, function, resolver)
|
resolveDeclaration(*sourceUnit, function, resolver)
|
||||||
));
|
));
|
||||||
bytes instructions = context.assembledObject().bytecode;
|
BOOST_REQUIRE(context.assemblyPtr());
|
||||||
|
LinkerObject const& object = context.assemblyPtr()->assemble();
|
||||||
|
BOOST_REQUIRE(object.immutableReferences.empty());
|
||||||
|
bytes instructions = object.bytecode;
|
||||||
// debug
|
// debug
|
||||||
// cout << evmasm::disassemble(instructions) << endl;
|
// cout << evmasm::disassemble(instructions) << endl;
|
||||||
return instructions;
|
return instructions;
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
contract c {
|
||||||
|
bytes a;
|
||||||
|
bytes b;
|
||||||
|
function f(uint len) public returns (bytes memory) {
|
||||||
|
bytes memory x = new bytes(len);
|
||||||
|
for (uint i = 0; i < len; i++)
|
||||||
|
x[i] = byte(uint8(i));
|
||||||
|
a = x;
|
||||||
|
for (uint i = 0; i < len; i++)
|
||||||
|
assert(a[i] == x[i]);
|
||||||
|
b = a;
|
||||||
|
for (uint i = 0; i < len; i++)
|
||||||
|
assert(b[i] == x[i]);
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ====
|
||||||
|
// compileViaYul: also
|
||||||
|
// ----
|
||||||
|
// f(uint256): 0 -> 0x20, 0x00
|
||||||
|
// f(uint256): 31 -> 0x20, 0x1f, 0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e00
|
||||||
|
// f(uint256): 32 -> 0x20, 0x20, 1780731860627700044960722568376592200742329637303199754547598369979440671
|
||||||
|
// f(uint256): 33 -> 0x20, 33, 1780731860627700044960722568376592200742329637303199754547598369979440671, 0x2000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
// f(uint256): 63 -> 0x20, 0x3f, 1780731860627700044960722568376592200742329637303199754547598369979440671, 14532552714582660066924456880521368950258152170031413196862950297402215316992
|
||||||
|
// f(uint256): 12 -> 0x20, 0x0c, 0x0102030405060708090a0b0000000000000000000000000000000000000000
|
||||||
|
// f(uint256): 129 -> 0x20, 0x81, 1780731860627700044960722568376592200742329637303199754547598369979440671, 0x202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f, 29063324697304692433803953038474361308315562010425523193971352996434451193439, 0x606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f, -57896044618658097711785492504343953926634992332820282019728792003956564819968
|
@ -9,3 +9,5 @@ contract C {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// ----
|
||||||
|
// Warning 4984: (112-115): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
|
||||||
|
@ -11,4 +11,5 @@ contract C {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
|
// Warning 4984: (112-115): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
|
||||||
// Warning 2529: (150-157): CHC: Empty array "pop" happens here.\nCounterexample:\na = []\nl = 0\n\n\nTransaction trace:\nconstructor()\nState: a = []\nf(0)
|
// Warning 2529: (150-157): CHC: Empty array "pop" happens here.\nCounterexample:\na = []\nl = 0\n\n\nTransaction trace:\nconstructor()\nState: a = []\nf(0)
|
||||||
|
@ -11,3 +11,5 @@ contract C {
|
|||||||
assert(x[0] == 42);
|
assert(x[0] == 42);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// ----
|
||||||
|
// Warning 4984: (174-177): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
pragma experimental SMTChecker;
|
||||||
|
contract C {
|
||||||
|
uint8 x;
|
||||||
|
|
||||||
|
function inc_pre() public {
|
||||||
|
++x;
|
||||||
|
}
|
||||||
|
|
||||||
|
function dec_pre() public {
|
||||||
|
--x;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Commented out because Spacer segfaults in Z3 4.8.9
|
||||||
|
function inc_post() public {
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
|
||||||
|
function dec_post() public {
|
||||||
|
x--;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
||||||
|
// ====
|
||||||
|
// SMTEngine: bmc
|
||||||
|
// ----
|
||||||
|
// Warning 2661: (87-90): BMC: Overflow (resulting value larger than 255) happens here.
|
||||||
|
// Warning 4144: (127-130): BMC: Underflow (resulting value less than 0) happens here.
|
@ -19,4 +19,3 @@ contract C {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning 2661: (158-161): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
|
||||||
|
@ -23,4 +23,3 @@ contract C {
|
|||||||
// Warning 6328: (274-300): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
|
// Warning 6328: (274-300): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
|
||||||
// Warning 6328: (304-330): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
|
// Warning 6328: (304-330): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
|
||||||
// Warning 6328: (334-362): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
|
// Warning 6328: (334-362): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
|
||||||
// Warning 2661: (158-161): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
|
||||||
|
@ -28,4 +28,3 @@ contract C {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning 2661: (188-191): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
|
||||||
|
@ -38,4 +38,3 @@ contract C {
|
|||||||
// Warning 6328: (437-458): CHC: Assertion violation happens here.
|
// Warning 6328: (437-458): CHC: Assertion violation happens here.
|
||||||
// Warning 6328: (462-490): CHC: Assertion violation happens here.
|
// Warning 6328: (462-490): CHC: Assertion violation happens here.
|
||||||
// Warning 6328: (494-517): CHC: Assertion violation happens here.
|
// Warning 6328: (494-517): CHC: Assertion violation happens here.
|
||||||
// Warning 2661: (188-191): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
|
||||||
|
@ -18,5 +18,6 @@ contract C {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning 6328: (189-203): CHC: Assertion violation happens here.\nCounterexample:\nx = 10, d = 0\n\n\n\nTransaction trace:\nconstructor()\nState: x = 0, d = 0\ninc()\nState: x = 1, d = 0\ninc()\nState: x = 2, d = 0\nf()
|
// Warning 4984: (146-149): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
|
||||||
|
// Warning 6328: (189-203): CHC: Assertion violation happens here.\nCounterexample:\nx = 10, d = 0\n\n\n\nTransaction trace:\nconstructor()\nState: x = 0, d = 0\ninc()\nState: x = 1, d = 0\nf()
|
||||||
// Warning 2661: (146-149): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
// Warning 2661: (146-149): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
||||||
|
@ -16,3 +16,6 @@ contract C {
|
|||||||
assert(x < 11);
|
assert(x < 11);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// ----
|
||||||
|
// Warning 6328: (200-214): CHC: Assertion violation might happen here.
|
||||||
|
// Warning 4661: (200-214): BMC: Assertion violation happens here.
|
||||||
|
@ -21,5 +21,3 @@ contract C{
|
|||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning 5667: (70-76): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
// Warning 5667: (70-76): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
||||||
// Warning 2661: (156-159): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
|
||||||
// Warning 4144: (238-241): BMC: Underflow (resulting value less than 0) happens here.
|
|
||||||
|
@ -26,5 +26,3 @@ contract C{
|
|||||||
// Warning 6328: (220-234): CHC: Assertion violation happens here.\nCounterexample:\nx = 2\n\n\n\nTransaction trace:\nconstructor(0)\nState: x = 1\nf()
|
// Warning 6328: (220-234): CHC: Assertion violation happens here.\nCounterexample:\nx = 2\n\n\n\nTransaction trace:\nconstructor(0)\nState: x = 1\nf()
|
||||||
// Warning 6328: (245-259): CHC: Assertion violation happens here.\nCounterexample:\nx = 1\n\n\n\nTransaction trace:\nconstructor(0)\nState: x = 1\nf()
|
// Warning 6328: (245-259): CHC: Assertion violation happens here.\nCounterexample:\nx = 1\n\n\n\nTransaction trace:\nconstructor(0)\nState: x = 1\nf()
|
||||||
// Warning 6328: (82-96): CHC: Assertion violation happens here.\nCounterexample:\nx = 0\ny = 0\n\n\nTransaction trace:\nconstructor(0)
|
// Warning 6328: (82-96): CHC: Assertion violation happens here.\nCounterexample:\nx = 0\ny = 0\n\n\nTransaction trace:\nconstructor(0)
|
||||||
// Warning 2661: (156-159): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
|
||||||
// Warning 4144: (238-241): BMC: Underflow (resulting value less than 0) happens here.
|
|
||||||
|
@ -17,5 +17,3 @@ contract C is A {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning 4144: (100-103): BMC: Underflow (resulting value less than 0) happens here.
|
|
||||||
// Warning 4144: (100-103): BMC: Underflow (resulting value less than 0) happens here.
|
|
||||||
|
@ -20,5 +20,3 @@ contract C is A {
|
|||||||
// Warning 6328: (82-96): CHC: Assertion violation happens here.\nCounterexample:\nx = 1\n\n\n\nTransaction trace:\nconstructor()
|
// Warning 6328: (82-96): CHC: Assertion violation happens here.\nCounterexample:\nx = 1\n\n\n\nTransaction trace:\nconstructor()
|
||||||
// Warning 6328: (148-162): CHC: Assertion violation happens here.\nCounterexample:\nx = 0\n\n\n\nTransaction trace:\nconstructor()
|
// Warning 6328: (148-162): CHC: Assertion violation happens here.\nCounterexample:\nx = 0\n\n\n\nTransaction trace:\nconstructor()
|
||||||
// Warning 6328: (180-194): CHC: Assertion violation happens here.\nCounterexample:\nx = 0\n\n\n\nTransaction trace:\nconstructor()
|
// Warning 6328: (180-194): CHC: Assertion violation happens here.\nCounterexample:\nx = 0\n\n\n\nTransaction trace:\nconstructor()
|
||||||
// Warning 4144: (100-103): BMC: Underflow (resulting value less than 0) happens here.
|
|
||||||
// Warning 4144: (100-103): BMC: Underflow (resulting value less than 0) happens here.
|
|
||||||
|
@ -21,7 +21,3 @@ contract C{
|
|||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning 5667: (70-76): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
// Warning 5667: (70-76): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
||||||
// Warning 2661: (156-159): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
|
||||||
// Warning 2661: (163-166): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
|
||||||
// Warning 2661: (234-237): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
|
||||||
// Warning 4144: (234-237): BMC: Underflow (resulting value less than 0) happens here.
|
|
||||||
|
@ -24,7 +24,3 @@ contract C{
|
|||||||
// Warning 6328: (138-152): CHC: Assertion violation happens here.\nCounterexample:\nx = 1\n\n\n\nTransaction trace:\nconstructor(0)\nState: x = 1\nf()
|
// Warning 6328: (138-152): CHC: Assertion violation happens here.\nCounterexample:\nx = 1\n\n\n\nTransaction trace:\nconstructor(0)\nState: x = 1\nf()
|
||||||
// Warning 6328: (184-198): CHC: Assertion violation happens here.\nCounterexample:\nx = 1\n\n\n\nTransaction trace:\nconstructor(0)\nState: x = 1\nf()
|
// Warning 6328: (184-198): CHC: Assertion violation happens here.\nCounterexample:\nx = 1\n\n\n\nTransaction trace:\nconstructor(0)\nState: x = 1\nf()
|
||||||
// Warning 6328: (82-96): CHC: Assertion violation happens here.\nCounterexample:\nx = 0\ny = 0\n\n\nTransaction trace:\nconstructor(0)
|
// Warning 6328: (82-96): CHC: Assertion violation happens here.\nCounterexample:\nx = 0\ny = 0\n\n\nTransaction trace:\nconstructor(0)
|
||||||
// Warning 2661: (156-159): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
|
||||||
// Warning 2661: (163-166): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
|
||||||
// Warning 2661: (234-237): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
|
||||||
// Warning 4144: (234-237): BMC: Underflow (resulting value less than 0) happens here.
|
|
||||||
|
@ -20,6 +20,7 @@ contract Der is Base {
|
|||||||
// ----
|
// ----
|
||||||
// Warning 4984: (der:101-109): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
|
// Warning 4984: (der:101-109): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
|
||||||
// Warning 6328: (der:113-126): CHC: Assertion violation happens here.\nCounterexample:\nx = 3, a = 0\ny = 0\n\n\nTransaction trace:\nconstructor()\nState: x = 0, a = 0\ng(0)
|
// Warning 6328: (der:113-126): CHC: Assertion violation happens here.\nCounterexample:\nx = 3, a = 0\ny = 0\n\n\nTransaction trace:\nconstructor()\nState: x = 0, a = 0\ng(0)
|
||||||
|
// Warning 4984: (base:100-103): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
|
||||||
// Warning 2661: (base:100-103): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
// Warning 2661: (base:100-103): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
||||||
// Warning 2661: (der:101-109): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
// Warning 2661: (der:101-109): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
||||||
// Warning 2661: (base:100-103): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
// Warning 2661: (base:100-103): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
||||||
|
@ -11,3 +11,5 @@ contract Simple {
|
|||||||
}
|
}
|
||||||
// ====
|
// ====
|
||||||
// SMTSolvers: z3
|
// SMTSolvers: z3
|
||||||
|
// ----
|
||||||
|
// Warning 4984: (132-135): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
|
||||||
|
@ -9,3 +9,5 @@ contract Simple {
|
|||||||
}
|
}
|
||||||
// ====
|
// ====
|
||||||
// SMTSolvers: z3
|
// SMTSolvers: z3
|
||||||
|
// ----
|
||||||
|
// Warning 4984: (116-119): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
|
||||||
|
@ -15,4 +15,4 @@ contract C
|
|||||||
// SMTSolvers: z3
|
// SMTSolvers: z3
|
||||||
// ----
|
// ----
|
||||||
// Warning 5740: (120-123): Unreachable code.
|
// Warning 5740: (120-123): Unreachable code.
|
||||||
// Warning 6328: (131-145): CHC: Assertion violation happens here.\nCounterexample:\n\nx = 1\n\n\nTransaction trace:\nconstructor()\nf(1)
|
// Warning 6328: (131-145): CHC: Assertion violation happens here.\nCounterexample:\n\nx = 3\n\n\nTransaction trace:\nconstructor()\nf(3)
|
||||||
|
@ -18,9 +18,10 @@ contract LoopFor2 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ====
|
// ====
|
||||||
// SMTSolvers: z3
|
|
||||||
// SMTIgnoreCex: yes
|
// SMTIgnoreCex: yes
|
||||||
|
// SMTSolvers: z3
|
||||||
// ----
|
// ----
|
||||||
// Warning 4984: (244-249): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
|
// Warning 4984: (244-249): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
|
||||||
|
// Warning 4984: (270-273): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
|
||||||
// Warning 6328: (373-392): CHC: Assertion violation happens here.
|
// Warning 6328: (373-392): CHC: Assertion violation happens here.
|
||||||
// Warning 6328: (396-415): CHC: Assertion violation happens here.
|
// Warning 6328: (396-415): CHC: Assertion violation happens here.
|
||||||
|
@ -26,3 +26,4 @@ contract LoopFor2 {
|
|||||||
// SMTSolvers: z3
|
// SMTSolvers: z3
|
||||||
// ----
|
// ----
|
||||||
// Warning 4984: (237-242): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
|
// Warning 4984: (237-242): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
|
||||||
|
// Warning 4984: (263-266): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
|
||||||
|
@ -21,5 +21,6 @@ contract LoopFor2 {
|
|||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning 4984: (229-234): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
|
// Warning 4984: (229-234): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
|
||||||
|
// Warning 4984: (255-258): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
|
||||||
// Warning 6328: (338-357): CHC: Assertion violation happens here.\nCounterexample:\nb = [], c = []\nn = 1\n\n\nTransaction trace:\nconstructor()\nState: b = [], c = []\ntestUnboundedForLoop(1)
|
// Warning 6328: (338-357): CHC: Assertion violation happens here.\nCounterexample:\nb = [], c = []\nn = 1\n\n\nTransaction trace:\nconstructor()\nState: b = [], c = []\ntestUnboundedForLoop(1)
|
||||||
// Warning 6328: (361-380): CHC: Assertion violation happens here.\nCounterexample:\nb = [], c = []\nn = 1\n\n\nTransaction trace:\nconstructor()\nState: b = [], c = []\ntestUnboundedForLoop(1)
|
// Warning 6328: (361-380): CHC: Assertion violation happens here.\nCounterexample:\nb = [], c = []\nn = 1\n\n\nTransaction trace:\nconstructor()\nState: b = [], c = []\ntestUnboundedForLoop(1)
|
||||||
|
@ -7,7 +7,7 @@ contract A {
|
|||||||
A.y = A.x++;
|
A.y = A.x++;
|
||||||
assert(A.y == A.x - 1);
|
assert(A.y == A.x - 1);
|
||||||
// Fails
|
// Fails
|
||||||
assert(A.y == 0);
|
// assert(A.y == 0); // Disabled because of nondeterminism in Spacer
|
||||||
A.y = ++A.x;
|
A.y = ++A.x;
|
||||||
assert(A.y == A.x);
|
assert(A.y == A.x);
|
||||||
delete A.x;
|
delete A.x;
|
||||||
@ -25,6 +25,7 @@ contract A {
|
|||||||
assert(A.y == A.x);
|
assert(A.y == A.x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// ====
|
||||||
|
// SMTIgnoreCex: yes
|
||||||
// ----
|
// ----
|
||||||
// Warning 6328: (160-176): CHC: Assertion violation happens here.\nCounterexample:\nx = (- 1), y = (- 2)\n\n\n\nTransaction trace:\nconstructor()\nState: x = 0, y = 0\na()\nState: x = (- 2), y = (- 2)\na()
|
// Warning 6328: (424-440): CHC: Assertion violation happens here.
|
||||||
// Warning 6328: (373-389): CHC: Assertion violation happens here.\nCounterexample:\nx = 8, y = (- 2)\n\n\n\nTransaction trace:\nconstructor()\nState: x = 0, y = 0\na()
|
|
||||||
|
@ -10,4 +10,4 @@ contract C {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning 6328: (161-174): CHC: Assertion violation happens here.\nCounterexample:\n\na = 6\nb = 5\n\n\nTransaction trace:\nconstructor()\nf(5, 5)
|
// Warning 6328: (161-174): CHC: Assertion violation happens here.\nCounterexample:\n\na = 0\nb = 1\n\n\nTransaction trace:\nconstructor()\nf(0, 0)
|
||||||
|
@ -10,3 +10,6 @@ contract C {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
|
// Warning 4984: (129-134): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.\nCounterexample:\na = 115792089237316195423570985008687907853269984665640564039457584007913129639935, b = false\n\nc = 0\n\nTransaction trace:\nconstructor()\nState: a = 0, b = false\nf()\nState: a = 115792089237316195423570985008687907853269984665640564039457584007913129639935, b = false\nf()
|
||||||
|
// Warning 3944: (137-140): CHC: Underflow (resulting value less than 0) happens here.\nCounterexample:\na = 0, b = false\n\nc = 0\n\nTransaction trace:\nconstructor()\nState: a = 0, b = false\nf()
|
||||||
|
// Warning 6328: (150-163): CHC: Assertion violation happens here.\nCounterexample:\na = 115792089237316195423570985008687907853269984665640564039457584007913129639935, b = false\n\nc = 0\n\nTransaction trace:\nconstructor()\nState: a = 0, b = false\nf()
|
||||||
|
@ -15,4 +15,4 @@ contract C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning 6328: (240-253): CHC: Assertion violation happens here.\nCounterexample:\narray = []\nx = 38\n\n\nTransaction trace:\nconstructor()\nState: array = []\nf(38)
|
// Warning 6328: (240-253): CHC: Assertion violation happens here.
|
||||||
|
@ -14,5 +14,7 @@ contract C
|
|||||||
assert(b < 3);
|
assert(b < 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// ====
|
||||||
|
// SMTIgnoreCex: yes
|
||||||
// ----
|
// ----
|
||||||
// Warning 6328: (244-257): CHC: Assertion violation happens here.\nCounterexample:\n\nx = 38\n\n\nTransaction trace:\nconstructor()\nf(38)
|
// Warning 6328: (244-257): CHC: Assertion violation happens here.
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
pragma experimental SMTChecker;
|
||||||
|
contract C {
|
||||||
|
uint8 x;
|
||||||
|
|
||||||
|
function inc_pre() public {
|
||||||
|
++x;
|
||||||
|
}
|
||||||
|
|
||||||
|
function dec_pre() public {
|
||||||
|
--x;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Commented out because Spacer segfaults in Z3 4.8.9
|
||||||
|
function inc_post() public {
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
|
||||||
|
function dec_post() public {
|
||||||
|
x--;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// Warning 4984: (87-90): CHC: Overflow (resulting value larger than 255) happens here.\nCounterexample:\nx = 255\n\n\n\nTransaction trace:\nconstructor()\nState: x = 0\ndec_pre()\nState: x = 255\ninc_pre()
|
||||||
|
// Warning 3944: (127-130): CHC: Underflow (resulting value less than 0) happens here.\nCounterexample:\nx = 0\n\n\n\nTransaction trace:\nconstructor()\nState: x = 0\ndec_pre()
|
@ -0,0 +1,16 @@
|
|||||||
|
pragma experimental SMTChecker;
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
uint8 x = 254;
|
||||||
|
|
||||||
|
function inc_pre() public {
|
||||||
|
++x;
|
||||||
|
}
|
||||||
|
|
||||||
|
function check() view public {
|
||||||
|
uint y = x;
|
||||||
|
assert(y < 256);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// Warning 4984: (94-97): CHC: Overflow (resulting value larger than 255) happens here.\nCounterexample:\nx = 255\n\n\n\nTransaction trace:\nconstructor()\nState: x = 254\ninc_pre()\nState: x = 255\ninc_pre()
|
@ -0,0 +1,24 @@
|
|||||||
|
pragma experimental SMTChecker;
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
struct S {
|
||||||
|
uint8 x;
|
||||||
|
}
|
||||||
|
|
||||||
|
S s;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
s.x = 254;
|
||||||
|
}
|
||||||
|
|
||||||
|
function inc_pre() public {
|
||||||
|
++s.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
function check() view public {
|
||||||
|
uint y = s.x;
|
||||||
|
assert(y < 256);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// Warning 4984: (145-150): CHC: Overflow (resulting value larger than 255) happens here.\nCounterexample:\ns = {x: 255}\n\n\n\nTransaction trace:\nconstructor()\nState: s = {x: 254}\ninc_pre()\nState: s = {x: 255}\ninc_pre()
|
@ -15,4 +15,4 @@ contract C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning 6328: (240-253): CHC: Assertion violation happens here.\nCounterexample:\narray = []\nx = 38\n\n\nTransaction trace:\nconstructor()\nState: array = []\nf(38)
|
// Warning 6328: (240-253): CHC: Assertion violation happens here.\nCounterexample:\narray = []\nx = 0\n\n\nTransaction trace:\nconstructor()\nState: array = []\nf(0)
|
||||||
|
@ -15,4 +15,4 @@ contract C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning 6328: (244-257): CHC: Assertion violation happens here.\nCounterexample:\n\nx = 38\n\n\nTransaction trace:\nconstructor()\nf(38)
|
// Warning 6328: (244-257): CHC: Assertion violation happens here.\nCounterexample:\n\nx = 0\n\n\nTransaction trace:\nconstructor()\nf(0)
|
||||||
|
@ -52,6 +52,10 @@ contract C {
|
|||||||
// Warning 8364: (258-260): Assertion checker does not yet implement type struct C.S storage ref
|
// Warning 8364: (258-260): Assertion checker does not yet implement type struct C.S storage ref
|
||||||
// Warning 7650: (271-275): Assertion checker does not yet support this expression.
|
// Warning 7650: (271-275): Assertion checker does not yet support this expression.
|
||||||
// Warning 8364: (271-273): Assertion checker does not yet implement type struct C.S storage ref
|
// Warning 8364: (271-273): Assertion checker does not yet implement type struct C.S storage ref
|
||||||
|
// Warning 4984: (132-138): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
|
||||||
|
// Warning 4984: (142-148): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
|
||||||
|
// Warning 3944: (165-171): CHC: Underflow (resulting value less than 0) happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
|
||||||
|
// Warning 3944: (175-181): CHC: Underflow (resulting value less than 0) happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
|
||||||
// Warning 4984: (200-208): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
|
// Warning 4984: (200-208): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
|
||||||
// Warning 6328: (185-209): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
|
// Warning 6328: (185-209): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
|
||||||
// Warning 6328: (213-247): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
|
// Warning 6328: (213-247): CHC: Assertion violation happens here.\nCounterexample:\n\n\n\n\nTransaction trace:\nconstructor()\nf()
|
||||||
@ -87,11 +91,3 @@ contract C {
|
|||||||
// Warning 8364: (258-260): Assertion checker does not yet implement type struct C.S storage ref
|
// Warning 8364: (258-260): Assertion checker does not yet implement type struct C.S storage ref
|
||||||
// Warning 7650: (271-275): Assertion checker does not yet support this expression.
|
// Warning 7650: (271-275): Assertion checker does not yet support this expression.
|
||||||
// Warning 8364: (271-273): Assertion checker does not yet implement type struct C.S storage ref
|
// Warning 8364: (271-273): Assertion checker does not yet implement type struct C.S storage ref
|
||||||
// Warning 4144: (132-138): BMC: Underflow (resulting value less than 0) happens here.
|
|
||||||
// Warning 2661: (132-138): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
|
||||||
// Warning 4144: (142-148): BMC: Underflow (resulting value less than 0) happens here.
|
|
||||||
// Warning 2661: (142-148): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
|
||||||
// Warning 4144: (165-171): BMC: Underflow (resulting value less than 0) happens here.
|
|
||||||
// Warning 2661: (165-171): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
|
||||||
// Warning 4144: (175-181): BMC: Underflow (resulting value less than 0) happens here.
|
|
||||||
// Warning 2661: (175-181): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
|
|
||||||
|
@ -15,4 +15,4 @@ contract C {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning 6328: (225-245): CHC: Assertion violation happens here.\nCounterexample:\n\ns1 = {x: 2, a: []}\ns2 = {x: 3, a: [5, 5, 5, 5, 5, 5]}\n\n\nTransaction trace:\nconstructor()\nf({x: 0, a: []}, {x: 3, a: [5, 5, 5, 5, 5, 5]})
|
// Warning 6328: (225-245): CHC: Assertion violation happens here.\nCounterexample:\n\ns1 = {x: 2, a: []}\ns2 = {x: 3, a: [6, 6, 6, 6, 6, 6, 6]}\n\n\nTransaction trace:\nconstructor()\nf({x: 0, a: []}, {x: 3, a: [6, 6, 6, 6, 6, 6, 6]})
|
||||||
|
@ -16,4 +16,4 @@ contract C {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning 6328: (240-260): CHC: Assertion violation happens here.\nCounterexample:\n\ns1 = {x: 98, a: []}\ns2 = {x: (- 38), a: [5, 5, 5, 5, 5, 5]}\n\n\nTransaction trace:\nconstructor()\nf({x: 0, a: []}, {x: (- 38), a: [5, 5, 5, 5, 5, 5]})
|
// Warning 6328: (240-260): CHC: Assertion violation happens here.\nCounterexample:\n\ns1 = {x: 98, a: []}\ns2 = {x: 99, a: [6, 6, 6, 6, 6, 6, 6]}\n\n\nTransaction trace:\nconstructor()\nf({x: 0, a: []}, {x: 99, a: [6, 6, 6, 6, 6, 6, 6]})
|
||||||
|
@ -12,6 +12,7 @@ contract C {
|
|||||||
if(x == 0) x = 0; // noop state var read
|
if(x == 0) x = 0; // noop state var read
|
||||||
x++;
|
x++;
|
||||||
y++;
|
y++;
|
||||||
assert(y == x);
|
// Commented out because of nondeterminism in Spacer in Z3 4.8.9
|
||||||
|
//assert(y == x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,4 +22,4 @@ contract Test {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// TypeError 9574: (B:269-313): Type function (struct L.Item memory) is not implicitly convertible to expected type function (struct L.Item memory) external.
|
// TypeError 9574: (B:269-313): Type function (struct L.Item memory) is not implicitly convertible to expected type function (struct L.Item memory) external. Special functions can not be converted to function types.
|
||||||
|
@ -30,6 +30,6 @@ contract E {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// TypeError 9553: (140-143): Invalid type for argument in function call. Invalid implicit conversion from function () to function () external requested.
|
// TypeError 9553: (140-143): Invalid type for argument in function call. Invalid implicit conversion from function () to function () external requested. Special functions can not be converted to function types.
|
||||||
// TypeError 9553: (230-233): Invalid type for argument in function call. Invalid implicit conversion from function () to function () external requested.
|
// TypeError 9553: (230-233): Invalid type for argument in function call. Invalid implicit conversion from function () to function () external requested. Special functions can not be converted to function types.
|
||||||
// TypeError 9553: (345-348): Invalid type for argument in function call. Invalid implicit conversion from function D.f() to function () external requested.
|
// TypeError 9553: (345-348): Invalid type for argument in function call. Invalid implicit conversion from function D.f() to function () external requested. Special functions can not be converted to function types.
|
||||||
|
15
test/libsolidity/syntaxTests/functionTypes/assign_bound.sol
Normal file
15
test/libsolidity/syntaxTests/functionTypes/assign_bound.sol
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
library L {
|
||||||
|
function foo(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||||
|
return a + b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
contract C {
|
||||||
|
using L for uint256;
|
||||||
|
|
||||||
|
function bar() public {
|
||||||
|
uint256 x;
|
||||||
|
function (uint256, uint256) internal pure returns (uint256) ptr = x.foo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 9574: (209-280): Type function (uint256,uint256) pure returns (uint256) is not implicitly convertible to expected type function (uint256,uint256) pure returns (uint256). Bound functions can not be converted to non-bound functions.
|
@ -0,0 +1,7 @@
|
|||||||
|
contract C {
|
||||||
|
function f() public {
|
||||||
|
function (uint) view returns (bytes32) _blockhash = blockhash;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 9574: (42-103): Type function (uint256) view returns (bytes32) is not implicitly convertible to expected type function (uint256) view returns (bytes32). Special functions can not be converted to function types.
|
@ -10,5 +10,5 @@ contract C {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// TypeError 9553: (230-233): Invalid type for argument in function call. Invalid implicit conversion from function (uint256) returns (uint256) to function (uint256) external returns (uint256) requested.
|
// TypeError 9553: (230-233): Invalid type for argument in function call. Invalid implicit conversion from function (uint256) returns (uint256) to function (uint256) external returns (uint256) requested. Special functions can not be converted to function types.
|
||||||
// TypeError 9574: (244-305): Type function (uint256) returns (uint256) is not implicitly convertible to expected type function (uint256) external returns (uint256).
|
// TypeError 9574: (244-305): Type function (uint256) returns (uint256) is not implicitly convertible to expected type function (uint256) external returns (uint256). Special functions can not be converted to function types.
|
||||||
|
@ -3,4 +3,4 @@ contract test {
|
|||||||
function(bytes memory) external internal a = fa;
|
function(bytes memory) external internal a = fa;
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// TypeError 7407: (106-108): Type function (bytes memory) is not implicitly convertible to expected type function (bytes memory) external.
|
// TypeError 7407: (106-108): Type function (bytes memory) is not implicitly convertible to expected type function (bytes memory) external. Special functions can not be converted to function types.
|
||||||
|
@ -9,5 +9,5 @@ contract C {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// TypeError 9574: (218-271): Type function (struct D.s storage pointer,uint256) returns (uint256) is not implicitly convertible to expected type function (struct D.s storage pointer,uint256) returns (uint256).
|
// TypeError 9574: (218-271): Type function (struct D.s storage pointer,uint256) returns (uint256) is not implicitly convertible to expected type function (struct D.s storage pointer,uint256) returns (uint256). Bound functions can not be converted to non-bound functions.
|
||||||
// TypeError 6160: (298-302): Wrong argument count for function call: 1 arguments given but expected 2.
|
// TypeError 6160: (298-302): Wrong argument count for function call: 1 arguments given but expected 2.
|
||||||
|
@ -10,5 +10,5 @@ contract B is A {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// TypeError 9574: (133-160): Type function A.f() is not implicitly convertible to expected type function () external.
|
// TypeError 9574: (133-160): Type function A.f() is not implicitly convertible to expected type function () external. Special functions can not be converted to function types.
|
||||||
// TypeError 9574: (170-202): Type function A.g() pure is not implicitly convertible to expected type function () pure external.
|
// TypeError 9574: (170-202): Type function A.g() pure is not implicitly convertible to expected type function () pure external. Special functions can not be converted to function types.
|
||||||
|
@ -10,5 +10,5 @@ contract B {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// TypeError 9574: (128-155): Type function A.f() is not implicitly convertible to expected type function () external.
|
// TypeError 9574: (128-155): Type function A.f() is not implicitly convertible to expected type function () external. Special functions can not be converted to function types.
|
||||||
// TypeError 9574: (165-197): Type function A.g() pure is not implicitly convertible to expected type function () pure external.
|
// TypeError 9574: (165-197): Type function A.g() pure is not implicitly convertible to expected type function () pure external. Special functions can not be converted to function types.
|
||||||
|
@ -39,6 +39,9 @@ namespace solidity::frontend::test
|
|||||||
using fmt = ExecutionFramework;
|
using fmt = ExecutionFramework;
|
||||||
using Mode = FunctionCall::DisplayMode;
|
using Mode = FunctionCall::DisplayMode;
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
vector<FunctionCall> parse(string const& _source)
|
vector<FunctionCall> parse(string const& _source)
|
||||||
{
|
{
|
||||||
istringstream stream{_source, ios_base::out};
|
istringstream stream{_source, ios_base::out};
|
||||||
@ -86,6 +89,8 @@ void testFunctionCall(
|
|||||||
BOOST_REQUIRE_EQUAL(_call.kind == FunctionCall::Kind::Library, _isLibrary);
|
BOOST_REQUIRE_EQUAL(_call.kind == FunctionCall::Kind::Library, _isLibrary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE(TestFileParserTest)
|
BOOST_AUTO_TEST_SUITE(TestFileParserTest)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(smoke_test)
|
BOOST_AUTO_TEST_CASE(smoke_test)
|
||||||
|
272
test/libsolutil/FixedHash.cpp
Normal file
272
test/libsolutil/FixedHash.cpp
Normal file
@ -0,0 +1,272 @@
|
|||||||
|
/*
|
||||||
|
This file is part of solidity.
|
||||||
|
|
||||||
|
solidity is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
solidity is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Unit tests for FixedHash.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <libsolutil/FixedHash.h>
|
||||||
|
|
||||||
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
namespace solidity::util::test
|
||||||
|
{
|
||||||
|
|
||||||
|
static_assert(std::is_same<h160, FixedHash<20>>());
|
||||||
|
static_assert(std::is_same<h256, FixedHash<32>>());
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_SUITE(FixedHashTest)
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(default_constructor)
|
||||||
|
{
|
||||||
|
BOOST_CHECK_EQUAL(
|
||||||
|
FixedHash<1>{}.hex(),
|
||||||
|
"00"
|
||||||
|
);
|
||||||
|
BOOST_CHECK_EQUAL(
|
||||||
|
FixedHash<1>{}.size,
|
||||||
|
1
|
||||||
|
);
|
||||||
|
BOOST_CHECK_EQUAL(
|
||||||
|
FixedHash<8>{}.hex(),
|
||||||
|
"0000000000000000"
|
||||||
|
);
|
||||||
|
BOOST_CHECK_EQUAL(
|
||||||
|
FixedHash<8>{}.size,
|
||||||
|
8
|
||||||
|
);
|
||||||
|
BOOST_CHECK_EQUAL(
|
||||||
|
FixedHash<20>{}.hex(),
|
||||||
|
"0000000000000000000000000000000000000000"
|
||||||
|
);
|
||||||
|
BOOST_CHECK_EQUAL(
|
||||||
|
FixedHash<20>{}.size,
|
||||||
|
20
|
||||||
|
);
|
||||||
|
BOOST_CHECK_EQUAL(
|
||||||
|
FixedHash<32>{}.hex(),
|
||||||
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
|
);
|
||||||
|
BOOST_CHECK_EQUAL(
|
||||||
|
FixedHash<32>{}.size,
|
||||||
|
32
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(bytes_constructor)
|
||||||
|
{
|
||||||
|
FixedHash<8> a(bytes{});
|
||||||
|
BOOST_CHECK_EQUAL(a.size, 8);
|
||||||
|
BOOST_CHECK_EQUAL(a.hex(), "0000000000000000");
|
||||||
|
|
||||||
|
FixedHash<8> b(bytes{0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88});
|
||||||
|
BOOST_CHECK_EQUAL(b.size, 8);
|
||||||
|
BOOST_CHECK_EQUAL(b.hex(), "1122334455667788");
|
||||||
|
|
||||||
|
// TODO: short input, this should fail
|
||||||
|
FixedHash<8> c(bytes{0x11, 0x22, 0x33, 0x44, 0x55, 0x66});
|
||||||
|
BOOST_CHECK_EQUAL(c.size, 8);
|
||||||
|
BOOST_CHECK_EQUAL(c.hex(), "0000000000000000");
|
||||||
|
|
||||||
|
// TODO: oversized input, this should fail
|
||||||
|
FixedHash<8> d(bytes{0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99});
|
||||||
|
BOOST_CHECK_EQUAL(d.size, 8);
|
||||||
|
BOOST_CHECK_EQUAL(d.hex(), "0000000000000000");
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: add FixedHash(bytesConstRef) constructor
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(string_constructor_fromhex)
|
||||||
|
{
|
||||||
|
// TODO: this tests the default settings ConstructFromStringType::fromHex, ConstructFromHashType::FailIfDifferent
|
||||||
|
// should test other options too
|
||||||
|
|
||||||
|
FixedHash<8> a("");
|
||||||
|
BOOST_CHECK_EQUAL(a.size, 8);
|
||||||
|
BOOST_CHECK_EQUAL(a.hex(), "0000000000000000");
|
||||||
|
|
||||||
|
FixedHash<8> b("1122334455667788");
|
||||||
|
BOOST_CHECK_EQUAL(b.size, 8);
|
||||||
|
BOOST_CHECK_EQUAL(b.hex(), "1122334455667788");
|
||||||
|
|
||||||
|
FixedHash<8> c("0x1122334455667788");
|
||||||
|
BOOST_CHECK_EQUAL(c.size, 8);
|
||||||
|
BOOST_CHECK_EQUAL(c.hex(), "1122334455667788");
|
||||||
|
|
||||||
|
// TODO: short input, this should fail
|
||||||
|
FixedHash<8> d("112233445566");
|
||||||
|
BOOST_CHECK_EQUAL(d.size, 8);
|
||||||
|
BOOST_CHECK_EQUAL(d.hex(), "0000000000000000");
|
||||||
|
|
||||||
|
// TODO: oversized input, this should fail
|
||||||
|
FixedHash<8> e("112233445566778899");
|
||||||
|
BOOST_CHECK_EQUAL(e.size, 8);
|
||||||
|
BOOST_CHECK_EQUAL(e.hex(), "0000000000000000");
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(string_constructor_frombytes)
|
||||||
|
{
|
||||||
|
|
||||||
|
FixedHash<8> b("", FixedHash<8>::FromBinary);
|
||||||
|
BOOST_CHECK_EQUAL(b.size, 8);
|
||||||
|
BOOST_CHECK_EQUAL(b.hex(), "0000000000000000");
|
||||||
|
|
||||||
|
FixedHash<8> c("abcdefgh", FixedHash<8>::FromBinary);
|
||||||
|
BOOST_CHECK_EQUAL(c.size, 8);
|
||||||
|
BOOST_CHECK_EQUAL(c.hex(), "6162636465666768");
|
||||||
|
|
||||||
|
// TODO: short input, this should fail
|
||||||
|
FixedHash<8> d("abcdefg", FixedHash<8>::FromBinary);
|
||||||
|
BOOST_CHECK_EQUAL(d.size, 8);
|
||||||
|
BOOST_CHECK_EQUAL(d.hex(), "0000000000000000");
|
||||||
|
|
||||||
|
// TODO: oversized input, this should fail
|
||||||
|
FixedHash<8> e("abcdefghi", FixedHash<8>::FromBinary);
|
||||||
|
BOOST_CHECK_EQUAL(e.size, 8);
|
||||||
|
BOOST_CHECK_EQUAL(e.hex(), "0000000000000000");
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(converting_constructor)
|
||||||
|
{
|
||||||
|
// Truncation
|
||||||
|
FixedHash<8> a = FixedHash<8>(FixedHash<12>("112233445566778899001122"));
|
||||||
|
BOOST_CHECK_EQUAL(a.size, 8);
|
||||||
|
BOOST_CHECK_EQUAL(a.hex(), "1122334455667788");
|
||||||
|
|
||||||
|
// Left-aligned extension
|
||||||
|
FixedHash<12> b = FixedHash<12>(FixedHash<8>("1122334455667788"), FixedHash<12>::AlignLeft);
|
||||||
|
BOOST_CHECK_EQUAL(b.size, 12);
|
||||||
|
BOOST_CHECK_EQUAL(b.hex(), "112233445566778800000000");
|
||||||
|
|
||||||
|
// Right-aligned extension
|
||||||
|
FixedHash<12> c = FixedHash<12>(FixedHash<8>("1122334455667788"), FixedHash<12>::AlignRight);
|
||||||
|
BOOST_CHECK_EQUAL(c.size, 12);
|
||||||
|
BOOST_CHECK_EQUAL(c.hex(), "000000001122334455667788");
|
||||||
|
|
||||||
|
// Default setting
|
||||||
|
FixedHash<12> d = FixedHash<12>(FixedHash<8>("1122334455667788"));
|
||||||
|
BOOST_CHECK_EQUAL(d, b);
|
||||||
|
|
||||||
|
// FailIfDifferent setting
|
||||||
|
// TODO: Shouldn't this throw?
|
||||||
|
FixedHash<12> e = FixedHash<12>(FixedHash<8>("1122334455667788"), FixedHash<12>::FailIfDifferent);
|
||||||
|
BOOST_CHECK_EQUAL(e, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(arith_constructor)
|
||||||
|
{
|
||||||
|
FixedHash<20> a(u160(0x1234));
|
||||||
|
BOOST_CHECK_EQUAL(
|
||||||
|
a.hex(),
|
||||||
|
"0000000000000000000000000000000000001234"
|
||||||
|
);
|
||||||
|
|
||||||
|
FixedHash<32> b(u256(0x12340000));
|
||||||
|
BOOST_CHECK_EQUAL(
|
||||||
|
b.hex(),
|
||||||
|
"0000000000000000000000000000000000000000000000000000000012340000"
|
||||||
|
);
|
||||||
|
|
||||||
|
// NOTE: size-mismatched constructor is not available
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(to_arith)
|
||||||
|
{
|
||||||
|
FixedHash<20> a{};
|
||||||
|
BOOST_CHECK_EQUAL(u160(a), 0);
|
||||||
|
|
||||||
|
FixedHash<32> b("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470");
|
||||||
|
BOOST_CHECK_EQUAL(u256(b), u256("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"));
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(comparison)
|
||||||
|
{
|
||||||
|
FixedHash<32> a("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470");
|
||||||
|
FixedHash<32> b("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470");
|
||||||
|
FixedHash<32> c("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a471");
|
||||||
|
FixedHash<32> d("233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470c5d2460186f7");
|
||||||
|
|
||||||
|
BOOST_CHECK(a == a);
|
||||||
|
BOOST_CHECK(b == b);
|
||||||
|
BOOST_CHECK(a == b);
|
||||||
|
BOOST_CHECK(b == a);
|
||||||
|
BOOST_CHECK(a != c);
|
||||||
|
BOOST_CHECK(c != a);
|
||||||
|
BOOST_CHECK(a != d);
|
||||||
|
BOOST_CHECK(d != a);
|
||||||
|
|
||||||
|
// Only equal size comparison is supported.
|
||||||
|
BOOST_CHECK(FixedHash<8>{} == FixedHash<8>{});
|
||||||
|
BOOST_CHECK(FixedHash<32>{} != b);
|
||||||
|
|
||||||
|
// Only equal size less than comparison is supported.
|
||||||
|
BOOST_CHECK(!(a < b));
|
||||||
|
BOOST_CHECK(d < c);
|
||||||
|
BOOST_CHECK(FixedHash<32>{} < a);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(indexing)
|
||||||
|
{
|
||||||
|
// NOTE: uses std::array, so "Accessing a nonexistent element through this operator is undefined behavior."
|
||||||
|
|
||||||
|
FixedHash<32> a("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470");
|
||||||
|
BOOST_CHECK_EQUAL(a[0], 0xc5);
|
||||||
|
BOOST_CHECK_EQUAL(a[1], 0xd2);
|
||||||
|
BOOST_CHECK_EQUAL(a[31], 0x70);
|
||||||
|
a[0] = 0xff;
|
||||||
|
a[31] = 0x54;
|
||||||
|
BOOST_CHECK_EQUAL(a[0], 0xff);
|
||||||
|
BOOST_CHECK_EQUAL(a[1], 0xd2);
|
||||||
|
BOOST_CHECK_EQUAL(a[31], 0x54);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(misc)
|
||||||
|
{
|
||||||
|
FixedHash<32> a("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470");
|
||||||
|
|
||||||
|
uint8_t* mut_a = a.data();
|
||||||
|
uint8_t const* const_a = a.data();
|
||||||
|
BOOST_CHECK_EQUAL(mut_a, const_a);
|
||||||
|
BOOST_CHECK_EQUAL(memcmp(mut_a, const_a, a.size), 0);
|
||||||
|
|
||||||
|
bytes bytes_a = a.asBytes();
|
||||||
|
bytesRef bytesref_a = a.ref();
|
||||||
|
bytesConstRef bytesconstref_a = a.ref();
|
||||||
|
|
||||||
|
// There's no printing for bytesRef/bytesConstRef
|
||||||
|
BOOST_CHECK(bytes(a.data(), a.data() + a.size) == bytes_a);
|
||||||
|
BOOST_CHECK(bytesRef(a.data(), a.size) == bytesref_a);
|
||||||
|
BOOST_CHECK(bytesConstRef(a.data(), a.size) == bytesconstref_a);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(tostream)
|
||||||
|
{
|
||||||
|
std::ostringstream out;
|
||||||
|
out << FixedHash<4>("44114411");
|
||||||
|
out << FixedHash<32>{};
|
||||||
|
out << FixedHash<2>("f77f");
|
||||||
|
out << FixedHash<1>("1");
|
||||||
|
BOOST_CHECK_EQUAL(out.str(), "441144110000000000000000000000000000000000000000000000000000000000000000f77f01");
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
|
}
|
@ -34,6 +34,9 @@ namespace solidity::util::test
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE(SwarmHash, *boost::unit_test::label("nooptions"))
|
BOOST_AUTO_TEST_SUITE(SwarmHash, *boost::unit_test::label("nooptions"))
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
string bzzr0HashHex(string const& _input)
|
string bzzr0HashHex(string const& _input)
|
||||||
{
|
{
|
||||||
return toHex(bzzr0Hash(_input).asBytes());
|
return toHex(bzzr0Hash(_input).asBytes());
|
||||||
@ -52,6 +55,8 @@ bytes sequence(size_t _length)
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(test_zeros)
|
BOOST_AUTO_TEST_CASE(test_zeros)
|
||||||
{
|
{
|
||||||
BOOST_CHECK_EQUAL(bzzr0HashHex(string()), string("011b4d03dd8c01f1049143cf9c4c817e4b167f1d1b83e5c6f0f10d89ba1e7bce"));
|
BOOST_CHECK_EQUAL(bzzr0HashHex(string()), string("011b4d03dd8c01f1049143cf9c4c817e4b167f1d1b83e5c6f0f10d89ba1e7bce"));
|
||||||
|
@ -35,6 +35,9 @@ namespace po = boost::program_options;
|
|||||||
namespace solidity::test
|
namespace solidity::test
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
auto const description = R"(isoltest, tool for interactively managing test contracts.
|
auto const description = R"(isoltest, tool for interactively managing test contracts.
|
||||||
Usage: isoltest [Options]
|
Usage: isoltest [Options]
|
||||||
Interactively validates test contracts.
|
Interactively validates test contracts.
|
||||||
@ -51,6 +54,8 @@ std::string editorPath()
|
|||||||
return std::string{};
|
return std::string{};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
IsolTestOptions::IsolTestOptions(std::string* _editor):
|
IsolTestOptions::IsolTestOptions(std::string* _editor):
|
||||||
CommonOptions(description)
|
CommonOptions(description)
|
||||||
{
|
{
|
||||||
|
@ -28,10 +28,28 @@ using namespace std;
|
|||||||
|
|
||||||
static constexpr size_t abiCoderHeapSize = 1024 * 512;
|
static constexpr size_t abiCoderHeapSize = 1024 * 512;
|
||||||
|
|
||||||
DEFINE_PROTO_FUZZER(Contract const&)
|
DEFINE_PROTO_FUZZER(Contract const& _contract)
|
||||||
{
|
{
|
||||||
|
ProtoConverter converter;
|
||||||
|
string contractSource = converter.contractToString(_contract);
|
||||||
|
|
||||||
|
if (const char* dump_path = getenv("PROTO_FUZZER_DUMP_PATH"))
|
||||||
|
{
|
||||||
|
// With libFuzzer binary run this to generate the solidity source file x.sol from a proto input:
|
||||||
|
// PROTO_FUZZER_DUMP_PATH=x.sol ./a.out proto-input
|
||||||
|
ofstream of(dump_path);
|
||||||
|
of << contractSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
string typeString = converter.isabelleTypeString();
|
||||||
|
string valueString = converter.isabelleValueString();
|
||||||
|
std::cout << typeString << std::endl;
|
||||||
|
std::cout << valueString << std::endl;
|
||||||
abicoder::ABICoder coder(abiCoderHeapSize);
|
abicoder::ABICoder coder(abiCoderHeapSize);
|
||||||
auto [encodeStatus, encodedData] = coder.encode("bool", "true");
|
if (!typeString.empty())
|
||||||
solAssert(encodeStatus, "Isabelle abicoder fuzzer: Encoding failed");
|
{
|
||||||
|
auto [encodeStatus, encodedData] = coder.encode(typeString, valueString);
|
||||||
|
solAssert(encodeStatus, "Isabelle abicoder fuzzer: Encoding failed");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -10,14 +10,13 @@ add_dependencies(ossfuzz
|
|||||||
strictasm_assembly_ossfuzz
|
strictasm_assembly_ossfuzz
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
if (OSSFUZZ)
|
if (OSSFUZZ)
|
||||||
add_custom_target(ossfuzz_proto)
|
add_custom_target(ossfuzz_proto)
|
||||||
add_dependencies(ossfuzz_proto
|
add_dependencies(ossfuzz_proto
|
||||||
sol_proto_ossfuzz
|
sol_proto_ossfuzz
|
||||||
yul_proto_ossfuzz
|
yul_proto_ossfuzz
|
||||||
yul_proto_diff_ossfuzz
|
yul_proto_diff_ossfuzz
|
||||||
yul_proto_diff_custom_mutate_ossfuzz
|
yul_proto_diff_custom_mutate_ossfuzz
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_target(ossfuzz_abiv2)
|
add_custom_target(ossfuzz_abiv2)
|
||||||
@ -85,7 +84,7 @@ if (OSSFUZZ)
|
|||||||
protobuf.a
|
protobuf.a
|
||||||
)
|
)
|
||||||
set_target_properties(yul_proto_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE})
|
set_target_properties(yul_proto_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE})
|
||||||
target_compile_options(yul_proto_ossfuzz PUBLIC ${COMPILE_OPTIONS} -Wno-sign-conversion)
|
target_compile_options(yul_proto_ossfuzz PUBLIC ${COMPILE_OPTIONS} -Wno-sign-conversion -Wno-suggest-destructor-override -Wno-inconsistent-missing-destructor-override)
|
||||||
|
|
||||||
add_executable(yul_proto_diff_ossfuzz yulProto_diff_ossfuzz.cpp yulFuzzerCommon.cpp protoToYul.cpp yulProto.pb.cc)
|
add_executable(yul_proto_diff_ossfuzz yulProto_diff_ossfuzz.cpp yulFuzzerCommon.cpp protoToYul.cpp yulProto.pb.cc)
|
||||||
target_include_directories(yul_proto_diff_ossfuzz PRIVATE /usr/include/libprotobuf-mutator)
|
target_include_directories(yul_proto_diff_ossfuzz PRIVATE /usr/include/libprotobuf-mutator)
|
||||||
@ -96,7 +95,7 @@ if (OSSFUZZ)
|
|||||||
protobuf.a
|
protobuf.a
|
||||||
)
|
)
|
||||||
set_target_properties(yul_proto_diff_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE})
|
set_target_properties(yul_proto_diff_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE})
|
||||||
target_compile_options(yul_proto_diff_ossfuzz PUBLIC ${COMPILE_OPTIONS} -Wno-sign-conversion)
|
target_compile_options(yul_proto_diff_ossfuzz PUBLIC ${COMPILE_OPTIONS} -Wno-sign-conversion -Wno-suggest-destructor-override -Wno-inconsistent-missing-destructor-override)
|
||||||
|
|
||||||
add_executable(yul_proto_diff_custom_mutate_ossfuzz
|
add_executable(yul_proto_diff_custom_mutate_ossfuzz
|
||||||
yulProto_diff_ossfuzz.cpp
|
yulProto_diff_ossfuzz.cpp
|
||||||
@ -113,7 +112,7 @@ if (OSSFUZZ)
|
|||||||
protobuf.a
|
protobuf.a
|
||||||
)
|
)
|
||||||
set_target_properties(yul_proto_diff_custom_mutate_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE})
|
set_target_properties(yul_proto_diff_custom_mutate_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE})
|
||||||
target_compile_options(yul_proto_diff_custom_mutate_ossfuzz PUBLIC ${COMPILE_OPTIONS} -Wno-sign-conversion)
|
target_compile_options(yul_proto_diff_custom_mutate_ossfuzz PUBLIC ${COMPILE_OPTIONS} -Wno-sign-conversion -Wno-suggest-destructor-override -Wno-inconsistent-missing-destructor-override)
|
||||||
|
|
||||||
add_executable(abiv2_proto_ossfuzz
|
add_executable(abiv2_proto_ossfuzz
|
||||||
../../EVMHost.cpp
|
../../EVMHost.cpp
|
||||||
@ -133,7 +132,7 @@ if (OSSFUZZ)
|
|||||||
protobuf.a
|
protobuf.a
|
||||||
)
|
)
|
||||||
set_target_properties(abiv2_proto_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE})
|
set_target_properties(abiv2_proto_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE})
|
||||||
target_compile_options(abiv2_proto_ossfuzz PUBLIC ${COMPILE_OPTIONS} -Wno-sign-conversion)
|
target_compile_options(abiv2_proto_ossfuzz PUBLIC ${COMPILE_OPTIONS} -Wno-sign-conversion -Wno-suggest-destructor-override -Wno-inconsistent-missing-destructor-override)
|
||||||
|
|
||||||
add_executable(abiv2_isabelle_ossfuzz
|
add_executable(abiv2_isabelle_ossfuzz
|
||||||
../../EVMHost.cpp
|
../../EVMHost.cpp
|
||||||
@ -155,7 +154,7 @@ if (OSSFUZZ)
|
|||||||
gmp
|
gmp
|
||||||
)
|
)
|
||||||
set_target_properties(abiv2_isabelle_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE})
|
set_target_properties(abiv2_isabelle_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE})
|
||||||
target_compile_options(abiv2_isabelle_ossfuzz PUBLIC ${COMPILE_OPTIONS} -Wno-sign-conversion)
|
target_compile_options(abiv2_isabelle_ossfuzz PUBLIC ${COMPILE_OPTIONS} -Wno-sign-conversion -Wno-suggest-destructor-override -Wno-inconsistent-missing-destructor-override)
|
||||||
|
|
||||||
add_executable(sol_proto_ossfuzz
|
add_executable(sol_proto_ossfuzz
|
||||||
solProtoFuzzer.cpp
|
solProtoFuzzer.cpp
|
||||||
@ -175,7 +174,7 @@ if (OSSFUZZ)
|
|||||||
protobuf.a
|
protobuf.a
|
||||||
)
|
)
|
||||||
set_target_properties(sol_proto_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE})
|
set_target_properties(sol_proto_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE})
|
||||||
target_compile_options(sol_proto_ossfuzz PUBLIC ${COMPILE_OPTIONS} -Wno-sign-conversion)
|
target_compile_options(sol_proto_ossfuzz PUBLIC ${COMPILE_OPTIONS} -Wno-sign-conversion -Wno-suggest-destructor-override -Wno-inconsistent-missing-destructor-override)
|
||||||
else()
|
else()
|
||||||
add_library(solc_opt_ossfuzz
|
add_library(solc_opt_ossfuzz
|
||||||
solc_opt_ossfuzz.cpp
|
solc_opt_ossfuzz.cpp
|
||||||
|
@ -24,10 +24,9 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace solidity::test::fuzzer;
|
using namespace solidity::test::fuzzer;
|
||||||
|
|
||||||
namespace
|
// Prototype as we can't use the FuzzerInterface.h header.
|
||||||
{
|
|
||||||
/// Forward declare libFuzzer's default mutator definition
|
|
||||||
extern "C" size_t LLVMFuzzerMutate(uint8_t* _data, size_t _size, size_t _maxSize);
|
extern "C" size_t LLVMFuzzerMutate(uint8_t* _data, size_t _size, size_t _maxSize);
|
||||||
|
extern "C" size_t LLVMFuzzerCustomMutator(uint8_t* _data, size_t size, size_t _maxSize, unsigned int seed);
|
||||||
|
|
||||||
/// Define Solidity's custom mutator by implementing libFuzzer's
|
/// Define Solidity's custom mutator by implementing libFuzzer's
|
||||||
/// custom mutator external interface.
|
/// custom mutator external interface.
|
||||||
@ -42,7 +41,6 @@ extern "C" size_t LLVMFuzzerCustomMutator(
|
|||||||
return LLVMFuzzerMutate(_data, _size, _maxSize);
|
return LLVMFuzzerMutate(_data, _size, _maxSize);
|
||||||
return SolidityCustomMutatorInterface{_data, _size, _maxSize, _seed}.generate();
|
return SolidityCustomMutatorInterface{_data, _size, _maxSize, _seed}.generate();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
SolidityCustomMutatorInterface::SolidityCustomMutatorInterface(
|
SolidityCustomMutatorInterface::SolidityCustomMutatorInterface(
|
||||||
uint8_t* _data,
|
uint8_t* _data,
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user