aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/contracts/AuctionRegistrar.cpp36
-rw-r--r--test/contracts/FixedFeeRegistrar.cpp30
-rw-r--r--test/contracts/Wallet.cpp14
-rw-r--r--test/libsolidity/ABIDecoderTests.cpp2
-rw-r--r--test/libsolidity/GasMeter.cpp26
-rw-r--r--test/libsolidity/Metadata.cpp14
-rw-r--r--test/libsolidity/SolidityABIJSON.cpp20
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp150
-rw-r--r--test/libsolidity/SolidityOptimizer.cpp6
-rw-r--r--test/libsolidity/StandardCompiler.cpp6
-rw-r--r--test/libsolidity/syntaxTests/array/uninitialized_storage_var.sol6
11 files changed, 155 insertions, 155 deletions
diff --git a/test/contracts/AuctionRegistrar.cpp b/test/contracts/AuctionRegistrar.cpp
index 4f135730..14c37105 100644
--- a/test/contracts/AuctionRegistrar.cpp
+++ b/test/contracts/AuctionRegistrar.cpp
@@ -43,20 +43,20 @@ static char const* registrarCode = R"DELIMITER(
pragma solidity ^0.4.0;
contract NameRegister {
- function addr(string memory _name) view returns (address o_owner);
- function name(address _owner) view returns (string memory o_name);
+ function addr(string memory _name) public view returns (address o_owner);
+ function name(address _owner) public view returns (string memory o_name);
}
contract Registrar is NameRegister {
event Changed(string indexed name);
event PrimaryChanged(string indexed name, address indexed addr);
- function owner(string memory _name) view returns (address o_owner);
- function addr(string memory _name) view returns (address o_address);
- function subRegistrar(string memory _name) view returns (address o_subRegistrar);
- function content(string memory _name) view returns (bytes32 o_content);
+ function owner(string memory _name) public view returns (address o_owner);
+ function addr(string memory _name) public view returns (address o_address);
+ function subRegistrar(string memory _name) public view returns (address o_subRegistrar);
+ function content(string memory _name) public view returns (bytes32 o_content);
- function name(address _owner) view returns (string memory o_name);
+ function name(address _owner) public view returns (string memory o_name);
}
contract AuctionSystem {
@@ -112,7 +112,7 @@ contract GlobalRegistrar is Registrar, AuctionSystem {
uint constant c_renewalInterval = 365 days;
uint constant c_freeBytes = 12;
- function Registrar() {
+ function Registrar() public {
// TODO: Populate with hall-of-fame.
}
@@ -156,12 +156,12 @@ contract GlobalRegistrar is Registrar, AuctionSystem {
modifier onlyrecordowner(string memory _name) { if (m_toRecord[_name].owner == msg.sender) _; }
- function transfer(string memory _name, address _newOwner) onlyrecordowner(_name) {
+ function transfer(string memory _name, address _newOwner) onlyrecordowner(_name) public {
m_toRecord[_name].owner = _newOwner;
emit Changed(_name);
}
- function disown(string memory _name) onlyrecordowner(_name) {
+ function disown(string memory _name) onlyrecordowner(_name) public {
if (stringsEqual(m_toName[m_toRecord[_name].primary], _name))
{
emit PrimaryChanged(_name, m_toRecord[_name].primary);
@@ -171,7 +171,7 @@ contract GlobalRegistrar is Registrar, AuctionSystem {
emit Changed(_name);
}
- function setAddress(string memory _name, address _a, bool _primary) onlyrecordowner(_name) {
+ function setAddress(string memory _name, address _a, bool _primary) onlyrecordowner(_name) public {
m_toRecord[_name].primary = _a;
if (_primary)
{
@@ -180,11 +180,11 @@ contract GlobalRegistrar is Registrar, AuctionSystem {
}
emit Changed(_name);
}
- function setSubRegistrar(string memory _name, address _registrar) onlyrecordowner(_name) {
+ function setSubRegistrar(string memory _name, address _registrar) onlyrecordowner(_name) public {
m_toRecord[_name].subRegistrar = _registrar;
emit Changed(_name);
}
- function setContent(string memory _name, bytes32 _content) onlyrecordowner(_name) {
+ function setContent(string memory _name, bytes32 _content) onlyrecordowner(_name) public {
m_toRecord[_name].content = _content;
emit Changed(_name);
}
@@ -201,11 +201,11 @@ contract GlobalRegistrar is Registrar, AuctionSystem {
return true;
}
- function owner(string memory _name) view returns (address) { return m_toRecord[_name].owner; }
- function addr(string memory _name) view returns (address) { return m_toRecord[_name].primary; }
- function subRegistrar(string memory _name) view returns (address) { return m_toRecord[_name].subRegistrar; }
- function content(string memory _name) view returns (bytes32) { return m_toRecord[_name].content; }
- function name(address _addr) view returns (string memory o_name) { return m_toName[_addr]; }
+ function owner(string memory _name) public view returns (address) { return m_toRecord[_name].owner; }
+ function addr(string memory _name) public view returns (address) { return m_toRecord[_name].primary; }
+ function subRegistrar(string memory _name) public view returns (address) { return m_toRecord[_name].subRegistrar; }
+ function content(string memory _name) public view returns (bytes32) { return m_toRecord[_name].content; }
+ function name(address _addr) public view returns (string memory o_name) { return m_toName[_addr]; }
mapping (address => string) m_toName;
mapping (string => Record) m_toRecord;
diff --git a/test/contracts/FixedFeeRegistrar.cpp b/test/contracts/FixedFeeRegistrar.cpp
index ff683de0..bc0c4118 100644
--- a/test/contracts/FixedFeeRegistrar.cpp
+++ b/test/contracts/FixedFeeRegistrar.cpp
@@ -58,10 +58,10 @@ pragma solidity ^0.4.0;
contract Registrar {
event Changed(string indexed name);
- function owner(string memory _name) view returns (address o_owner);
- function addr(string memory _name) view returns (address o_address);
- function subRegistrar(string memory _name) view returns (address o_subRegistrar);
- function content(string memory _name) view returns (bytes32 o_content);
+ function owner(string memory _name) public view returns (address o_owner);
+ function addr(string memory _name) public view returns (address o_address);
+ function subRegistrar(string memory _name) public view returns (address o_subRegistrar);
+ function content(string memory _name) public view returns (bytes32 o_content);
}
contract FixedFeeRegistrar is Registrar {
@@ -74,47 +74,47 @@ contract FixedFeeRegistrar is Registrar {
modifier onlyrecordowner(string memory _name) { if (m_record(_name).owner == msg.sender) _; }
- function reserve(string memory _name) payable {
+ function reserve(string memory _name) public payable {
Record storage rec = m_record(_name);
if (rec.owner == 0x0000000000000000000000000000000000000000 && msg.value >= c_fee) {
rec.owner = msg.sender;
emit Changed(_name);
}
}
- function disown(string memory _name, address _refund) onlyrecordowner(_name) {
+ function disown(string memory _name, address _refund) onlyrecordowner(_name) public {
delete m_recordData[uint(keccak256(bytes(_name))) / 8];
if (!_refund.send(c_fee))
throw;
emit Changed(_name);
}
- function transfer(string memory _name, address _newOwner) onlyrecordowner(_name) {
+ function transfer(string memory _name, address _newOwner) onlyrecordowner(_name) public {
m_record(_name).owner = _newOwner;
emit Changed(_name);
}
- function setAddr(string memory _name, address _a) onlyrecordowner(_name) {
+ function setAddr(string memory _name, address _a) onlyrecordowner(_name) public {
m_record(_name).addr = _a;
emit Changed(_name);
}
- function setSubRegistrar(string memory _name, address _registrar) onlyrecordowner(_name) {
+ function setSubRegistrar(string memory _name, address _registrar) onlyrecordowner(_name) public {
m_record(_name).subRegistrar = _registrar;
emit Changed(_name);
}
- function setContent(string memory _name, bytes32 _content) onlyrecordowner(_name) {
+ function setContent(string memory _name, bytes32 _content) onlyrecordowner(_name) public {
m_record(_name).content = _content;
emit Changed(_name);
}
- function record(string memory _name) view returns (address o_addr, address o_subRegistrar, bytes32 o_content, address o_owner) {
+ function record(string memory _name) public view returns (address o_addr, address o_subRegistrar, bytes32 o_content, address o_owner) {
Record storage rec = m_record(_name);
o_addr = rec.addr;
o_subRegistrar = rec.subRegistrar;
o_content = rec.content;
o_owner = rec.owner;
}
- function addr(string memory _name) view returns (address) { return m_record(_name).addr; }
- function subRegistrar(string memory _name) view returns (address) { return m_record(_name).subRegistrar; }
- function content(string memory _name) view returns (bytes32) { return m_record(_name).content; }
- function owner(string memory _name) view returns (address) { return m_record(_name).owner; }
+ function addr(string memory _name) public view returns (address) { return m_record(_name).addr; }
+ function subRegistrar(string memory _name) public view returns (address) { return m_record(_name).subRegistrar; }
+ function content(string memory _name) public view returns (bytes32) { return m_record(_name).content; }
+ function owner(string memory _name) public view returns (address) { return m_record(_name).owner; }
Record[2**253] m_recordData;
function m_record(string memory _name) view internal returns (Record storage o_record) {
diff --git a/test/contracts/Wallet.cpp b/test/contracts/Wallet.cpp
index 08470d8e..dc949063 100644
--- a/test/contracts/Wallet.cpp
+++ b/test/contracts/Wallet.cpp
@@ -101,7 +101,7 @@ contract multiowned {
// constructor is given number of sigs required to do protected "onlymanyowners" transactions
// as well as the selection of addresses capable of confirming them.
- constructor(address[] memory _owners, uint _required) {
+ constructor(address[] memory _owners, uint _required) public {
m_numOwners = _owners.length + 1;
m_owners[1] = uint(msg.sender);
m_ownerIndex[uint(msg.sender)] = 1;
@@ -173,11 +173,11 @@ contract multiowned {
emit RequirementChanged(_newRequired);
}
- function isOwner(address _addr) returns (bool) {
+ function isOwner(address _addr) public returns (bool) {
return m_ownerIndex[uint(_addr)] > 0;
}
- function hasConfirmed(bytes32 _operation, address _owner) view returns (bool) {
+ function hasConfirmed(bytes32 _operation, address _owner) public view returns (bool) {
PendingState storage pending = m_pending[_operation];
uint ownerIndex = m_ownerIndex[uint(_owner)];
@@ -288,7 +288,7 @@ contract daylimit is multiowned {
// METHODS
// constructor - stores initial daily limit and records the present day's index.
- constructor(uint _limit) {
+ constructor(uint _limit) public {
m_dailyLimit = _limit;
m_lastDay = today();
}
@@ -348,7 +348,7 @@ contract multisig {
// TODO: document
function changeOwner(address _from, address _to) external;
function execute(address _to, uint _value, bytes _data) external returns (bytes32);
- function confirm(bytes32 _h) returns (bool);
+ function confirm(bytes32 _h) public returns (bool);
}
// usage:
@@ -369,7 +369,7 @@ contract Wallet is multisig, multiowned, daylimit {
// constructor - just pass on the owner array to the multiowned and
// the limit to daylimit
- constructor(address[] memory _owners, uint _required, uint _daylimit) payable
+ constructor(address[] memory _owners, uint _required, uint _daylimit) public payable
multiowned(_owners, _required) daylimit(_daylimit) {
}
@@ -409,7 +409,7 @@ contract Wallet is multisig, multiowned, daylimit {
// confirm a transaction through just the hash. we use the previous transactions map, m_txs, in order
// to determine the body of the transaction from the hash provided.
- function confirm(bytes32 _h) onlymanyowners(_h) returns (bool) {
+ function confirm(bytes32 _h) onlymanyowners(_h) public returns (bool) {
if (m_txs[_h].to != 0x0000000000000000000000000000000000000000) {
m_txs[_h].to.call.value(m_txs[_h].value)(m_txs[_h].data);
emit MultiTransact(msg.sender, _h, m_txs[_h].value, m_txs[_h].to, m_txs[_h].data);
diff --git a/test/libsolidity/ABIDecoderTests.cpp b/test/libsolidity/ABIDecoderTests.cpp
index 2cfa27d6..28f982c4 100644
--- a/test/libsolidity/ABIDecoderTests.cpp
+++ b/test/libsolidity/ABIDecoderTests.cpp
@@ -182,7 +182,7 @@ BOOST_AUTO_TEST_CASE(dynamic_nested_arrays)
public pure returns (uint, uint, uint, uint, uint, uint, uint) {
return (a, b.length, b[1].length, b[1][1], c[1].length, c[1][1][1], d);
}
- function test() view returns (uint, uint, uint, uint, uint, uint, uint) {
+ function test() public view returns (uint, uint, uint, uint, uint, uint, uint) {
uint16[][] memory b = new uint16[][](3);
b[0] = new uint16[](2);
b[0][0] = 0x55;
diff --git a/test/libsolidity/GasMeter.cpp b/test/libsolidity/GasMeter.cpp
index a404c072..84e30033 100644
--- a/test/libsolidity/GasMeter.cpp
+++ b/test/libsolidity/GasMeter.cpp
@@ -119,7 +119,7 @@ BOOST_AUTO_TEST_CASE(non_overlapping_filtered_costs)
char const* sourceCode = R"(
contract test {
bytes x;
- function f(uint a) returns (uint b) {
+ function f(uint a) public returns (uint b) {
x.length = a;
for (; a < 200; ++a) {
x[a] = 9;
@@ -152,7 +152,7 @@ BOOST_AUTO_TEST_CASE(simple_contract)
char const* sourceCode = R"(
contract test {
bytes32 public shaValue;
- function f(uint a) {
+ function f(uint a) public {
shaValue = keccak256(abi.encodePacked(a));
}
}
@@ -165,7 +165,7 @@ BOOST_AUTO_TEST_CASE(store_keccak256)
char const* sourceCode = R"(
contract test {
bytes32 public shaValue;
- constructor(uint a) {
+ constructor(uint a) public {
shaValue = keccak256(abi.encodePacked(a));
}
}
@@ -179,7 +179,7 @@ BOOST_AUTO_TEST_CASE(updating_store)
contract test {
uint data;
uint data2;
- constructor() {
+ constructor() public {
data = 1;
data = 2;
data2 = 0;
@@ -195,7 +195,7 @@ BOOST_AUTO_TEST_CASE(branches)
contract test {
uint data;
uint data2;
- function f(uint x) {
+ function f(uint x) public {
if (x > 7)
data2 = 1;
else
@@ -213,7 +213,7 @@ BOOST_AUTO_TEST_CASE(function_calls)
contract test {
uint data;
uint data2;
- function f(uint x) {
+ function f(uint x) public {
if (x > 7)
data2 = g(x**8) + 1;
else
@@ -234,13 +234,13 @@ BOOST_AUTO_TEST_CASE(multiple_external_functions)
contract test {
uint data;
uint data2;
- function f(uint x) {
+ function f(uint x) public {
if (x > 7)
data2 = g(x**8) + 1;
else
data = 1;
}
- function g(uint x) returns (uint) {
+ function g(uint x) public returns (uint) {
return data2;
}
}
@@ -254,10 +254,10 @@ BOOST_AUTO_TEST_CASE(exponent_size)
{
char const* sourceCode = R"(
contract A {
- function g(uint x) returns (uint) {
+ function g(uint x) public returns (uint) {
return x ** 0x100;
}
- function h(uint x) returns (uint) {
+ function h(uint x) public returns (uint) {
return x ** 0x10000;
}
}
@@ -271,7 +271,7 @@ BOOST_AUTO_TEST_CASE(balance_gas)
{
char const* sourceCode = R"(
contract A {
- function lookup_balance(address a) returns (uint) {
+ function lookup_balance(address a) public returns (uint) {
return a.balance;
}
}
@@ -284,7 +284,7 @@ BOOST_AUTO_TEST_CASE(extcodesize_gas)
{
char const* sourceCode = R"(
contract A {
- function f() returns (uint _s) {
+ function f() public returns (uint _s) {
assembly {
_s := extcodesize(0x30)
}
@@ -316,7 +316,7 @@ BOOST_AUTO_TEST_CASE(complex_control_flow)
// we previously considered. This of course reduces accuracy.
char const* sourceCode = R"(
contract log {
- function ln(int128 x) pure returns (int128 result) {
+ function ln(int128 x) public pure returns (int128 result) {
int128 t = x / 256;
int128 y = 5545177;
x = t;
diff --git a/test/libsolidity/Metadata.cpp b/test/libsolidity/Metadata.cpp
index 808bd1e1..007ee2b6 100644
--- a/test/libsolidity/Metadata.cpp
+++ b/test/libsolidity/Metadata.cpp
@@ -41,7 +41,7 @@ BOOST_AUTO_TEST_CASE(metadata_stamp)
pragma solidity >=0.0;
pragma experimental __testOnlyAnalysis;
contract test {
- function g(function(uint) external returns (uint) x) {}
+ function g(function(uint) external returns (uint) x) public {}
}
)";
CompilerStack compilerStack;
@@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE(metadata_stamp_experimental)
pragma solidity >=0.0;
pragma experimental __test;
contract test {
- function g(function(uint) external returns (uint) x) {}
+ function g(function(uint) external returns (uint) x) public {}
}
)";
CompilerStack compilerStack;
@@ -97,14 +97,14 @@ BOOST_AUTO_TEST_CASE(metadata_relevant_sources)
char const* sourceCode = R"(
pragma solidity >=0.0;
contract A {
- function g(function(uint) external returns (uint) x) {}
+ function g(function(uint) external returns (uint) x) public {}
}
)";
compilerStack.addSource("A", std::string(sourceCode));
sourceCode = R"(
pragma solidity >=0.0;
contract B {
- function g(function(uint) external returns (uint) x) {}
+ function g(function(uint) external returns (uint) x) public {}
}
)";
compilerStack.addSource("B", std::string(sourceCode));
@@ -127,7 +127,7 @@ BOOST_AUTO_TEST_CASE(metadata_relevant_sources_imports)
char const* sourceCode = R"(
pragma solidity >=0.0;
contract A {
- function g(function(uint) external returns (uint) x) {}
+ function g(function(uint) external returns (uint) x) public {}
}
)";
compilerStack.addSource("A", std::string(sourceCode));
@@ -135,7 +135,7 @@ BOOST_AUTO_TEST_CASE(metadata_relevant_sources_imports)
pragma solidity >=0.0;
import "./A";
contract B is A {
- function g(function(uint) external returns (uint) x) {}
+ function g(function(uint) external returns (uint) x) public {}
}
)";
compilerStack.addSource("B", std::string(sourceCode));
@@ -143,7 +143,7 @@ BOOST_AUTO_TEST_CASE(metadata_relevant_sources_imports)
pragma solidity >=0.0;
import "./B";
contract C is B {
- function g(function(uint) external returns (uint) x) {}
+ function g(function(uint) external returns (uint) x) public {}
}
)";
compilerStack.addSource("C", std::string(sourceCode));
diff --git a/test/libsolidity/SolidityABIJSON.cpp b/test/libsolidity/SolidityABIJSON.cpp
index e3e06ddd..14413ca0 100644
--- a/test/libsolidity/SolidityABIJSON.cpp
+++ b/test/libsolidity/SolidityABIJSON.cpp
@@ -256,7 +256,7 @@ BOOST_AUTO_TEST_CASE(view_function)
char const* sourceCode = R"(
contract test {
function foo(uint a, uint b) public returns (uint d) { return a + b; }
- function boo(uint32 a) view returns(uint b) { return a * 4; }
+ function boo(uint32 a) public view returns(uint b) { return a * 4; }
}
)";
@@ -311,7 +311,7 @@ BOOST_AUTO_TEST_CASE(pure_function)
char const* sourceCode = R"(
contract test {
function foo(uint a, uint b) public returns (uint d) { return a + b; }
- function boo(uint32 a) pure returns(uint b) { return a * 4; }
+ function boo(uint32 a) public pure returns (uint b) { return a * 4; }
}
)";
@@ -616,7 +616,7 @@ BOOST_AUTO_TEST_CASE(constructor_abi)
{
char const* sourceCode = R"(
contract test {
- constructor(uint param1, test param2, bool param3) {}
+ constructor(uint param1, test param2, bool param3) public {}
}
)";
@@ -648,7 +648,7 @@ BOOST_AUTO_TEST_CASE(payable_constructor_abi)
{
char const* sourceCode = R"(
contract test {
- constructor(uint param1, test param2, bool param3) payable {}
+ constructor(uint param1, test param2, bool param3) public payable {}
}
)";
@@ -682,7 +682,7 @@ BOOST_AUTO_TEST_CASE(return_param_in_abi)
char const* sourceCode = R"(
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
- constructor(ActionChoices param) {}
+ constructor(ActionChoices param) public {}
function ret() public returns (ActionChoices) {
ActionChoices action = ActionChoices.GoLeft;
return action;
@@ -807,8 +807,8 @@ BOOST_AUTO_TEST_CASE(payable_function)
{
char const* sourceCode = R"(
contract test {
- function f() {}
- function g() payable {}
+ function f() public {}
+ function g() public payable {}
}
)";
@@ -861,7 +861,7 @@ BOOST_AUTO_TEST_CASE(function_type)
{
char const* sourceCode = R"(
contract test {
- function g(function(uint) external returns (uint) x) {}
+ function g(function(uint) external returns (uint) x) public {}
}
)";
@@ -1041,8 +1041,8 @@ BOOST_AUTO_TEST_CASE(structs_in_libraries)
library L {
struct S { uint a; T[] sub; bytes b; }
struct T { uint[2] x; }
- function f(L.S storage s) {}
- function g(L.S memory s) {}
+ function f(L.S storage s) public {}
+ function g(L.S memory s) public {}
}
)";
char const* interface = R"(
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index be74c5ff..ba6e864a 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -53,9 +53,9 @@ BOOST_AUTO_TEST_CASE(transaction_status)
{
char const* sourceCode = R"(
contract test {
- function f() { }
- function g() { revert(); }
- function h() { assert(false); }
+ function f() public { }
+ function g() public { revert(); }
+ function h() public { assert(false); }
}
)";
compileAndRun(sourceCode);
@@ -1253,7 +1253,7 @@ BOOST_AUTO_TEST_CASE(state_smoke_test)
if (which == 0) return value1;
else return value2;
}
- function set(uint8 which, uint256 value) {
+ function set(uint8 which, uint256 value) public {
if (which == 0) value1 = value;
else value2 = value;
}
@@ -1315,7 +1315,7 @@ BOOST_AUTO_TEST_CASE(simple_mapping)
function get(uint8 k) public returns (uint8 v) {
return table[k];
}
- function set(uint8 k, uint8 v) {
+ function set(uint8 k, uint8 v) public {
table[k] = v;
}
}
@@ -1349,7 +1349,7 @@ BOOST_AUTO_TEST_CASE(mapping_state)
function getVoteCount(address addr) public returns (uint retVoteCount) {
return voteCount[addr];
}
- function grantVoteRight(address addr) {
+ function grantVoteRight(address addr) public {
canVote[addr] = true;
}
function vote(address voter, address vote) public returns (bool success) {
@@ -1562,7 +1562,7 @@ BOOST_AUTO_TEST_CASE(deleteStruct)
uint nestedValue;
mapping (uint => bool) nestedMapping;
}
- constructor(){
+ constructor() public {
toDelete = 5;
str.topValue = 1;
str.topMapping[0] = 1;
@@ -2085,7 +2085,7 @@ BOOST_AUTO_TEST_CASE(transfer_ether)
addr.transfer(amount);
return this.balance;
}
- function b(address addr, uint amount) {
+ function b(address addr, uint amount) public {
addr.transfer(amount);
}
}
@@ -2477,7 +2477,7 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls)
function getHelper() public returns (address haddress) {
return address(h);
}
- function setHelper(address haddress) {
+ function setHelper(address haddress) public {
h = Helper(haddress);
}
}
@@ -2508,7 +2508,7 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_with_complex_parameters)
function getHelper() public returns (address haddress) {
return address(h);
}
- function setHelper(address haddress) {
+ function setHelper(address haddress) public {
h = Helper(haddress);
}
}
@@ -2540,7 +2540,7 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_accessing_this)
function getHelper() public returns (address addr) {
return address(h);
}
- function setHelper(address addr) {
+ function setHelper(address addr) public {
h = Helper(addr);
}
}
@@ -2572,7 +2572,7 @@ BOOST_AUTO_TEST_CASE(calls_to_this)
function getHelper() public returns (address addr) {
return address(h);
}
- function setHelper(address addr) {
+ function setHelper(address addr) public {
h = Helper(addr);
}
}
@@ -2607,7 +2607,7 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_with_local_vars)
function getHelper() public returns (address haddress) {
return address(h);
}
- function setHelper(address haddress) {
+ function setHelper(address haddress) public {
h = Helper(haddress);
}
}
@@ -2638,7 +2638,7 @@ BOOST_AUTO_TEST_CASE(fixed_bytes_in_calls)
function getHelper() public returns (address addr) {
return address(h);
}
- function setHelper(address addr) {
+ function setHelper(address addr) public {
h = Helper(addr);
}
}
@@ -2847,7 +2847,7 @@ BOOST_AUTO_TEST_CASE(value_complex)
contract test {
helper h;
constructor() public payable { h = new helper(); }
- function sendAmount(uint amount) payable returns (uint256 bal) {
+ function sendAmount(uint amount) public payable returns (uint256 bal) {
uint someStackElement = 20;
return h.getBalance.value(amount).gas(1000).value(amount + 3)();
}
@@ -2883,7 +2883,7 @@ BOOST_AUTO_TEST_CASE(value_for_constructor)
contract Helper {
bytes3 name;
bool flag;
- constructor(bytes3 x, bool f) payable {
+ constructor(bytes3 x, bool f) public payable {
name = x;
flag = f;
}
@@ -2892,7 +2892,7 @@ BOOST_AUTO_TEST_CASE(value_for_constructor)
}
contract Main {
Helper h;
- constructor() payable {
+ constructor() public payable {
h = (new Helper).value(10)("abc", true);
}
function getFlag() public returns (bool ret) { return h.getFlag(); }
@@ -2953,10 +2953,10 @@ BOOST_AUTO_TEST_CASE(single_copy_with_multiple_inheritance)
char const* sourceCode = R"(
contract Base {
uint data;
- function setData(uint i) { data = i; }
+ function setData(uint i) public { data = i; }
function getViaBase() public returns (uint i) { return data; }
}
- contract A is Base { function setViaA(uint i) { setData(i); } }
+ contract A is Base { function setViaA(uint i) public { setData(i); } }
contract B is Base { function getViaB() public returns (uint i) { return getViaBase(); } }
contract Derived is Base, B, A { }
)";
@@ -3165,7 +3165,7 @@ BOOST_AUTO_TEST_CASE(function_modifier_for_constructor)
char const* sourceCode = R"(
contract A {
uint data;
- constructor() mod1 { data |= 2; }
+ constructor() mod1 public { data |= 2; }
modifier mod1 { data |= 1; _; }
function getData() public returns (uint r) { return data; }
}
@@ -3375,7 +3375,7 @@ BOOST_AUTO_TEST_CASE(event)
char const* sourceCode = R"(
contract ClientReceipt {
event Deposit(address indexed _from, bytes32 indexed _id, uint _value);
- function deposit(bytes32 _id, bool _manually) payable {
+ function deposit(bytes32 _id, bool _manually) public payable {
if (_manually) {
bytes32 s = 0x19dacbf83c5de6658e14cbf7bcae5c15eca2eedecf1c66fbca928e4d351bea0f;
log3(bytes32(msg.value), s, bytes32(uint256(msg.sender)), _id);
@@ -3406,7 +3406,7 @@ BOOST_AUTO_TEST_CASE(event_emit)
char const* sourceCode = R"(
contract ClientReceipt {
event Deposit(address indexed _from, bytes32 indexed _id, uint _value);
- function deposit(bytes32 _id) payable {
+ function deposit(bytes32 _id) public payable {
emit Deposit(msg.sender, _id, msg.value);
}
}
@@ -3584,7 +3584,7 @@ BOOST_AUTO_TEST_CASE(event_anonymous_with_topics)
char const* sourceCode = R"(
contract ClientReceipt {
event Deposit(address indexed _from, bytes32 indexed _id, uint indexed _value, uint indexed _value2, bytes32 data) anonymous;
- function deposit(bytes32 _id) payable {
+ function deposit(bytes32 _id) public payable {
emit Deposit(msg.sender, _id, msg.value, 2, "abc");
}
}
@@ -3608,7 +3608,7 @@ BOOST_AUTO_TEST_CASE(event_lots_of_data)
char const* sourceCode = R"(
contract ClientReceipt {
event Deposit(address _from, bytes32 _id, uint _value, bool _flag);
- function deposit(bytes32 _id) payable {
+ function deposit(bytes32 _id) public payable {
emit Deposit(msg.sender, _id, msg.value, true);
}
}
@@ -3910,7 +3910,7 @@ BOOST_AUTO_TEST_CASE(generic_call)
char const* sourceCode = R"**(
contract receiver {
uint public received;
- function receive(uint256 x) payable { received = x; }
+ function receive(uint256 x) public payable { received = x; }
}
contract sender {
constructor() public payable {}
@@ -3936,15 +3936,15 @@ BOOST_AUTO_TEST_CASE(generic_delegatecall)
uint public received;
address public sender;
uint public value;
- constructor() payable {}
- function receive(uint256 x) payable { received = x; sender = msg.sender; value = msg.value; }
+ constructor() public payable {}
+ function receive(uint256 x) public payable { received = x; sender = msg.sender; value = msg.value; }
}
contract Sender {
uint public received;
address public sender;
uint public value;
- constructor() payable {}
- function doSend(address rec) payable
+ constructor() public payable {}
+ function doSend(address rec) public payable
{
bytes4 signature = bytes4(bytes32(keccak256("receive(uint256)")));
if (rec.delegatecall(abi.encodeWithSelector(signature, 23))) {}
@@ -4130,7 +4130,7 @@ BOOST_AUTO_TEST_CASE(copying_bytes_multiassign)
char const* sourceCode = R"(
contract receiver {
uint public received;
- function receive(uint x) { received += x + 1; }
+ function receive(uint x) public { received += x + 1; }
function() external { received = 0x80; }
}
contract sender {
@@ -4349,7 +4349,7 @@ BOOST_AUTO_TEST_CASE(using_enums)
char const* sourceCode = R"(
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
- constructor()
+ constructor() public
{
choices = ActionChoices.GoStraight;
}
@@ -4369,7 +4369,7 @@ BOOST_AUTO_TEST_CASE(enum_explicit_overflow)
char const* sourceCode = R"(
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight }
- constructor()
+ constructor() public
{
}
function getChoiceExp(uint x) public returns (uint d)
@@ -4514,7 +4514,7 @@ BOOST_AUTO_TEST_CASE(inline_member_init)
{
char const* sourceCode = R"(
contract test {
- constructor(){
+ constructor() public {
m_b = 6;
m_c = 8;
}
@@ -4536,12 +4536,12 @@ BOOST_AUTO_TEST_CASE(inline_member_init_inheritence)
{
char const* sourceCode = R"(
contract Base {
- constructor(){}
+ constructor() public {}
uint m_base = 5;
function getBMember() public returns (uint i) { return m_base; }
}
contract Derived is Base {
- constructor(){}
+ constructor() public {}
uint m_derived = 6;
function getDMember() public returns (uint i) { return m_derived; }
}
@@ -4588,8 +4588,8 @@ BOOST_AUTO_TEST_CASE(bytes_in_arguments)
char const* sourceCode = R"(
contract c {
uint result;
- function f(uint a, uint b) { result += a + b; }
- function g(uint a) { result *= a; }
+ function f(uint a, uint b) public { result += a + b; }
+ function g(uint a) public { result *= a; }
function test(uint a, bytes data1, bytes data2, uint b) external returns (uint r_a, uint r, uint r_b, uint l) {
r_a = a;
this.call(data1);
@@ -4621,9 +4621,9 @@ BOOST_AUTO_TEST_CASE(fixed_arrays_in_storage)
struct Data { uint x; uint y; }
Data[2**10] data;
uint[2**10 + 3] ids;
- function setIDStatic(uint id) { ids[2] = id; }
- function setID(uint index, uint id) { ids[index] = id; }
- function setData(uint index, uint x, uint y) { data[index].x = x; data[index].y = y; }
+ function setIDStatic(uint id) public { ids[2] = id; }
+ function setID(uint index, uint id) public { ids[index] = id; }
+ function setData(uint index, uint x, uint y) public { data[index].x = x; data[index].y = y; }
function getID(uint index) public returns (uint) { return ids[index]; }
function getData(uint index) public returns (uint x, uint y) { x = data[index].x; y = data[index].y; }
function getLengths() public returns (uint l1, uint l2) { l1 = data.length; l2 = ids.length; }
@@ -4648,13 +4648,13 @@ BOOST_AUTO_TEST_CASE(dynamic_arrays_in_storage)
struct Data { uint x; uint y; }
Data[] data;
uint[] ids;
- function setIDStatic(uint id) { ids[2] = id; }
- function setID(uint index, uint id) { ids[index] = id; }
- function setData(uint index, uint x, uint y) { data[index].x = x; data[index].y = y; }
+ function setIDStatic(uint id) public { ids[2] = id; }
+ function setID(uint index, uint id) public { ids[index] = id; }
+ function setData(uint index, uint x, uint y) public { data[index].x = x; data[index].y = y; }
function getID(uint index) public returns (uint) { return ids[index]; }
function getData(uint index) public returns (uint x, uint y) { x = data[index].x; y = data[index].y; }
function getLengths() public returns (uint l1, uint l2) { l1 = data.length; l2 = ids.length; }
- function setLengths(uint l1, uint l2) { data.length = l1; ids.length = l2; }
+ function setLengths(uint l1, uint l2) public { data.length = l1; ids.length = l2; }
}
)";
compileAndRun(sourceCode);
@@ -4811,7 +4811,7 @@ BOOST_AUTO_TEST_CASE(array_copy_storage_storage_dyn_dyn)
contract c {
uint[] data1;
uint[] data2;
- function setData1(uint length, uint index, uint value) {
+ function setData1(uint length, uint index, uint value) public {
data1.length = length; if (index < length) data1[index] = value;
}
function copyStorageStorage() public { data2 = data1; }
@@ -5737,14 +5737,14 @@ BOOST_AUTO_TEST_CASE(pass_dynamic_arguments_to_the_base)
{
char const* sourceCode = R"(
contract Base {
- constructor(uint i)
+ constructor(uint i) public
{
m_i = i;
}
uint public m_i;
}
contract Derived is Base {
- constructor(uint i) Base(i)
+ constructor(uint i) Base(i) public
{}
}
contract Final is Derived(4) {
@@ -5782,14 +5782,14 @@ BOOST_AUTO_TEST_CASE(pass_dynamic_arguments_to_the_base_base_with_gap)
{
char const* sourceCode = R"(
contract Base {
- constructor(uint i)
+ constructor(uint i) public
{
m_i = i;
}
uint public m_i;
}
contract Base1 is Base {
- constructor(uint k) {}
+ constructor(uint k) public {}
}
contract Derived is Base, Base1 {
constructor(uint i) Base(i) Base1(7) public {}
@@ -6368,7 +6368,7 @@ BOOST_AUTO_TEST_CASE(struct_assign_reference_to_struct)
testStruct data1;
testStruct data2;
testStruct data3;
- constructor()
+ constructor() public
{
data1.m_value = 2;
}
@@ -6400,7 +6400,7 @@ BOOST_AUTO_TEST_CASE(struct_delete_member)
uint m_value;
}
testStruct data1;
- constructor()
+ constructor() public
{
data1.m_value = 2;
}
@@ -6427,7 +6427,7 @@ BOOST_AUTO_TEST_CASE(struct_delete_struct_in_mapping)
}
mapping (uint => testStruct) campaigns;
- constructor()
+ constructor() public
{
campaigns[0].m_value = 2;
}
@@ -6470,14 +6470,14 @@ BOOST_AUTO_TEST_CASE(evm_exceptions_in_constructor_call_fail)
{
char const* sourceCode = R"(
contract A {
- constructor()
+ constructor() public
{
this.call("123");
}
}
contract B {
uint public test = 1;
- function testIt()
+ function testIt() public
{
A a = new A();
++test;
@@ -6496,7 +6496,7 @@ BOOST_AUTO_TEST_CASE(evm_exceptions_in_constructor_out_of_baund)
contract A {
uint public test = 1;
uint[3] arr;
- constructor()
+ constructor() public
{
uint index = 5;
test = arr[index];
@@ -7038,7 +7038,7 @@ BOOST_AUTO_TEST_CASE(storage_array_ref)
contract Store is BinarySearch {
uint[] data;
- function add(uint v) {
+ function add(uint v) public {
data.length++;
data[data.length - 1] = v;
}
@@ -7121,7 +7121,7 @@ BOOST_AUTO_TEST_CASE(memory_arrays_index_access_write)
{
char const* sourceCode = R"(
contract Test {
- function set(uint24[3][4] memory x) {
+ function set(uint24[3][4] memory x) public {
x[2][2] = 1;
x[3][2] = 7;
}
@@ -7458,7 +7458,7 @@ BOOST_AUTO_TEST_CASE(string_as_mapping_key)
char const* sourceCode = R"(
contract Test {
mapping(string => uint) data;
- function set(string memory _s, uint _v) { data[_s] = _v; }
+ function set(string memory _s, uint _v) public { data[_s] = _v; }
function get(string memory _s) public returns (uint) { return data[_s]; }
}
)";
@@ -7764,7 +7764,7 @@ BOOST_AUTO_TEST_CASE(strings_in_struct)
string last;
}
- constructor(){
+ constructor() public {
bug = Buggy(10, 20, 30, "asdfghjkl");
}
function getFirst() public returns (uint)
@@ -7856,7 +7856,7 @@ BOOST_AUTO_TEST_CASE(using_library_structs)
char const* sourceCode = R"(
library Lib {
struct Data { uint a; uint[] b; }
- function set(Data storage _s)
+ function set(Data storage _s) public
{
_s.a = 7;
_s.b.length = 20;
@@ -8039,7 +8039,7 @@ BOOST_AUTO_TEST_CASE(calldata_offset)
{
address[] _arr;
string public last = "nd";
- constructor(address[] memory guardians)
+ constructor(address[] memory guardians) public
{
_arr = guardians;
}
@@ -8941,8 +8941,8 @@ BOOST_AUTO_TEST_CASE(inline_assembly_function_access)
char const* sourceCode = R"(
contract C {
uint public x;
- function g(uint y) { x = 2 * y; assembly { stop } }
- function f(uint _x) {
+ function g(uint y) public { x = 2 * y; assembly { stop } }
+ function f(uint _x) public {
assembly {
_x
jump(g)
@@ -9416,7 +9416,7 @@ BOOST_AUTO_TEST_CASE(skip_dynamic_types_for_structs)
BOOST_AUTO_TEST_CASE(failed_create)
{
char const* sourceCode = R"(
- contract D { constructor() payable {} }
+ contract D { constructor() public payable {} }
contract C {
uint public x;
constructor() public payable {}
@@ -9512,7 +9512,7 @@ BOOST_AUTO_TEST_CASE(break_in_modifier)
break;
}
}
- function f() run {
+ function f() run public {
uint k = x;
uint t = k + 1;
x = t;
@@ -9584,7 +9584,7 @@ BOOST_AUTO_TEST_CASE(stacked_return_with_modifiers)
break;
}
}
- function f() run {
+ function f() run public {
uint k = x;
uint t = k + 1;
x = t;
@@ -9611,8 +9611,8 @@ BOOST_AUTO_TEST_CASE(mutex)
}
contract Fund is mutexed {
uint shares;
- constructor() payable { shares = msg.value; }
- function withdraw(uint amount) protected returns (uint) {
+ constructor() public payable { shares = msg.value; }
+ function withdraw(uint amount) public protected returns (uint) {
// NOTE: It is very bad practice to write this function this way.
// Please refer to the documentation of how to do this properly.
if (amount > shares) throw;
@@ -9633,7 +9633,7 @@ BOOST_AUTO_TEST_CASE(mutex)
Fund public fund;
uint callDepth;
bool protected;
- function setProtected(bool _protected) { protected = _protected; }
+ function setProtected(bool _protected) public { protected = _protected; }
constructor(Fund _fund) public { fund = _fund; }
function attack() public returns (uint) {
callDepth = 0;
@@ -9730,7 +9730,7 @@ BOOST_AUTO_TEST_CASE(failing_ecrecover_invalid_input_asm)
BOOST_AUTO_TEST_CASE(calling_nonexisting_contract_throws)
{
char const* sourceCode = R"YY(
- contract D { function g(); }
+ contract D { function g() public; }
contract C {
D d = D(0x1212);
function f() public returns (uint) {
@@ -9757,7 +9757,7 @@ BOOST_AUTO_TEST_CASE(payable_constructor)
{
char const* sourceCode = R"(
contract C {
- constructor() payable { }
+ constructor() public payable { }
}
)";
compileAndRun(sourceCode, 27, "C");
@@ -9792,7 +9792,7 @@ BOOST_AUTO_TEST_CASE(payable_function_calls_library)
function f() public returns (uint) { return 7; }
}
contract C {
- function f() payable public returns (uint) {
+ function f() public payable returns (uint) {
return L.f();
}
}
@@ -10015,7 +10015,7 @@ BOOST_AUTO_TEST_CASE(store_function)
contract C {
function (function (uint) external returns (uint)) internal returns (uint) ev;
function (uint) external returns (uint) x;
- function store(function(uint) external returns (uint) y) {
+ function store(function(uint) external returns (uint) y) public {
x = y;
}
function eval(function(uint) external returns (uint) y) public returns (uint) {
@@ -11594,7 +11594,7 @@ BOOST_AUTO_TEST_CASE(literal_empty_string)
contract C {
bytes32 public x;
uint public a;
- function f(bytes32 _x, uint _a) {
+ function f(bytes32 _x, uint _a) public {
x = _x;
a = _a;
}
@@ -12730,7 +12730,7 @@ BOOST_AUTO_TEST_CASE(senders_balance)
}
contract D {
C c = new C();
- constructor() payable { }
+ constructor() public payable { }
function f() public view returns (uint) {
return c.f();
}
diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp
index 43ae5f73..3e2dce26 100644
--- a/test/libsolidity/SolidityOptimizer.cpp
+++ b/test/libsolidity/SolidityOptimizer.cpp
@@ -394,12 +394,12 @@ BOOST_AUTO_TEST_CASE(computing_constants)
g();
return 1;
}
- function g() {
+ function g() public {
m_b = 0x817416927846239487123469187231298734162934871263941234127518276;
m_c = 0x817416927846239487123469187231298734162934871263941234127518276;
h();
}
- function h() {
+ function h() public {
m_d = 0xff05694900000000000000000000000000000000000000000000000000000000;
}
function get() public returns (uint ra, uint rb, uint rc, uint rd) {
@@ -600,7 +600,7 @@ BOOST_AUTO_TEST_CASE(init_empty_dynamic_arrays)
// not use any memory.
char const* sourceCode = R"(
contract Test {
- function f() pure returns (uint r) {
+ function f() public pure returns (uint r) {
uint[][] memory x = new uint[][](20000);
return x.length;
}
diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp
index bfb0d739..16921a24 100644
--- a/test/libsolidity/StandardCompiler.cpp
+++ b/test/libsolidity/StandardCompiler.cpp
@@ -466,7 +466,7 @@ BOOST_AUTO_TEST_CASE(output_selection_dependent_contract)
},
"sources": {
"fileA": {
- "content": "contract B { } contract A { function f() { new B(); } }"
+ "content": "contract B { } contract A { function f() public { new B(); } }"
}
}
}
@@ -495,7 +495,7 @@ BOOST_AUTO_TEST_CASE(output_selection_dependent_contract_with_import)
},
"sources": {
"fileA": {
- "content": "import \"fileB\"; contract A { function f() { new B(); } }"
+ "content": "import \"fileB\"; contract A { function f() public { new B(); } }"
},
"fileB": {
"content": "contract B { }"
@@ -712,7 +712,7 @@ BOOST_AUTO_TEST_CASE(library_linking)
"content": "library L { function g() public returns (uint) { return 1; } }"
},
"library2.sol": {
- "content": "library L2 { function g() { } }"
+ "content": "library L2 { function g() public { } }"
}
}
}
diff --git a/test/libsolidity/syntaxTests/array/uninitialized_storage_var.sol b/test/libsolidity/syntaxTests/array/uninitialized_storage_var.sol
index 363d8147..f3be9071 100644
--- a/test/libsolidity/syntaxTests/array/uninitialized_storage_var.sol
+++ b/test/libsolidity/syntaxTests/array/uninitialized_storage_var.sol
@@ -1,9 +1,9 @@
contract C {
- function f() {
+ function f() public {
uint[] storage x;
uint[10] storage y;
}
}
// ----
-// DeclarationError: (31-47): Uninitialized storage pointer.
-// DeclarationError: (51-69): Uninitialized storage pointer.
+// DeclarationError: (38-54): Uninitialized storage pointer.
+// DeclarationError: (58-76): Uninitialized storage pointer.