diff options
author | chriseth <c@ethdev.com> | 2016-06-24 22:41:17 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2016-06-26 19:53:32 +0800 |
commit | 25a64c7f8f35833b9dec6068232be6e0ce9d2e78 (patch) | |
tree | a907069c75d43e2c86629e4e148383d4e3d5d26f /libsolidity | |
parent | cc6314cd019be80a9212f6bd5b0c86206be16c88 (diff) | |
download | dexon-solidity-25a64c7f8f35833b9dec6068232be6e0ce9d2e78.tar.gz dexon-solidity-25a64c7f8f35833b9dec6068232be6e0ce9d2e78.tar.zst dexon-solidity-25a64c7f8f35833b9dec6068232be6e0ce9d2e78.zip |
Only warn about unused return in low-level functions.
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index c2fd3e7e..6b2c1cb8 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -831,12 +831,21 @@ void TypeChecker::endVisit(ExpressionStatement const& _statement) if (!dynamic_cast<RationalNumberType const&>(*type(_statement.expression())).mobileType()) typeError(_statement.expression().location(), "Invalid rational number."); - bool unusedReturnValue = true; - if (auto t = dynamic_cast<TupleType const*>(type(_statement.expression()).get())) - if (t->components().empty()) - unusedReturnValue = false; - if (unusedReturnValue) - warning(_statement.location(), "Unused return value."); + if (auto call = dynamic_cast<FunctionCall const*>(&_statement.expression())) + { + if (auto callType = dynamic_cast<FunctionType const*>(type(call->expression()).get())) + { + using Location = FunctionType::Location; + Location location = callType->location(); + if ( + location == Location::Bare || + location == Location::BareCallCode || + location == Location::BareDelegateCall || + location == Location::Send + ) + warning(_statement.location(), "Return value of low-level calls not used."); + } + } } bool TypeChecker::visit(Conditional const& _conditional) |