diff options
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 17 | ||||
-rw-r--r-- | libsolidity/analysis/TypeChecker.h | 3 |
2 files changed, 20 insertions, 0 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index ce55de00..c2fd3e7e 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -830,6 +830,13 @@ void TypeChecker::endVisit(ExpressionStatement const& _statement) if (type(_statement.expression())->category() == Type::Category::RationalNumber) 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."); } bool TypeChecker::visit(Conditional const& _conditional) @@ -1570,6 +1577,16 @@ void TypeChecker::typeError(SourceLocation const& _location, string const& _desc m_errors.push_back(err); } +void TypeChecker::warning(SourceLocation const& _location, string const& _description) +{ + auto err = make_shared<Error>(Error::Type::Warning); + *err << + errinfo_sourceLocation(_location) << + errinfo_comment(_description); + + m_errors.push_back(err); +} + void TypeChecker::fatalTypeError(SourceLocation const& _location, string const& _description) { typeError(_location, _description); diff --git a/libsolidity/analysis/TypeChecker.h b/libsolidity/analysis/TypeChecker.h index 48f8285a..be1e02be 100644 --- a/libsolidity/analysis/TypeChecker.h +++ b/libsolidity/analysis/TypeChecker.h @@ -59,6 +59,9 @@ private: /// Adds a new error to the list of errors. void typeError(SourceLocation const& _location, std::string const& _description); + /// Adds a new warning to the list of errors. + void warning(SourceLocation const& _location, std::string const& _description); + /// Adds a new error to the list of errors and throws to abort type checking. void fatalTypeError(SourceLocation const& _location, std::string const& _description); |