aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Parpart <christian@ethereum.org>2018-07-03 17:51:44 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-08-02 20:36:05 +0800
commit5d9320c70b11b5ae1a44376451599732aa49dcde (patch)
tree6d41279efe62a7f9e62afcb119bdcfb045a3e5ea
parent6003ed2abdea76e809b1e6501b9e5a85b38e5859 (diff)
downloaddexon-solidity-5d9320c70b11b5ae1a44376451599732aa49dcde.tar
dexon-solidity-5d9320c70b11b5ae1a44376451599732aa49dcde.tar.gz
dexon-solidity-5d9320c70b11b5ae1a44376451599732aa49dcde.tar.bz2
dexon-solidity-5d9320c70b11b5ae1a44376451599732aa49dcde.tar.lz
dexon-solidity-5d9320c70b11b5ae1a44376451599732aa49dcde.tar.xz
dexon-solidity-5d9320c70b11b5ae1a44376451599732aa49dcde.tar.zst
dexon-solidity-5d9320c70b11b5ae1a44376451599732aa49dcde.zip
Disallow loos assembly in Solidity by permanently setting it to SyntaxError (from Warning)
-rw-r--r--Changelog.md1
-rw-r--r--libsolidity/analysis/ReferencesResolver.cpp2
-rw-r--r--libsolidity/analysis/TypeChecker.cpp6
-rw-r--r--libsolidity/inlineasm/AsmAnalysis.cpp6
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/373_inline_assembly_unbalanced_positive_stack.sol2
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol2
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/386_inline_assembly_050_literals_on_stack.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/387_inline_assembly_literals_on_stack.sol2
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/388_inline_assembly_050_bare_instructions.sol12
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/390_inline_assembly_050_labels.sol11
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol3
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/395_inline_assembly_leave_items_on_stack.sol2
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol2
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol3
16 files changed, 17 insertions, 56 deletions
diff --git a/Changelog.md b/Changelog.md
index c21f0ae9..e4f09bb0 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -53,6 +53,7 @@ Breaking Changes:
* Type Checker: Fallback function must be external. This was already the case in the experimental 0.5.0 mode.
* Type Checker: Interface functions must be declared external. This was already the case in the experimental 0.5.0 mode.
* Type Checker: Address members are not included in contract types anymore. An explicit conversion is now required before invoking an ``address`` member from a contract.
+ * Type Checker: Disallow "loose assembly" syntax entirely. This means that jump labels, jumps and non-functional instructions cannot be used anymore.
* Remove obsolete ``std`` directory from the Solidity repository. This means accessing ``https://github.com/ethereum/soldity/blob/develop/std/*.sol`` (or ``https://github.com/ethereum/solidity/std/*.sol`` in Remix) will not be possible.
* References Resolver: Turn missing storage locations into an error. This was already the case in the experimental 0.5.0 mode.
* Syntax Checker: Disallow functions without implementation to use modifiers. This was already the case in the experimental 0.5.0 mode.
diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp
index a9a998b0..e058d917 100644
--- a/libsolidity/analysis/ReferencesResolver.cpp
+++ b/libsolidity/analysis/ReferencesResolver.cpp
@@ -277,7 +277,7 @@ bool ReferencesResolver::visit(InlineAssembly const& _inlineAssembly)
// Will be re-generated later with correct information
// We use the latest EVM version because we will re-run it anyway.
assembly::AsmAnalysisInfo analysisInfo;
- boost::optional<Error::Type> errorTypeForLoose = m_experimental050Mode ? Error::Type::SyntaxError : Error::Type::Warning;
+ boost::optional<Error::Type> errorTypeForLoose = Error::Type::SyntaxError;
assembly::AsmAnalyzer(analysisInfo, errorsIgnored, EVMVersion(), errorTypeForLoose, assembly::AsmFlavour::Loose, resolver).analyze(_inlineAssembly.operations());
return false;
}
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 8f504ffe..f4354c61 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -927,15 +927,11 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
};
solAssert(!_inlineAssembly.annotation().analysisInfo, "");
_inlineAssembly.annotation().analysisInfo = make_shared<assembly::AsmAnalysisInfo>();
- boost::optional<Error::Type> errorTypeForLoose =
- m_scope->sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050) ?
- Error::Type::SyntaxError :
- Error::Type::Warning;
assembly::AsmAnalyzer analyzer(
*_inlineAssembly.annotation().analysisInfo,
m_errorReporter,
m_evmVersion,
- errorTypeForLoose,
+ Error::Type::SyntaxError,
assembly::AsmFlavour::Loose,
identifierAccess
);
diff --git a/libsolidity/inlineasm/AsmAnalysis.cpp b/libsolidity/inlineasm/AsmAnalysis.cpp
index d5580dd2..ea804cf5 100644
--- a/libsolidity/inlineasm/AsmAnalysis.cpp
+++ b/libsolidity/inlineasm/AsmAnalysis.cpp
@@ -57,7 +57,7 @@ bool AsmAnalyzer::operator()(Label const& _label)
solAssert(!_label.name.empty(), "");
checkLooseFeature(
_label.location,
- "The use of labels is deprecated. Please use \"if\", \"switch\", \"for\" or function calls instead."
+ "The use of labels is disallowed. Please use \"if\", \"switch\", \"for\" or function calls instead."
);
m_info.stackHeightInfo[&_label] = m_stackHeight;
warnOnInstructions(solidity::Instruction::JUMPDEST, _label.location);
@@ -68,7 +68,7 @@ bool AsmAnalyzer::operator()(assembly::Instruction const& _instruction)
{
checkLooseFeature(
_instruction.location,
- "The use of non-functional instructions is deprecated. Please use functional notation instead."
+ "The use of non-functional instructions is disallowed. Please use functional notation instead."
);
auto const& info = instructionInfo(_instruction.instruction);
m_stackHeight += info.ret - info.args;
@@ -201,7 +201,7 @@ bool AsmAnalyzer::operator()(assembly::StackAssignment const& _assignment)
{
checkLooseFeature(
_assignment.location,
- "The use of stack assignment is deprecated. Please use assignment in functional notation instead."
+ "The use of stack assignment is disallowed. Please use assignment in functional notation instead."
);
bool success = checkAssignment(_assignment.variableName, size_t(-1));
m_info.stackHeightInfo[&_assignment] = m_stackHeight;
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/373_inline_assembly_unbalanced_positive_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/373_inline_assembly_unbalanced_positive_stack.sol
index 273e1844..e9599f4b 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/373_inline_assembly_unbalanced_positive_stack.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/373_inline_assembly_unbalanced_positive_stack.sol
@@ -6,5 +6,5 @@ contract test {
}
}
// ----
-// Warning: (73-74): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
+// SyntaxError: (73-74): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
// DeclarationError: (59-84): Unbalanced stack at the end of a block: 1 surplus item(s).
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol
index bda090b4..9768a014 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol
@@ -6,5 +6,5 @@ contract test {
}
}
// ----
-// Warning: (73-76): The use of non-functional instructions is deprecated. Please use functional notation instead.
+// SyntaxError: (73-76): The use of non-functional instructions is deprecated. Please use functional notation instead.
// DeclarationError: (59-86): Unbalanced stack at the end of a block: 1 missing item(s).
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/386_inline_assembly_050_literals_on_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/386_inline_assembly_050_literals_on_stack.sol
deleted file mode 100644
index a5f0f96c..00000000
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/386_inline_assembly_050_literals_on_stack.sol
+++ /dev/null
@@ -1,11 +0,0 @@
-pragma experimental "v0.5.0";
-contract C {
- function f() pure public {
- assembly {
- 1
- }
- }
-}
-// ----
-// SyntaxError: (105-106): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
-// DeclarationError: (91-116): Unbalanced stack at the end of a block: 1 surplus item(s).
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/387_inline_assembly_literals_on_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/387_inline_assembly_literals_on_stack.sol
index 7b68c60b..62fe7171 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/387_inline_assembly_literals_on_stack.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/387_inline_assembly_literals_on_stack.sol
@@ -6,5 +6,5 @@ contract C {
}
}
// ----
-// Warning: (75-76): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
+// SyntaxError: (75-76): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
// DeclarationError: (61-86): Unbalanced stack at the end of a block: 1 surplus item(s).
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/388_inline_assembly_050_bare_instructions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/388_inline_assembly_050_bare_instructions.sol
deleted file mode 100644
index 4a7aca8a..00000000
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/388_inline_assembly_050_bare_instructions.sol
+++ /dev/null
@@ -1,12 +0,0 @@
-pragma experimental "v0.5.0";
-contract C {
- function f() view public {
- assembly {
- address
- pop
- }
- }
-}
-// ----
-// SyntaxError: (105-112): The use of non-functional instructions is deprecated. Please use functional notation instead.
-// SyntaxError: (125-128): The use of non-functional instructions is deprecated. Please use functional notation instead.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol
index c44412cf..fa706e7d 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol
@@ -7,5 +7,5 @@ contract C {
}
}
// ----
-// Warning: (75-82): The use of non-functional instructions is deprecated. Please use functional notation instead.
-// Warning: (95-98): The use of non-functional instructions is deprecated. Please use functional notation instead.
+// SyntaxError: (75-82): The use of non-functional instructions is deprecated. Please use functional notation instead.
+// SyntaxError: (95-98): The use of non-functional instructions is deprecated. Please use functional notation instead.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/390_inline_assembly_050_labels.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/390_inline_assembly_050_labels.sol
deleted file mode 100644
index 77a73ebc..00000000
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/390_inline_assembly_050_labels.sol
+++ /dev/null
@@ -1,11 +0,0 @@
-pragma experimental "v0.5.0";
-contract C {
- function f() pure public {
- assembly {
- label:
- }
- }
-}
-// ----
-// SyntaxError: (105-110): The use of labels is deprecated. Please use "if", "switch", "for" or function calls instead.
-// SyntaxError: (105-110): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol
index 15bd6660..8c820560 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol
@@ -6,5 +6,5 @@ contract C {
}
}
// ----
-// Warning: (75-80): The use of labels is deprecated. Please use "if", "switch", "for" or function calls instead.
-// Warning: (75-80): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
+// SyntaxError: (75-80): The use of labels is deprecated. Please use "if", "switch", "for" or function calls instead.
+// SyntaxError: (75-80): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol
index c3c82ce8..6cb35d6d 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol
@@ -6,5 +6,4 @@ contract C {
}
}
// ----
-// Warning: (75-82): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
-// TypeError: (75-82): Function declared as pure, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
+// SyntaxError: (75-82): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/395_inline_assembly_leave_items_on_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/395_inline_assembly_leave_items_on_stack.sol
index 56043ccf..8538a2a0 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/395_inline_assembly_leave_items_on_stack.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/395_inline_assembly_leave_items_on_stack.sol
@@ -6,5 +6,5 @@ contract C {
}
}
// ----
-// Warning: (75-83): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
+// SyntaxError: (75-83): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
// DeclarationError: (61-93): Unbalanced stack at the end of a block: 1 surplus item(s).
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol b/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol
index 418be561..cc6ef183 100644
--- a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol
+++ b/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol
@@ -4,4 +4,4 @@ contract C {
}
}
// ----
-// Warning: (58-65): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
+// SyntaxError: (58-65): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol
index c1729db7..933bb4a3 100644
--- a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol
+++ b/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol
@@ -4,5 +4,4 @@ contract C {
}
}
// ----
-// Warning: (63-70): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
-// TypeError: (63-70): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
+// SyntaxError: (63-70): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.