aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-03-27 22:00:33 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-03-27 22:49:41 +0800
commitebb12756adfe95ae694ed7e141890c6d47e8b7b4 (patch)
treeb510bc4c73dedc9a3110a7b8ad2dc4c2bc64df2c
parentb540ba527a70df440299de9c0bf44f9d11ac6ef6 (diff)
downloaddexon-solidity-ebb12756adfe95ae694ed7e141890c6d47e8b7b4.tar.gz
dexon-solidity-ebb12756adfe95ae694ed7e141890c6d47e8b7b4.tar.zst
dexon-solidity-ebb12756adfe95ae694ed7e141890c6d47e8b7b4.zip
Still allow empty structs for non-0.5.0 mode
-rw-r--r--Changelog.md2
-rw-r--r--libsolidity/analysis/SyntaxChecker.cpp9
-rw-r--r--test/libsolidity/syntaxTests/empty_struct.sol2
-rw-r--r--test/libsolidity/syntaxTests/empty_struct_050.sol6
4 files changed, 16 insertions, 3 deletions
diff --git a/Changelog.md b/Changelog.md
index 3fa0c485..e9314834 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -3,6 +3,7 @@
Features:
* General: Support accessing dynamic return data in post-byzantium EVMs.
* Interfaces: Allow overriding external functions in interfaces with public in an implementing contract.
+ * Syntax Checker: Issue warning for empty structs (or error as experimental 0.5.0 feature).
Bugfixes:
* Code Generator: Allow ``block.blockhash`` without being called.
@@ -12,7 +13,6 @@ Bugfixes:
* Commandline interface: Support ``--evm-version constantinople`` properly.
* DocString Parser: Fix error message for empty descriptions.
* Standard JSON: Support ``constantinople`` as ``evmVersion`` properly.
- * Syntax Checker: Issue error for empty structs.
* Type System: Make external library functions accessible.
### 0.4.21 (2018-03-07)
diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp
index e03417a9..3a32810b 100644
--- a/libsolidity/analysis/SyntaxChecker.cpp
+++ b/libsolidity/analysis/SyntaxChecker.cpp
@@ -258,7 +258,14 @@ bool SyntaxChecker::visit(VariableDeclaration const& _declaration)
bool SyntaxChecker::visit(StructDefinition const& _struct)
{
+ bool const v050 = m_sourceUnit->annotation().experimentalFeatures.count(ExperimentalFeature::V050);
+
if (_struct.members().empty())
- m_errorReporter.syntaxError(_struct.location(), "Defining empty structs is disallowed.");
+ {
+ if (v050)
+ m_errorReporter.syntaxError(_struct.location(), "Defining empty structs is disallowed.");
+ else
+ m_errorReporter.warning(_struct.location(), "Defining empty structs is deprecated.");
+ }
return true;
}
diff --git a/test/libsolidity/syntaxTests/empty_struct.sol b/test/libsolidity/syntaxTests/empty_struct.sol
index 87bc2ffe..dcced618 100644
--- a/test/libsolidity/syntaxTests/empty_struct.sol
+++ b/test/libsolidity/syntaxTests/empty_struct.sol
@@ -2,4 +2,4 @@ contract test {
struct A {}
}
// ----
-// SyntaxError: Defining empty structs is disallowed.
+// Warning: Defining empty structs is deprecated.
diff --git a/test/libsolidity/syntaxTests/empty_struct_050.sol b/test/libsolidity/syntaxTests/empty_struct_050.sol
new file mode 100644
index 00000000..dbec93c4
--- /dev/null
+++ b/test/libsolidity/syntaxTests/empty_struct_050.sol
@@ -0,0 +1,6 @@
+pragma experimental "v0.5.0";
+contract test {
+ struct A {}
+}
+// ----
+// SyntaxError: Defining empty structs is disallowed.