From b540ba527a70df440299de9c0bf44f9d11ac6ef6 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 27 Mar 2018 14:38:28 +0100 Subject: Disallow empty structs --- test/libsolidity/SolidityNameAndTypeResolution.cpp | 2 +- test/libsolidity/syntaxTests/empty_struct.sol | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 test/libsolidity/syntaxTests/empty_struct.sol (limited to 'test') diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index c5abac03..6163aed0 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -7279,7 +7279,7 @@ BOOST_AUTO_TEST_CASE(modifiers_access_storage_pointer) { char const* text = R"( contract C { - struct S { } + struct S { uint a; } modifier m(S storage x) { x; _; diff --git a/test/libsolidity/syntaxTests/empty_struct.sol b/test/libsolidity/syntaxTests/empty_struct.sol new file mode 100644 index 00000000..87bc2ffe --- /dev/null +++ b/test/libsolidity/syntaxTests/empty_struct.sol @@ -0,0 +1,5 @@ +contract test { + struct A {} +} +// ---- +// SyntaxError: Defining empty structs is disallowed. -- cgit v1.2.3 From ebb12756adfe95ae694ed7e141890c6d47e8b7b4 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 27 Mar 2018 15:00:33 +0100 Subject: Still allow empty structs for non-0.5.0 mode --- test/libsolidity/syntaxTests/empty_struct.sol | 2 +- test/libsolidity/syntaxTests/empty_struct_050.sol | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 test/libsolidity/syntaxTests/empty_struct_050.sol (limited to 'test') 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. -- cgit v1.2.3