aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Changelog.md1
-rw-r--r--docs/using-the-compiler.rst11
-rw-r--r--libsolidity/analysis/SyntaxChecker.cpp17
-rw-r--r--libsolidity/analysis/SyntaxChecker.h4
-rw-r--r--libsolidity/interface/StandardCompiler.cpp24
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp19
6 files changed, 44 insertions, 32 deletions
diff --git a/Changelog.md b/Changelog.md
index cd54aadb..c95cab5a 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -10,6 +10,7 @@ Features:
* Inline Assembly: Storage variable access using ``_slot`` and ``_offset`` suffixes.
* Inline Assembly: Disallow blocks with unbalanced stack.
* Static analyzer: Warn about statements without effects.
+ * Syntax checker: issue deprecation warning for unary '+'
Bugfixes:
* Assembly output: Implement missing AssemblyItem types.
diff --git a/docs/using-the-compiler.rst b/docs/using-the-compiler.rst
index 85ef9230..7aa997f8 100644
--- a/docs/using-the-compiler.rst
+++ b/docs/using-the-compiler.rst
@@ -121,7 +121,6 @@ Input Description
// abi - ABI
// ast - AST of all source files (not supported atm)
// legacyAST - legacy AST of all source files
- // why3 - Why3 translated output
// devdoc - Developer documentation (natspec)
// userdoc - User documentation (natspec)
// metadata - Metadata
@@ -154,9 +153,9 @@ Input Description
"*": {
"*": [ "evm.sourceMap" ]
},
- // Enable the legacy AST and Why3 output of every single file.
+ // Enable the legacy AST output of every single file.
"*": {
- "": [ "legacyAST", "why3" ]
+ "": [ "legacyAST" ]
}
}
}
@@ -180,7 +179,7 @@ Output Description
],
// Mandatory: Error type, such as "TypeError", "InternalCompilerError", "Exception", etc
type: "TypeError",
- // Mandatory: Component where the error originated, such as "general", "why3", "ewasm", etc.
+ // Mandatory: Component where the error originated, such as "general", "ewasm", etc.
component: "general",
// Mandatory ("error" or "warning")
severity: "error",
@@ -272,7 +271,5 @@ Output Description
}
}
}
- },
- // Why3 output (string)
- why3: ""
+ }
}
diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp
index 89014133..94e82a87 100644
--- a/libsolidity/analysis/SyntaxChecker.cpp
+++ b/libsolidity/analysis/SyntaxChecker.cpp
@@ -32,6 +32,16 @@ bool SyntaxChecker::checkSyntax(ASTNode const& _astRoot)
return Error::containsOnlyWarnings(m_errors);
}
+void SyntaxChecker::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 SyntaxChecker::syntaxError(SourceLocation const& _location, std::string const& _description)
{
auto err = make_shared<Error>(Error::Type::SyntaxError);
@@ -148,6 +158,13 @@ bool SyntaxChecker::visit(Break const& _breakStatement)
return true;
}
+bool SyntaxChecker::visit(UnaryOperation const& _operation)
+{
+ if (_operation.getOperator() == Token::Add)
+ warning(_operation.location(), "Use of unary + is deprecated.");
+ return true;
+}
+
bool SyntaxChecker::visit(PlaceholderStatement const&)
{
m_placeholderFound = true;
diff --git a/libsolidity/analysis/SyntaxChecker.h b/libsolidity/analysis/SyntaxChecker.h
index 308e128b..8d7dcdd3 100644
--- a/libsolidity/analysis/SyntaxChecker.h
+++ b/libsolidity/analysis/SyntaxChecker.h
@@ -32,6 +32,7 @@ namespace solidity
* The module that performs syntax analysis on the AST:
* - whether continue/break is in a for/while loop.
* - whether a modifier contains at least one '_'
+ * - issues deprecation warnings for unary '+'
*/
class SyntaxChecker: private ASTConstVisitor
{
@@ -43,6 +44,7 @@ public:
private:
/// Adds a new error to the list of errors.
+ void warning(SourceLocation const& _location, std::string const& _description);
void syntaxError(SourceLocation const& _location, std::string const& _description);
virtual bool visit(SourceUnit const& _sourceUnit) override;
@@ -60,6 +62,8 @@ private:
virtual bool visit(Continue const& _continueStatement) override;
virtual bool visit(Break const& _breakStatement) override;
+ virtual bool visit(UnaryOperation const& _operation) override;
+
virtual bool visit(PlaceholderStatement const& _placeholderStatement) override;
ErrorList& m_errors;
diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp
index 8670234b..223cc15d 100644
--- a/libsolidity/interface/StandardCompiler.cpp
+++ b/libsolidity/interface/StandardCompiler.cpp
@@ -425,30 +425,6 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input)
}
output["contracts"] = contractsOutput;
- {
- ErrorList formalErrors;
- if (m_compilerStack.prepareFormalAnalysis(&formalErrors))
- output["why3"] = m_compilerStack.formalTranslation();
-
- for (auto const& error: formalErrors)
- {
- auto err = dynamic_pointer_cast<Error const>(error);
-
- errors.append(formatErrorWithException(
- *error,
- err->type() == Error::Type::Warning,
- err->typeName(),
- "general",
- "",
- scannerFromSourceName
- ));
- }
-
- // FIXME!!
- if (!formalErrors.empty())
- output["errors"] = errors;
- }
-
return output;
}
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index f88f600a..90d0e728 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -3938,12 +3938,29 @@ BOOST_AUTO_TEST_CASE(rational_unary_operation)
char const* text = R"(
contract test {
function f() {
+ ufixed8x16 a = 3.25;
+ fixed8x16 b = -3.25;
+ }
+ }
+ )";
+ CHECK_SUCCESS_NO_WARNINGS(text);
+ text = R"(
+ contract test {
+ function f() {
ufixed8x16 a = +3.25;
fixed8x16 b = -3.25;
}
}
)";
- CHECK_SUCCESS(text);
+ CHECK_WARNING(text,"Use of unary + is deprecated");
+ text = R"(
+ contract test {
+ function f(uint x) {
+ uint y = +x;
+ }
+ }
+ )";
+ CHECK_WARNING(text,"Use of unary + is deprecated");
}
BOOST_AUTO_TEST_CASE(leading_zero_rationals_convert)