From b5e9d849ef93589ab8eb59e1becbc4d7a8250ccb Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Tue, 13 Nov 2018 12:12:08 +0100 Subject: Ignore unimplemented functions for storage returns. --- Changelog.md | 1 + libsolidity/analysis/ControlFlowAnalyzer.cpp | 7 +++++-- .../controlFlow/storageReturn/unimplemented_internal.sol | 4 ++++ .../controlFlow/storageReturn/unimplemented_library.sol | 4 ++++ 4 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 test/libsolidity/syntaxTests/controlFlow/storageReturn/unimplemented_internal.sol create mode 100644 test/libsolidity/syntaxTests/controlFlow/storageReturn/unimplemented_library.sol diff --git a/Changelog.md b/Changelog.md index ff95a89a..2e5a3044 100644 --- a/Changelog.md +++ b/Changelog.md @@ -111,6 +111,7 @@ Bugfixes: * Code Generator: Properly handle negative number literals in ABIEncoderV2. * Code Generator: Do not crash on using a length of zero for multidimensional fixed-size arrays. * Commandline Interface: Correctly handle paths with backslashes on windows. + * Control Flow Analyzer: Ignore unimplemented functions when detecting uninitialized storage pointer returns. * Fix NatSpec json output for `@notice` and `@dev` tags on contract definitions. * Optimizer: Correctly estimate gas costs of constants for special cases. * Optimizer: Fix simplification rule initialization bug that appeared on some emscripten platforms. diff --git a/libsolidity/analysis/ControlFlowAnalyzer.cpp b/libsolidity/analysis/ControlFlowAnalyzer.cpp index ab6569be..8a608552 100644 --- a/libsolidity/analysis/ControlFlowAnalyzer.cpp +++ b/libsolidity/analysis/ControlFlowAnalyzer.cpp @@ -28,8 +28,11 @@ bool ControlFlowAnalyzer::analyze(ASTNode const& _astRoot) bool ControlFlowAnalyzer::visit(FunctionDefinition const& _function) { - auto const& functionFlow = m_cfg.functionFlow(_function); - checkUnassignedStorageReturnValues(_function, functionFlow.entry, functionFlow.exit); + if (_function.isImplemented()) + { + auto const& functionFlow = m_cfg.functionFlow(_function); + checkUnassignedStorageReturnValues(_function, functionFlow.entry, functionFlow.exit); + } return false; } diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/unimplemented_internal.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/unimplemented_internal.sol new file mode 100644 index 00000000..8bce0dd2 --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/unimplemented_internal.sol @@ -0,0 +1,4 @@ +contract C { + function f() internal returns(uint[] storage); + function g() internal returns(uint[] storage s); +} diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/unimplemented_library.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/unimplemented_library.sol new file mode 100644 index 00000000..818b6a20 --- /dev/null +++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/unimplemented_library.sol @@ -0,0 +1,4 @@ +library L { + function f() public returns(uint[] storage); + function g() public returns(uint[] storage s); +} -- cgit v1.2.3