diff options
Diffstat (limited to 'test/libsolidity')
51 files changed, 237 insertions, 280 deletions
diff --git a/test/libsolidity/ABIDecoderTests.cpp b/test/libsolidity/ABIDecoderTests.cpp index c122d806..b4f829ca 100644 --- a/test/libsolidity/ABIDecoderTests.cpp +++ b/test/libsolidity/ABIDecoderTests.cpp @@ -266,7 +266,6 @@ BOOST_AUTO_TEST_CASE(calldata_arrays_too_large) } } )"; - bool newEncoder = false; BOTH_ENCODERS( compileAndRun(sourceCode); bytes args = encodeArgs( @@ -275,9 +274,8 @@ BOOST_AUTO_TEST_CASE(calldata_arrays_too_large) ); ABI_CHECK( callContractFunction("f(uint256,uint256[],uint256)", args), - newEncoder ? encodeArgs() : encodeArgs(7) + encodeArgs() ); - newEncoder = true; ) } @@ -374,7 +372,7 @@ BOOST_AUTO_TEST_CASE(decode_function_type_array) } // uses "decode from memory" function test1_dynamic() public returns (uint) { - var x = new function() external returns (uint)[](3); + function () external returns (uint)[] memory x = new function() external returns (uint)[](4); x[0] = this.f1; x[1] = this.f2; x[2] = this.f3; @@ -387,7 +385,7 @@ BOOST_AUTO_TEST_CASE(decode_function_type_array) } // uses "decode from calldata" function test2_dynamic() public returns (uint) { - var x = new function() external returns (uint)[](3); + function () external returns (uint)[] memory x = new function() external returns (uint)[](3); x[0] = this.f1; x[1] = this.f2; x[2] = this.f3; @@ -449,13 +447,11 @@ BOOST_AUTO_TEST_CASE(short_input_value_type) function f(uint a, uint b) public pure returns (uint) { return a; } } )"; - bool newDecoder = false; BOTH_ENCODERS( compileAndRun(sourceCode); ABI_CHECK(callContractFunction("f(uint256,uint256)", 1, 2), encodeArgs(1)); ABI_CHECK(callContractFunctionNoEncoding("f(uint256,uint256)", bytes(64, 0)), encodeArgs(0)); - ABI_CHECK(callContractFunctionNoEncoding("f(uint256,uint256)", bytes(63, 0)), newDecoder ? encodeArgs() : encodeArgs(0)); - newDecoder = true; + ABI_CHECK(callContractFunctionNoEncoding("f(uint256,uint256)", bytes(63, 0)), encodeArgs()); ) } @@ -466,15 +462,13 @@ BOOST_AUTO_TEST_CASE(short_input_array) function f(uint[] a) public pure returns (uint) { return 7; } } )"; - bool newDecoder = false; BOTH_ENCODERS( compileAndRun(sourceCode); ABI_CHECK(callContractFunctionNoEncoding("f(uint256[])", encodeArgs(0x20, 0)), encodeArgs(7)); - ABI_CHECK(callContractFunctionNoEncoding("f(uint256[])", encodeArgs(0x20, 1)), newDecoder ? encodeArgs() : encodeArgs(7)); - ABI_CHECK(callContractFunctionNoEncoding("f(uint256[])", encodeArgs(0x20, 1) + bytes(31, 0)), newDecoder ? encodeArgs() : encodeArgs(7)); + ABI_CHECK(callContractFunctionNoEncoding("f(uint256[])", encodeArgs(0x20, 1)), encodeArgs()); + ABI_CHECK(callContractFunctionNoEncoding("f(uint256[])", encodeArgs(0x20, 1) + bytes(31, 0)), encodeArgs()); ABI_CHECK(callContractFunctionNoEncoding("f(uint256[])", encodeArgs(0x20, 1) + bytes(32, 0)), encodeArgs(7)); ABI_CHECK(callContractFunctionNoEncoding("f(uint256[])", encodeArgs(0x20, 2, 5, 6)), encodeArgs(7)); - newDecoder = true; ) } @@ -558,7 +552,7 @@ BOOST_AUTO_TEST_CASE(storage_ptr) r[2] = 3; s.x = 11; s.y = 12; - var (a, b, c, d) = L.f(r, s); + (uint a, uint b, uint c, uint d) = L.f(r, s); return (r[2], s.x, a, b, c, d); } } diff --git a/test/libsolidity/GasMeter.cpp b/test/libsolidity/GasMeter.cpp index 42965582..d8954f83 100644 --- a/test/libsolidity/GasMeter.cpp +++ b/test/libsolidity/GasMeter.cpp @@ -87,6 +87,7 @@ public: for (bytes const& arguments: _argumentVariants) { sendMessage(hash.asBytes() + arguments, false, 0); + BOOST_CHECK(m_transactionSuccessful); gasUsed = max(gasUsed, m_gasUsed); gas = max(gas, gasForTransaction(hash.asBytes() + arguments, false)); } diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 7ea6cf98..31842777 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -49,6 +49,25 @@ namespace test BOOST_FIXTURE_TEST_SUITE(SolidityEndToEndTest, SolidityExecutionFramework) +BOOST_AUTO_TEST_CASE(transaction_status) +{ + char const* sourceCode = R"( + contract test { + function f() { } + function g() { revert(); } + function h() { assert(false); } + } + )"; + compileAndRun(sourceCode); + callContractFunction("f()"); + BOOST_CHECK(m_transactionSuccessful); + callContractFunction("g()"); + BOOST_CHECK(!m_transactionSuccessful); + callContractFunction("h()"); + BOOST_CHECK(!m_transactionSuccessful); +} + + BOOST_AUTO_TEST_CASE(smoke_test) { char const* sourceCode = R"( @@ -305,7 +324,7 @@ BOOST_AUTO_TEST_CASE(conditional_expression_functions) function y() returns (uint) { return 2; } function f(bool cond) returns (uint) { - var z = cond ? x : y; + function () returns (uint) z = cond ? x : y; return z(); } } @@ -433,7 +452,7 @@ BOOST_AUTO_TEST_CASE(while_loop) contract test { function f(uint n) returns(uint nfac) { nfac = 1; - var i = 2; + uint i = 2; while (i <= n) nfac *= i++; } } @@ -460,7 +479,7 @@ BOOST_AUTO_TEST_CASE(do_while_loop) contract test { function f(uint n) returns(uint nfac) { nfac = 1; - var i = 2; + uint i = 2; do { nfac *= i++; } while (i <= n); } } @@ -561,7 +580,8 @@ BOOST_AUTO_TEST_CASE(for_loop) contract test { function f(uint n) returns(uint nfac) { nfac = 1; - for (var i = 2; i <= n; i++) + uint i; + for (i = 2; i <= n; i++) nfac *= i; } } @@ -735,7 +755,7 @@ BOOST_AUTO_TEST_CASE(many_local_variables) char const* sourceCode = R"( contract test { function run(uint x1, uint x2, uint x3) returns(uint y) { - var a = 0x1; var b = 0x10; var c = 0x100; + uint8 a = 0x1; uint8 b = 0x10; uint16 c = 0x100; y = a + b + c + x1 + x2 + x3; y += b + x2; } @@ -1252,7 +1272,7 @@ BOOST_AUTO_TEST_CASE(struct_reference) } function set() { data.z = 2; - var map = data.recursive; + mapping(uint8 => s2) map = data.recursive; s2 inner = map[0]; inner.z = 3; inner.recursive[0].z = inner.recursive[1].z + 1; @@ -1836,8 +1856,7 @@ BOOST_AUTO_TEST_CASE(uncalled_blockhash) contract C { function f() public view returns (bytes32) { - var x = block.blockhash; - return x(block.number - 1); + return (block.blockhash)(block.number - 1); } } )"; @@ -2061,7 +2080,7 @@ BOOST_AUTO_TEST_CASE(packed_keccak256) char const* sourceCode = R"( contract test { function a(bytes32 input) returns (bytes32 hash) { - var b = 65536; + uint24 b = 65536; uint c = 256; return keccak256(abi.encodePacked(8, input, b, input, c)); } @@ -2113,7 +2132,7 @@ BOOST_AUTO_TEST_CASE(packed_sha256) char const* sourceCode = R"( contract test { function a(bytes32 input) returns (bytes32 hash) { - var b = 65536; + uint24 b = 65536; uint c = 256; return sha256(abi.encodePacked(8, input, b, input, c)); } @@ -2140,7 +2159,7 @@ BOOST_AUTO_TEST_CASE(packed_ripemd160) char const* sourceCode = R"( contract test { function a(bytes32 input) returns (bytes32 hash) { - var b = 65536; + uint24 b = 65536; uint c = 256; return ripemd160(abi.encodePacked(8, input, b, input, c)); } @@ -2319,9 +2338,8 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_with_local_vars) contract Main { Helper h; function callHelper(uint a, uint b) returns (uint c) { - var fu = h.multiply; - var y = 9; - var ret = fu(a, b); + uint8 y = 9; + uint256 ret = h.multiply(a, b); return ret + y; } function getHelper() returns (address haddress) { @@ -2568,10 +2586,8 @@ BOOST_AUTO_TEST_CASE(value_complex) helper h; constructor() payable { h = new helper(); } function sendAmount(uint amount) payable returns (uint256 bal) { - var x1 = h.getBalance.value(amount); uint someStackElement = 20; - var x2 = x1.gas(1000); - return x2.value(amount + 3)();// overwrite value + return h.getBalance.value(amount).gas(1000).value(amount + 3)(); } } )"; @@ -2591,10 +2607,7 @@ BOOST_AUTO_TEST_CASE(value_insane) helper h; constructor() payable { h = new helper(); } function sendAmount(uint amount) returns (uint256 bal) { - var x1 = h.getBalance.value; - var x2 = x1(amount).gas; - var x3 = x2(1000).value; - return x3(amount + 3)();// overwrite value + return h.getBalance.value(amount).gas(1000).value(amount + 3)();// overwrite value } } )"; @@ -2815,7 +2828,7 @@ BOOST_AUTO_TEST_CASE(function_modifier_local_variables) { char const* sourceCode = R"( contract C { - modifier mod1 { var a = 1; var b = 2; _; } + modifier mod1 { uint8 a = 1; uint8 b = 2; _; } modifier mod2(bool a) { if (a) return; else _; } function f(bool a) mod1 mod2(a) returns (uint r) { return 3; } } @@ -2829,7 +2842,7 @@ BOOST_AUTO_TEST_CASE(function_modifier_loop) { char const* sourceCode = R"( contract C { - modifier repeat(uint count) { for (var i = 0; i < count; ++i) _; } + modifier repeat(uint count) { uint i; for (i = 0; i < count; ++i) _; } function f() repeat(10) returns (uint r) { r += 1; } } )"; @@ -3007,8 +3020,7 @@ BOOST_AUTO_TEST_CASE(crazy_elementary_typenames_on_stack) function f() returns (uint r) { uint; uint; uint; uint; int x = -7; - var a = uint; - return a(x); + return uint(x); } } )"; @@ -3106,9 +3118,11 @@ BOOST_AUTO_TEST_CASE(short_data_calls_fallback) compileAndRun(sourceCode); // should call fallback sendMessage(asBytes("\xd8\x8e\x0b"), false, 0); + BOOST_CHECK(m_transactionSuccessful); ABI_CHECK(callContractFunction("x()"), encodeArgs(2)); // should call function sendMessage(asBytes(string("\xd8\x8e\x0b") + string(1, 0)), false, 0); + BOOST_CHECK(m_transactionSuccessful); ABI_CHECK(callContractFunction("x()"), encodeArgs(3)); } @@ -3793,6 +3807,7 @@ BOOST_AUTO_TEST_CASE(bytes_from_calldata_to_memory) compileAndRun(sourceCode); bytes calldata1 = FixedHash<4>(dev::keccak256("f()")).asBytes() + bytes(61, 0x22) + bytes(12, 0x12); sendMessage(calldata1, false); + BOOST_CHECK(m_transactionSuccessful); BOOST_CHECK(m_output == encodeArgs(dev::keccak256(bytes{'a', 'b', 'c'} + calldata1))); } @@ -3928,7 +3943,8 @@ BOOST_AUTO_TEST_CASE(copy_from_calldata_removes_bytes_data) ABI_CHECK(callContractFunction("set()", 1, 2, 3, 4, 5), encodeArgs(true)); BOOST_CHECK(!storageEmpty(m_contractAddress)); sendMessage(bytes(), false); - BOOST_CHECK(m_output == bytes()); + BOOST_CHECK(m_transactionSuccessful); + BOOST_CHECK(m_output.empty()); BOOST_CHECK(storageEmpty(m_contractAddress)); } @@ -4074,7 +4090,7 @@ BOOST_AUTO_TEST_CASE(struct_copy_via_local) function test() returns (bool) { data1.a = 1; data1.b = 2; - var x = data1; + Struct memory x = data1; data2 = x; return data2.a == data1.a && data2.b == data1.b; } @@ -6243,6 +6259,7 @@ BOOST_AUTO_TEST_CASE(evm_exceptions_in_constructor_out_of_baund) } )"; ABI_CHECK(compileAndRunWithoutCheck(sourceCode, 0, "A"), encodeArgs()); + BOOST_CHECK(!m_transactionSuccessful); } BOOST_AUTO_TEST_CASE(positive_integers_to_signed) @@ -6295,7 +6312,7 @@ BOOST_AUTO_TEST_CASE(send_zero_ether) contract Main { constructor() payable {} function s() returns (bool) { - var r = new Receiver(); + Receiver r = new Receiver(); return r.send(0); } } @@ -6578,7 +6595,7 @@ BOOST_AUTO_TEST_CASE(bytes_in_constructors_packer) } contract Creator { function f(uint x, bytes s) returns (uint r, byte ch) { - var c = new Main(s, x); + Main c = new Main(s, x); r = c.m_x(); ch = c.part(x); } @@ -6617,7 +6634,7 @@ BOOST_AUTO_TEST_CASE(arrays_in_constructors) } contract Creator { function f(uint x, address[] s) returns (uint r, address ch) { - var c = new Main(s, x); + Main c = new Main(s, x); r = c.m_x(); ch = c.part(x); } @@ -7369,8 +7386,8 @@ BOOST_AUTO_TEST_CASE(constant_string_literal) string constant public x = "abefghijklmnopqabcdefghijklmnopqabcdefghijklmnopqabca"; constructor() { - var xx = x; - var bb = b; + string memory xx = x; + bytes32 bb = b; } function getB() returns (bytes32) { return b; } function getX() returns (string) { return x; } @@ -7461,7 +7478,7 @@ BOOST_AUTO_TEST_CASE(cross_contract_types) contract Lib { struct S {uint a; uint b; } } contract Test { function f() returns (uint r) { - var x = Lib.S({a: 2, b: 3}); + Lib.S memory x = Lib.S({a: 2, b: 3}); r = x.b; } } @@ -7546,7 +7563,7 @@ BOOST_AUTO_TEST_CASE(fixed_arrays_as_return_type) contract B { function f() returns (uint16[5] res, uint16[5] res2) { - var a = new A(); + A a = new A(); res = a.f(2); res2 = a.f(1000); } @@ -7829,13 +7846,13 @@ BOOST_AUTO_TEST_CASE(multi_variable_declaration) a = 1; b = 2; c = 3; } function f() returns (bool) { - var (x, y, z) = g(); + (uint x, uint y, uint z) = g(); if (x != 1 || y != 2 || z != 3) return false; - var (, a,) = g(); + (, uint a,) = g(); if (a != 2) return false; - var (b,) = g(); + (uint b,) = g(); if (b != 1) return false; - var (,c) = g(); + (, uint c) = g(); if (c != 3) return false; return true; } @@ -8037,11 +8054,11 @@ BOOST_AUTO_TEST_CASE(create_memory_array) contract C { struct S { uint[2] a; bytes b; } function f() returns (byte, uint, uint, byte) { - var x = new bytes(200); + bytes memory x = new bytes(200); x[199] = 'A'; - var y = new uint[2][](300); + uint[2][] memory y = new uint[2][](300); y[203][1] = 8; - var z = new S[](180); + S[] memory z = new S[](180); z[170].a[1] = 4; z[170].b = new bytes(102); z[170].b[99] = 'B'; @@ -8331,8 +8348,7 @@ BOOST_AUTO_TEST_CASE(bound_function_in_var) D.s public x; function f(uint a) returns (uint) { x.a = 6; - var g = x.mul; - return g({x: a}); + return (x.mul)({x: a}); } } )"; @@ -9120,7 +9136,7 @@ BOOST_AUTO_TEST_CASE(skip_dynamic_types) } function g() returns (uint, uint) { // Previous implementation "moved" b to the second place and did not skip. - var (a, _, b) = this.f(); + (uint a,, uint b) = this.f(); return (a, b); } } @@ -9146,7 +9162,7 @@ BOOST_AUTO_TEST_CASE(skip_dynamic_types_for_structs) s.a = "abc"; s.b = [7, 8, 9]; s.y = 6; - var (x, a, y) = this.s(); + (uint x,, uint y) = this.s(); return (x, y); } } @@ -9188,7 +9204,7 @@ BOOST_AUTO_TEST_CASE(create_dynamic_array_with_zero_length) char const* sourceCode = R"( contract C { function f() returns (uint) { - var a = new uint[][](0); + uint[][] memory a = new uint[][](0); return 7; } } @@ -10039,7 +10055,7 @@ BOOST_AUTO_TEST_CASE(function_delete_stack) contract C { function a() returns (uint) { return 7; } function test() returns (uint) { - var y = a; + function () returns (uint) y = a; delete y; y(); } @@ -10077,7 +10093,7 @@ BOOST_AUTO_TEST_CASE(function_array_cross_calls) char const* sourceCode = R"( contract D { function f(function() external returns (function() external returns (uint))[] x) - returns (function() external returns (uint)[3] r) + public returns (function() external returns (uint)[3] r) { r[0] = x[0](); r[1] = x[1](); @@ -10085,23 +10101,23 @@ BOOST_AUTO_TEST_CASE(function_array_cross_calls) } } contract C { - function test() returns (uint, uint, uint) { + function test() public returns (uint, uint, uint) { function() external returns (function() external returns (uint))[] memory x = new function() external returns (function() external returns (uint))[](10); for (uint i = 0; i < x.length; i ++) x[i] = this.h; x[0] = this.htwo; - var y = (new D()).f(x); + function() external returns (uint)[3] memory y = (new D()).f(x); return (y[0](), y[1](), y[2]()); } - function e() returns (uint) { return 5; } - function f() returns (uint) { return 6; } - function g() returns (uint) { return 7; } + function e() public returns (uint) { return 5; } + function f() public returns (uint) { return 6; } + function g() public returns (uint) { return 7; } uint counter; - function h() returns (function() external returns (uint)) { + function h() public returns (function() external returns (uint)) { return counter++ == 0 ? this.f : this.g; } - function htwo() returns (function() external returns (uint)) { + function htwo() public returns (function() external returns (uint)) { return this.e; } } @@ -11230,7 +11246,7 @@ BOOST_AUTO_TEST_CASE(bubble_up_error_messages_through_create) } contract D { function f() public { - var x = new E(); + E x = new E(); } } contract C { @@ -11506,8 +11522,7 @@ BOOST_AUTO_TEST_CASE(function_types_sig) } function h() returns (bytes4) { function () pure external returns (bytes4) fun = this.f; - var funvar = fun; - return funvar.selector; + return fun.selector; } function i() pure returns (bytes4) { return this.x.selector; @@ -11739,8 +11754,8 @@ BOOST_AUTO_TEST_CASE(snark) Pairing.G1Point memory p2; p1.X = 1; p1.Y = 2; p2.X = 1; p2.Y = 2; - var explict_sum = Pairing.add(p1, p2); - var scalar_prod = Pairing.mul(p1, 2); + Pairing.G1Point memory explict_sum = Pairing.add(p1, p2); + Pairing.G1Point memory scalar_prod = Pairing.mul(p1, 2); return (explict_sum.X == scalar_prod.X && explict_sum.Y == scalar_prod.Y); } diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp index 5d5fb218..2668dfdf 100644 --- a/test/libsolidity/SolidityExpressionCompiler.cpp +++ b/test/libsolidity/SolidityExpressionCompiler.cpp @@ -175,7 +175,7 @@ BOOST_AUTO_TEST_CASE(literal_true) { char const* sourceCode = R"( contract test { - function f() { var x = true; } + function f() { bool x = true; } } )"; bytes code = compileFirstExpression(sourceCode); @@ -188,7 +188,7 @@ BOOST_AUTO_TEST_CASE(literal_false) { char const* sourceCode = R"( contract test { - function f() { var x = false; } + function f() { bool x = false; } } )"; bytes code = compileFirstExpression(sourceCode); @@ -201,7 +201,7 @@ BOOST_AUTO_TEST_CASE(int_literal) { char const* sourceCode = R"( contract test { - function f() { var x = 0x12345678901234567890; } + function f() { uint x = 0x12345678901234567890; } } )"; bytes code = compileFirstExpression(sourceCode); @@ -216,7 +216,7 @@ BOOST_AUTO_TEST_CASE(int_with_wei_ether_subdenomination) char const* sourceCode = R"( contract test { constructor() { - var x = 1 wei; + uint x = 1 wei; } } )"; @@ -230,8 +230,8 @@ BOOST_AUTO_TEST_CASE(int_with_szabo_ether_subdenomination) { char const* sourceCode = R"( contract test { - constructor() { - var x = 1 szabo; + function test () { + uint x = 1 szabo; } } )"; @@ -247,7 +247,7 @@ BOOST_AUTO_TEST_CASE(int_with_finney_ether_subdenomination) contract test { constructor() { - var x = 1 finney; + uint x = 1 finney; } } )"; @@ -262,7 +262,7 @@ BOOST_AUTO_TEST_CASE(int_with_ether_ether_subdenomination) char const* sourceCode = R"( contract test { constructor() { - var x = 1 ether; + uint x = 1 ether; } } )"; @@ -276,7 +276,7 @@ BOOST_AUTO_TEST_CASE(comparison) { char const* sourceCode = R"( contract test { - function f() { var x = (0x10aa < 0x11aa) != true; } + function f() { bool x = (0x10aa < 0x11aa) != true; } } )"; bytes code = compileFirstExpression(sourceCode); @@ -294,7 +294,7 @@ BOOST_AUTO_TEST_CASE(short_circuiting) { char const* sourceCode = R"( contract test { - function f() { var x = true != (4 <= 8 + 10 || 9 != 2); } + function f() { bool x = true != (4 <= 8 + 10 || 9 != 2); } } )"; bytes code = compileFirstExpression(sourceCode); @@ -490,7 +490,7 @@ BOOST_AUTO_TEST_CASE(intermediately_overflowing_literals) // have been applied char const* sourceCode = R"( contract test { - function f() { var x = (0x00ffffffffffffffffffffffffffffffffffffffff * 0xffffffffffffffffffffffffff01) & 0xbf; } + function f() { uint8 x = (0x00ffffffffffffffffffffffffffffffffffffffff * 0xffffffffffffffffffffffffff01) & 0xbf; } } )"; bytes code = compileFirstExpression(sourceCode); diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 153a7afb..ff0a45f0 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -352,16 +352,16 @@ BOOST_AUTO_TEST_CASE(dynamic_return_types_not_possible) contract C { function f(uint) public returns (string); function g() public { - var x = this.f(2); + string memory x = this.f(2); // we can assign to x but it is not usable. bytes(x).length; } } )"; if (dev::test::Options::get().evmVersion() == EVMVersion::homestead()) - CHECK_ERROR(sourceCode, TypeError, "Explicit type conversion not allowed from \"inaccessible dynamic type\" to \"bytes storage pointer\"."); + CHECK_ERROR(sourceCode, TypeError, "Type inaccessible dynamic type is not implicitly convertible to expected type string memory."); else - CHECK_WARNING(sourceCode, "Use of the \"var\" keyword is deprecated"); + CHECK_SUCCESS_NO_WARNINGS(sourceCode); } BOOST_AUTO_TEST_CASE(warn_nonpresent_pragma) diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp index 805c8602..04d9ee16 100644 --- a/test/libsolidity/SolidityOptimizer.cpp +++ b/test/libsolidity/SolidityOptimizer.cpp @@ -246,7 +246,7 @@ BOOST_AUTO_TEST_CASE(storage_write_in_loops) contract test { uint d; function f(uint a) returns (uint r) { - var x = d; + uint x = d; for (uint i = 1; i < a * a; i++) { r = d; d = i; diff --git a/test/libsolidity/syntaxTests/constructor/constructor_no_visibility.sol b/test/libsolidity/syntaxTests/constructor/constructor_no_visibility.sol index f8820fdc..88553084 100644 --- a/test/libsolidity/syntaxTests/constructor/constructor_no_visibility.sol +++ b/test/libsolidity/syntaxTests/constructor/constructor_no_visibility.sol @@ -1,3 +1,3 @@ contract A { constructor() {} } // ---- -// Warning: (13-29): No visibility specified. Defaulting to "public". +// Warning: (13-29): No visibility specified. Defaulting to "public". diff --git a/test/libsolidity/syntaxTests/fallback/default_visibility.sol b/test/libsolidity/syntaxTests/fallback/default_visibility.sol index 2cb0af90..f45bbd3c 100644 --- a/test/libsolidity/syntaxTests/fallback/default_visibility.sol +++ b/test/libsolidity/syntaxTests/fallback/default_visibility.sol @@ -3,4 +3,4 @@ contract C { function() {} } // ---- -// Warning: (90-103): No visibility specified. Defaulting to "public". +// Warning: (90-103): No visibility specified. Defaulting to "public". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/040_functions_with_different_structs_in_interface.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/040_functions_with_different_structs_in_interface.sol index 2af584b7..1689e6f5 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/040_functions_with_different_structs_in_interface.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/040_functions_with_different_structs_in_interface.sol @@ -3,10 +3,8 @@ pragma experimental ABIEncoderV2; contract C { struct S1 { function() external a; } struct S2 { bytes24 a; } - function f(S1) pure {} - function f(S2) pure {} + function f(S1) public pure {} + function f(S2) public pure {} } // ---- // Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. -// Warning: (122-144): No visibility specified. Defaulting to "public". -// Warning: (149-171): No visibility specified. Defaulting to "public". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/124_enum_member_access.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/124_enum_member_access.sol index 3fd7a0cb..98bc8e66 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/124_enum_member_access.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/124_enum_member_access.sol @@ -1,10 +1,8 @@ contract test { enum ActionChoices { GoLeft, GoRight, GoStraight, Sit } - constructor() + constructor() public { choices = ActionChoices.GoStraight; } ActionChoices choices; } -// ---- -// Warning: (80-149): No visibility specified. Defaulting to "public". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/239_multi_variable_declaration_wildcards_fine.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/239_multi_variable_declaration_wildcards_fine.sol index ae260ce4..0da5c7ee 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/239_multi_variable_declaration_wildcards_fine.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/239_multi_variable_declaration_wildcards_fine.sol @@ -1,7 +1,7 @@ contract C { function three() public returns (uint, uint, uint); function two() public returns (uint, uint); - function none(); + function none() public; function f() public { (uint a,) = three(); (uint b, uint c,) = two(); @@ -13,8 +13,7 @@ contract C { } } // ---- -// Warning: (172-191): Different number of components on the left hand side (2) than on the right hand side (3). -// Warning: (201-226): Different number of components on the left hand side (3) than on the right hand side (2). -// Warning: (236-255): Different number of components on the left hand side (2) than on the right hand side (3). -// Warning: (265-290): Different number of components on the left hand side (3) than on the right hand side (2). -// Warning: (121-137): No visibility specified. Defaulting to "public". +// Warning: (179-198): Different number of components on the left hand side (2) than on the right hand side (3). +// Warning: (208-233): Different number of components on the left hand side (3) than on the right hand side (2). +// Warning: (243-262): Different number of components on the left hand side (2) than on the right hand side (3). +// Warning: (272-297): Different number of components on the left hand side (3) than on the right hand side (2). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/268_function_overload_array_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/268_function_overload_array_type.sol index 0ff1ed75..97e68aa3 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/268_function_overload_array_type.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/268_function_overload_array_type.sol @@ -1,7 +1,4 @@ - contract M { - function f(uint[]); - function f(int[]); - } -// ---- -// Warning: (25-44): No visibility specified. Defaulting to "public". -// Warning: (53-71): No visibility specified. Defaulting to "public". +contract M { + function f(uint[]) public; + function f(int[]) public; +} diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/275_inline_struct_declaration_arrays.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/275_inline_struct_declaration_arrays.sol index e69c2934..bdf033a3 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/275_inline_struct_declaration_arrays.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/275_inline_struct_declaration_arrays.sol @@ -3,11 +3,10 @@ contract C { uint a; string b; } - function f() { + function f() public { S[2] memory x = [S({a: 1, b: "fish"}), S({a: 2, b: "fish"})]; } } // ---- -// Warning: (72-162): No visibility specified. Defaulting to "public". -// Warning: (95-108): Unused local variable. -// Warning: (72-162): Function state mutability can be restricted to pure +// Warning: (102-115): Unused local variable. +// Warning: (72-169): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/403_return_structs.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/403_return_structs.sol index 5583dbff..8af8098c 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/403_return_structs.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/403_return_structs.sol @@ -2,10 +2,9 @@ pragma experimental ABIEncoderV2; contract C { struct S { uint a; T[] sub; } struct T { uint[] x; } - function f() returns (uint, S) { + function f() public returns (uint, S) { } } // ---- // Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. -// Warning: (112-150): No visibility specified. Defaulting to "public". -// Warning: (112-150): Function state mutability can be restricted to pure +// Warning: (112-157): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/423_using_interface.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/423_using_interface.sol index f06ffa62..d576bb60 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/423_using_interface.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/423_using_interface.sol @@ -1,10 +1,8 @@ interface I { - function f(); + function f() external; } contract C is I { function f() public { } } // ---- -// Warning: (18-31): Functions in interfaces should be declared external. -// Warning: (18-31): No visibility specified. Defaulting to "public". In interfaces it defaults to external. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/535_address_overload_resolution.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/535_address_overload_resolution.sol index 35f4639e..157ea36b 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/535_address_overload_resolution.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/535_address_overload_resolution.sol @@ -1,21 +1,18 @@ contract C { - function balance() returns (uint) { + function balance() public returns (uint) { this.balance; // to avoid pureness warning return 1; } - function transfer(uint amount) { + function transfer(uint amount) public { address(this).transfer(amount); // to avoid pureness warning } } contract D { - function f() { + function f() public { uint x = (new C()).balance(); x; (new C()).transfer(5); } } // ---- -// Warning: (17-127): No visibility specified. Defaulting to "public". -// Warning: (132-239): No visibility specified. Defaulting to "public". -// Warning: (259-359): No visibility specified. Defaulting to "public". -// Warning: (17-127): Function state mutability can be restricted to view +// Warning: (17-134): Function state mutability can be restricted to view diff --git a/test/libsolidity/syntaxTests/parsing/calling_function.sol b/test/libsolidity/syntaxTests/parsing/calling_function.sol index 4c4fc1fc..9e88c451 100644 --- a/test/libsolidity/syntaxTests/parsing/calling_function.sol +++ b/test/libsolidity/syntaxTests/parsing/calling_function.sol @@ -1,9 +1,7 @@ contract test { - function f() { + function f() public { function() returns(function() returns(function() returns(function() returns(uint)))) x; uint y; y = x()()()(); } } -// ---- -// Warning: (20-175): No visibility specified. Defaulting to "public". diff --git a/test/libsolidity/syntaxTests/parsing/conditional_multiple.sol b/test/libsolidity/syntaxTests/parsing/conditional_multiple.sol index c7d11ed6..0e348f5b 100644 --- a/test/libsolidity/syntaxTests/parsing/conditional_multiple.sol +++ b/test/libsolidity/syntaxTests/parsing/conditional_multiple.sol @@ -1,9 +1,8 @@ contract A { - function f() { + function f() public { uint x = 3 < 0 ? 2 > 1 ? 2 : 1 : 7 > 2 ? 7 : 6; } } // ---- -// Warning: (17-93): No visibility specified. Defaulting to "public". -// Warning: (40-46): Unused local variable. -// Warning: (17-93): Function state mutability can be restricted to pure +// Warning: (47-53): Unused local variable. +// Warning: (17-100): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/conditional_true_false_literal.sol b/test/libsolidity/syntaxTests/parsing/conditional_true_false_literal.sol index 90974e96..40aaa917 100644 --- a/test/libsolidity/syntaxTests/parsing/conditional_true_false_literal.sol +++ b/test/libsolidity/syntaxTests/parsing/conditional_true_false_literal.sol @@ -1,11 +1,10 @@ contract A { - function f() { + function f() public { uint x = true ? 1 : 0; uint y = false ? 0 : 1; } } // ---- -// Warning: (17-100): No visibility specified. Defaulting to "public". -// Warning: (40-46): Unused local variable. -// Warning: (71-77): Unused local variable. -// Warning: (17-100): Function state mutability can be restricted to pure +// Warning: (47-53): Unused local variable. +// Warning: (78-84): Unused local variable. +// Warning: (17-107): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/conditional_with_constants.sol b/test/libsolidity/syntaxTests/parsing/conditional_with_constants.sol index 35da69c6..705fbadf 100644 --- a/test/libsolidity/syntaxTests/parsing/conditional_with_constants.sol +++ b/test/libsolidity/syntaxTests/parsing/conditional_with_constants.sol @@ -1,11 +1,10 @@ contract A { - function f() { + function f() public { uint x = 3 > 0 ? 3 : 0; uint y = (3 > 0) ? 3 : 0; } } // ---- -// Warning: (17-103): No visibility specified. Defaulting to "public". -// Warning: (40-46): Unused local variable. -// Warning: (72-78): Unused local variable. -// Warning: (17-103): Function state mutability can be restricted to pure +// Warning: (47-53): Unused local variable. +// Warning: (79-85): Unused local variable. +// Warning: (17-110): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/conditional_with_variables.sol b/test/libsolidity/syntaxTests/parsing/conditional_with_variables.sol index eb4c7091..bbabf957 100644 --- a/test/libsolidity/syntaxTests/parsing/conditional_with_variables.sol +++ b/test/libsolidity/syntaxTests/parsing/conditional_with_variables.sol @@ -1,5 +1,5 @@ contract A { - function f() { + function f() public { uint x = 3; uint y = 1; uint z = (x > y) ? x : y; @@ -7,7 +7,6 @@ contract A { } } // ---- -// Warning: (17-143): No visibility specified. Defaulting to "public". -// Warning: (80-86): Unused local variable. -// Warning: (114-120): Unused local variable. -// Warning: (17-143): Function state mutability can be restricted to pure +// Warning: (87-93): Unused local variable. +// Warning: (121-127): Unused local variable. +// Warning: (17-150): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/declaring_fixed_and_ufixed_variables.sol b/test/libsolidity/syntaxTests/parsing/declaring_fixed_and_ufixed_variables.sol index 8be9667a..6d88669a 100644 --- a/test/libsolidity/syntaxTests/parsing/declaring_fixed_and_ufixed_variables.sol +++ b/test/libsolidity/syntaxTests/parsing/declaring_fixed_and_ufixed_variables.sol @@ -1,14 +1,13 @@ contract A { fixed40x40 storeMe; - function f(ufixed x, fixed32x32 y) { + function f(ufixed x, fixed32x32 y) public { ufixed8x8 a; fixed b; } } // ---- -// Warning: (41-121): No visibility specified. Defaulting to "public". // Warning: (52-60): Unused function parameter. Remove or comment out the variable name to silence this warning. // Warning: (62-74): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (86-97): Unused local variable. -// Warning: (107-114): Unused local variable. -// Warning: (41-121): Function state mutability can be restricted to pure +// Warning: (93-104): Unused local variable. +// Warning: (114-121): Unused local variable. +// Warning: (41-128): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/else_if_statement.sol b/test/libsolidity/syntaxTests/parsing/else_if_statement.sol index 37763697..c2a1aaeb 100644 --- a/test/libsolidity/syntaxTests/parsing/else_if_statement.sol +++ b/test/libsolidity/syntaxTests/parsing/else_if_statement.sol @@ -1,8 +1,7 @@ contract test { - function fun(uint256 a) returns (uint8 b) { + function fun(uint256 a) public returns (uint8 b) { if (a < 0) b = 0x67; else if (a == 0) b = 0x12; else b = 0x78; } } // ---- -// Warning: (20-140): No visibility specified. Defaulting to "public". -// Warning: (20-140): Function state mutability can be restricted to pure +// Warning: (20-147): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/empty_function.sol b/test/libsolidity/syntaxTests/parsing/empty_function.sol index 218fd9a7..320a0bcc 100644 --- a/test/libsolidity/syntaxTests/parsing/empty_function.sol +++ b/test/libsolidity/syntaxTests/parsing/empty_function.sol @@ -1,10 +1,9 @@ contract test { uint256 stateVar; - function functionName(bytes20 arg1, address addr) view returns (int id) { } + function functionName(bytes20 arg1, address addr) public view returns (int id) { } } // ---- -// Warning: (36-111): No visibility specified. Defaulting to "public". // Warning: (58-70): Unused function parameter. Remove or comment out the variable name to silence this warning. // Warning: (72-84): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (100-106): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (36-111): Function state mutability can be restricted to pure +// Warning: (107-113): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (36-118): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/enum_valid_declaration.sol b/test/libsolidity/syntaxTests/parsing/enum_valid_declaration.sol index 602c26ed..606f59d7 100644 --- a/test/libsolidity/syntaxTests/parsing/enum_valid_declaration.sol +++ b/test/libsolidity/syntaxTests/parsing/enum_valid_declaration.sol @@ -1,9 +1,7 @@ contract c { enum validEnum { Value1, Value2, Value3, Value4 } - constructor() { + constructor() public { a = validEnum.Value3; } validEnum a; } -// ---- -// Warning: (71-122): No visibility specified. Defaulting to "public". diff --git a/test/libsolidity/syntaxTests/parsing/exp_expression.sol b/test/libsolidity/syntaxTests/parsing/exp_expression.sol index cdabb996..6b307ea0 100644 --- a/test/libsolidity/syntaxTests/parsing/exp_expression.sol +++ b/test/libsolidity/syntaxTests/parsing/exp_expression.sol @@ -1,9 +1,8 @@ contract test { - function fun(uint256 a) { + function fun(uint256 a) public { uint256 x = 3 ** a; } } // ---- -// Warning: (20-79): No visibility specified. Defaulting to "public". -// Warning: (54-63): Unused local variable. -// Warning: (20-79): Function state mutability can be restricted to pure +// Warning: (61-70): Unused local variable. +// Warning: (20-86): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/for_loop_simple_initexpr.sol b/test/libsolidity/syntaxTests/parsing/for_loop_simple_initexpr.sol index bd86f2f5..fce669dd 100644 --- a/test/libsolidity/syntaxTests/parsing/for_loop_simple_initexpr.sol +++ b/test/libsolidity/syntaxTests/parsing/for_loop_simple_initexpr.sol @@ -1,5 +1,5 @@ contract test { - function fun(uint256 a) { + function fun(uint256 a) public { uint256 i =0; for (i = 0; i < 10; i++) { uint256 x = i; break; continue; @@ -7,7 +7,6 @@ contract test { } } // ---- -// Warning: (20-162): No visibility specified. Defaulting to "public". // Warning: (33-42): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (115-124): Unused local variable. -// Warning: (20-162): Function state mutability can be restricted to pure +// Warning: (122-131): Unused local variable. +// Warning: (20-169): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/for_loop_simple_noexpr.sol b/test/libsolidity/syntaxTests/parsing/for_loop_simple_noexpr.sol index 4a27e0fb..4adf0948 100644 --- a/test/libsolidity/syntaxTests/parsing/for_loop_simple_noexpr.sol +++ b/test/libsolidity/syntaxTests/parsing/for_loop_simple_noexpr.sol @@ -1,5 +1,5 @@ contract test { - function fun(uint256 a) { + function fun(uint256 a) public { uint256 i =0; for (;;) { uint256 x = i; break; continue; @@ -7,7 +7,6 @@ contract test { } } // ---- -// Warning: (24-170): No visibility specified. Defaulting to "public". // Warning: (37-46): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (115-124): Unused local variable. -// Warning: (24-170): Function state mutability can be restricted to pure +// Warning: (122-131): Unused local variable. +// Warning: (24-177): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/for_loop_single_stmt_body.sol b/test/libsolidity/syntaxTests/parsing/for_loop_single_stmt_body.sol index 3df88ef5..c6af519c 100644 --- a/test/libsolidity/syntaxTests/parsing/for_loop_single_stmt_body.sol +++ b/test/libsolidity/syntaxTests/parsing/for_loop_single_stmt_body.sol @@ -1,11 +1,10 @@ contract test { - function fun(uint256 a) { + function fun(uint256 a) public { uint256 i = 0; for (i = 0; i < 10; i++) continue; } } // ---- -// Warning: (20-129): No visibility specified. Defaulting to "public". // Warning: (33-42): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (20-129): Function state mutability can be restricted to pure +// Warning: (20-136): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/for_loop_vardef_initexpr.sol b/test/libsolidity/syntaxTests/parsing/for_loop_vardef_initexpr.sol index a7c5e8bb..c22ae42f 100644 --- a/test/libsolidity/syntaxTests/parsing/for_loop_vardef_initexpr.sol +++ b/test/libsolidity/syntaxTests/parsing/for_loop_vardef_initexpr.sol @@ -1,12 +1,11 @@ contract test { - function fun(uint256 a) { + function fun(uint256 a) public { for (uint256 i = 0; i < 10; i++) { uint256 x = i; break; continue; } } } // ---- -// Warning: (20-148): No visibility specified. Defaulting to "public". // Warning: (33-42): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (101-110): Unused local variable. -// Warning: (20-148): Function state mutability can be restricted to pure +// Warning: (108-117): Unused local variable. +// Warning: (20-155): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/function_no_body.sol b/test/libsolidity/syntaxTests/parsing/function_no_body.sol index 0424ebd8..c4a686dc 100644 --- a/test/libsolidity/syntaxTests/parsing/function_no_body.sol +++ b/test/libsolidity/syntaxTests/parsing/function_no_body.sol @@ -1,5 +1,3 @@ contract test { - function functionName(bytes32 input) returns (bytes32 out); + function functionName(bytes32 input) public returns (bytes32 out); } -// ---- -// Warning: (17-76): No visibility specified. Defaulting to "public". diff --git a/test/libsolidity/syntaxTests/parsing/function_normal_comments.sol b/test/libsolidity/syntaxTests/parsing/function_normal_comments.sol index c7a023ac..94e1e60a 100644 --- a/test/libsolidity/syntaxTests/parsing/function_normal_comments.sol +++ b/test/libsolidity/syntaxTests/parsing/function_normal_comments.sol @@ -1,10 +1,9 @@ contract test { uint256 stateVar; // We won't see this comment - function functionName(bytes32 input) returns (bytes32 out) {} + function functionName(bytes32 input) public returns (bytes32 out) {} } // ---- -// Warning: (75-136): No visibility specified. Defaulting to "public". // Warning: (97-110): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (121-132): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (75-136): Function state mutability can be restricted to pure +// Warning: (128-139): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (75-143): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_assignment.sol b/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_assignment.sol index 3b784733..11e77f25 100644 --- a/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_assignment.sol +++ b/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_assignment.sol @@ -1,10 +1,9 @@ contract test { - function f(uint x, uint y) returns (uint a) {} + function f(uint x, uint y) public returns (uint a) {} function (uint, uint) internal returns (uint) f1 = f; } // ---- -// Warning: (20-66): No visibility specified. Defaulting to "public". // Warning: (31-37): Unused function parameter. Remove or comment out the variable name to silence this warning. // Warning: (39-45): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (56-62): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (20-66): Function state mutability can be restricted to pure +// Warning: (63-69): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (20-73): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/function_type_in_expression.sol b/test/libsolidity/syntaxTests/parsing/function_type_in_expression.sol index fd6447c7..3defb5ea 100644 --- a/test/libsolidity/syntaxTests/parsing/function_type_in_expression.sol +++ b/test/libsolidity/syntaxTests/parsing/function_type_in_expression.sol @@ -1,15 +1,13 @@ contract test { - function f(uint x, uint y) returns (uint a) {} - function g() { + function f(uint x, uint y) public returns (uint a) {} + function g() public { function (uint, uint) internal returns (uint) f1 = f; } } // ---- -// Warning: (20-66): No visibility specified. Defaulting to "public". // Warning: (31-37): Unused function parameter. Remove or comment out the variable name to silence this warning. // Warning: (39-45): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (56-62): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (71-153): No visibility specified. Defaulting to "public". -// Warning: (94-142): Unused local variable. -// Warning: (20-66): Function state mutability can be restricted to pure -// Warning: (71-153): Function state mutability can be restricted to pure +// Warning: (63-69): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (108-156): Unused local variable. +// Warning: (20-73): Function state mutability can be restricted to pure +// Warning: (78-167): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/if_statement.sol b/test/libsolidity/syntaxTests/parsing/if_statement.sol index 451fba1f..b3269785 100644 --- a/test/libsolidity/syntaxTests/parsing/if_statement.sol +++ b/test/libsolidity/syntaxTests/parsing/if_statement.sol @@ -1,9 +1,8 @@ contract test { - function fun(uint256 a) returns (uint) { + function fun(uint256 a) public returns (uint) { if (a >= 8) { return 2; } else { uint b = 7; } } } // ---- -// Warning: (20-121): No visibility specified. Defaulting to "public". -// Warning: (102-108): Unused local variable. -// Warning: (20-121): Function state mutability can be restricted to pure +// Warning: (109-115): Unused local variable. +// Warning: (20-128): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/inline_array_declaration.sol b/test/libsolidity/syntaxTests/parsing/inline_array_declaration.sol index f42f8f16..4730f950 100644 --- a/test/libsolidity/syntaxTests/parsing/inline_array_declaration.sol +++ b/test/libsolidity/syntaxTests/parsing/inline_array_declaration.sol @@ -1,9 +1,8 @@ contract c { uint[] a; - function f() returns (uint, uint) { + function f() public returns (uint, uint) { a = [1,2,3]; return (a[3], [2,3,4][0]); } } // ---- -// Warning: (31-128): No visibility specified. Defaulting to "public". diff --git a/test/libsolidity/syntaxTests/parsing/interface_basic.sol b/test/libsolidity/syntaxTests/parsing/interface_basic.sol index c25b48ba..2363eaa8 100644 --- a/test/libsolidity/syntaxTests/parsing/interface_basic.sol +++ b/test/libsolidity/syntaxTests/parsing/interface_basic.sol @@ -1,6 +1,5 @@ interface Interface { - function f(); + function f() public; } // ---- -// Warning: (23-36): Functions in interfaces should be declared external. -// Warning: (23-36): No visibility specified. Defaulting to "public". In interfaces it defaults to external. +// Warning: (23-43): Functions in interfaces should be declared external. diff --git a/test/libsolidity/syntaxTests/parsing/library_simple.sol b/test/libsolidity/syntaxTests/parsing/library_simple.sol index fcf2638e..006ff307 100644 --- a/test/libsolidity/syntaxTests/parsing/library_simple.sol +++ b/test/libsolidity/syntaxTests/parsing/library_simple.sol @@ -1,6 +1,5 @@ library Lib { - function f() { } + function f() public { } } // ---- -// Warning: (18-34): No visibility specified. Defaulting to "public". -// Warning: (18-34): Function state mutability can be restricted to pure +// Warning: (18-41): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations.sol b/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations.sol index 452b52c7..64116b88 100644 --- a/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations.sol +++ b/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations.sol @@ -1,5 +1,5 @@ contract c { - function f() + function f() public { a = 1 wei; b = 2 szabo; @@ -12,5 +12,4 @@ contract c { uint256 d; } // ---- -// Warning: (163-172): This declaration shadows an existing declaration. -// Warning: (17-128): No visibility specified. Defaulting to "public". +// Warning: (170-179): This declaration shadows an existing declaration. diff --git a/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations_in_expressions.sol b/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations_in_expressions.sol index e0f49fbf..2f2302ed 100644 --- a/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations_in_expressions.sol +++ b/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations_in_expressions.sol @@ -1,9 +1,7 @@ contract c { - constructor() + constructor() public { a = 1 wei * 100 wei + 7 szabo - 3; } uint256 a; } -// ---- -// Warning: (17-86): No visibility specified. Defaulting to "public". diff --git a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals.sol b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals.sol index 5d6c8dc5..e311dd96 100644 --- a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals.sol +++ b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals.sol @@ -1,12 +1,11 @@ contract Foo { - function f() { + function f() public { uint[] storage x; uint[] memory y; } } // ---- -// Warning: (42-58): Uninitialized storage pointer. -// Warning: (19-90): No visibility specified. Defaulting to "public". -// Warning: (42-58): Unused local variable. -// Warning: (68-83): Unused local variable. -// Warning: (19-90): Function state mutability can be restricted to pure +// Warning: (49-65): Uninitialized storage pointer. +// Warning: (49-65): Unused local variable. +// Warning: (75-90): Unused local variable. +// Warning: (19-97): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/modifier_invocation.sol b/test/libsolidity/syntaxTests/parsing/modifier_invocation.sol index cb2f2985..cf986efe 100644 --- a/test/libsolidity/syntaxTests/parsing/modifier_invocation.sol +++ b/test/libsolidity/syntaxTests/parsing/modifier_invocation.sol @@ -1,8 +1,7 @@ contract c { modifier mod1(uint a) { if (msg.sender == address(a)) _; } modifier mod2 { if (msg.sender == address(2)) _; } - function f() mod1(7) mod2 { } + function f() public mod1(7) mod2 { } } // ---- -// Warning: (135-164): No visibility specified. Defaulting to "public". -// Warning: (135-164): Function state mutability can be restricted to view +// Warning: (135-171): Function state mutability can be restricted to view diff --git a/test/libsolidity/syntaxTests/parsing/multiple_functions_natspec_documentation.sol b/test/libsolidity/syntaxTests/parsing/multiple_functions_natspec_documentation.sol index 95a4d1e7..85d9e6a8 100644 --- a/test/libsolidity/syntaxTests/parsing/multiple_functions_natspec_documentation.sol +++ b/test/libsolidity/syntaxTests/parsing/multiple_functions_natspec_documentation.sol @@ -1,28 +1,24 @@ contract test { uint256 stateVar; /// This is test function 1 - function functionName1(bytes32 input) returns (bytes32 out) {} + function functionName1(bytes32 input) public returns (bytes32 out) {} /// This is test function 2 - function functionName2(bytes32 input) returns (bytes32 out) {} + function functionName2(bytes32 input) public returns (bytes32 out) {} // nothing to see here - function functionName3(bytes32 input) returns (bytes32 out) {} + function functionName3(bytes32 input) public returns (bytes32 out) {} /// This is test function 4 - function functionName4(bytes32 input) returns (bytes32 out) {} + function functionName4(bytes32 input) public returns (bytes32 out) {} } // ---- -// Warning: (74-136): No visibility specified. Defaulting to "public". // Warning: (97-110): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (121-132): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (173-235): No visibility specified. Defaulting to "public". -// Warning: (196-209): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (220-231): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (267-329): No visibility specified. Defaulting to "public". -// Warning: (290-303): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (314-325): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (366-428): No visibility specified. Defaulting to "public". -// Warning: (389-402): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (413-424): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (74-136): Function state mutability can be restricted to pure -// Warning: (173-235): Function state mutability can be restricted to pure -// Warning: (267-329): Function state mutability can be restricted to pure -// Warning: (366-428): Function state mutability can be restricted to pure +// Warning: (128-139): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (203-216): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (234-245): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (304-317): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (335-346): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (410-423): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (441-452): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (74-143): Function state mutability can be restricted to pure +// Warning: (180-249): Function state mutability can be restricted to pure +// Warning: (281-350): Function state mutability can be restricted to pure +// Warning: (387-456): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/no_function_params.sol b/test/libsolidity/syntaxTests/parsing/no_function_params.sol index 020f1233..5a024bdb 100644 --- a/test/libsolidity/syntaxTests/parsing/no_function_params.sol +++ b/test/libsolidity/syntaxTests/parsing/no_function_params.sol @@ -1,7 +1,6 @@ contract test { uint256 stateVar; - function functionName() {} + function functionName() public {} } // ---- -// Warning: (36-62): No visibility specified. Defaulting to "public". -// Warning: (36-62): Function state mutability can be restricted to pure +// Warning: (36-69): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/overloaded_functions.sol b/test/libsolidity/syntaxTests/parsing/overloaded_functions.sol index 1a78d155..fe050d1b 100644 --- a/test/libsolidity/syntaxTests/parsing/overloaded_functions.sol +++ b/test/libsolidity/syntaxTests/parsing/overloaded_functions.sol @@ -1,9 +1,7 @@ contract test { - function fun(uint a) returns(uint r) { return a; } - function fun(uint a, uint b) returns(uint r) { return a + b; } + function fun(uint a) public returns(uint r) { return a; } + function fun(uint a, uint b) public returns(uint r) { return a + b; } } // ---- -// Warning: (17-67): No visibility specified. Defaulting to "public". -// Warning: (69-131): No visibility specified. Defaulting to "public". -// Warning: (17-67): Function state mutability can be restricted to pure -// Warning: (69-131): Function state mutability can be restricted to pure +// Warning: (17-74): Function state mutability can be restricted to pure +// Warning: (76-145): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/placeholder_in_function_context.sol b/test/libsolidity/syntaxTests/parsing/placeholder_in_function_context.sol index e331440d..a50855c0 100644 --- a/test/libsolidity/syntaxTests/parsing/placeholder_in_function_context.sol +++ b/test/libsolidity/syntaxTests/parsing/placeholder_in_function_context.sol @@ -1,9 +1,8 @@ contract c { - function fun() returns (uint r) { + function fun() public returns (uint r) { uint _ = 8; return _ + 1; } } // ---- -// Warning: (17-98): No visibility specified. Defaulting to "public". -// Warning: (17-98): Function state mutability can be restricted to pure +// Warning: (17-105): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/single_function_param.sol b/test/libsolidity/syntaxTests/parsing/single_function_param.sol index 08e531f1..955f20f0 100644 --- a/test/libsolidity/syntaxTests/parsing/single_function_param.sol +++ b/test/libsolidity/syntaxTests/parsing/single_function_param.sol @@ -1,9 +1,8 @@ contract test { uint256 stateVar; - function functionName(bytes32 input) returns (bytes32 out) {} + function functionName(bytes32 input) public returns (bytes32 out) {} } // ---- -// Warning: (36-97): No visibility specified. Defaulting to "public". // Warning: (58-71): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (82-93): Unused function parameter. Remove or comment out the variable name to silence this warning. -// Warning: (36-97): Function state mutability can be restricted to pure +// Warning: (89-100): Unused function parameter. Remove or comment out the variable name to silence this warning. +// Warning: (36-104): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/tuples.sol b/test/libsolidity/syntaxTests/parsing/tuples.sol index d691da44..8266c94f 100644 --- a/test/libsolidity/syntaxTests/parsing/tuples.sol +++ b/test/libsolidity/syntaxTests/parsing/tuples.sol @@ -1,5 +1,5 @@ contract C { - function f() { + function f() public { uint a = (1); (uint b,) = (1,); (uint c, uint d) = (1, 2 + a); @@ -8,10 +8,9 @@ contract C { } } // ---- -// Warning: (47-63): Different number of components on the left hand side (2) than on the right hand side (1). -// Warning: (100-121): Different number of components on the left hand side (2) than on the right hand side (3). -// Warning: (14-136): No visibility specified. Defaulting to "public". -// Warning: (68-74): Unused local variable. -// Warning: (76-82): Unused local variable. -// Warning: (101-107): Unused local variable. -// Warning: (14-136): Function state mutability can be restricted to pure +// Warning: (54-70): Different number of components on the left hand side (2) than on the right hand side (1). +// Warning: (107-128): Different number of components on the left hand side (2) than on the right hand side (3). +// Warning: (75-81): Unused local variable. +// Warning: (83-89): Unused local variable. +// Warning: (108-114): Unused local variable. +// Warning: (14-143): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/parsing/visibility_specifiers.sol b/test/libsolidity/syntaxTests/parsing/visibility_specifiers.sol index 4706a26d..db890b37 100644 --- a/test/libsolidity/syntaxTests/parsing/visibility_specifiers.sol +++ b/test/libsolidity/syntaxTests/parsing/visibility_specifiers.sol @@ -3,15 +3,12 @@ contract c { uint internal b; uint public c; uint d; - function f() {} + function f() public {} function f_priv() private {} - function f_public() public {} function f_internal() internal {} } // ---- // Warning: (58-71): This declaration shadows an existing declaration. -// Warning: (89-104): No visibility specified. Defaulting to "public". -// Warning: (89-104): Function state mutability can be restricted to pure -// Warning: (109-137): Function state mutability can be restricted to pure -// Warning: (142-171): Function state mutability can be restricted to pure -// Warning: (176-209): Function state mutability can be restricted to pure +// Warning: (89-111): Function state mutability can be restricted to pure +// Warning: (116-144): Function state mutability can be restricted to pure +// Warning: (149-182): Function state mutability can be restricted to pure diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/566_require_visibility_specifiers.sol b/test/libsolidity/syntaxTests/visibility/function_no_visibility.sol index 7330ef8d..ecc36f04 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/566_require_visibility_specifiers.sol +++ b/test/libsolidity/syntaxTests/visibility/function_no_visibility.sol @@ -2,4 +2,4 @@ contract C { function f() pure { } } // ---- -// Warning: (17-38): No visibility specified. Defaulting to "public". +// Warning: (17-38): No visibility specified. Defaulting to "public". diff --git a/test/libsolidity/syntaxTests/visibility/function_no_visibility_050.sol b/test/libsolidity/syntaxTests/visibility/function_no_visibility_050.sol new file mode 100644 index 00000000..ec7c0937 --- /dev/null +++ b/test/libsolidity/syntaxTests/visibility/function_no_visibility_050.sol @@ -0,0 +1,6 @@ +pragma experimental "v0.5.0"; +contract C { + function f() pure { } +} +// ---- +// SyntaxError: (47-68): No visibility specified. |