diff --git a/test/cmdlineTests/storage_layout_transient_value_types/input.json b/test/cmdlineTests/storage_layout_transient_value_types/input.json new file mode 100644 index 000000000000..bf7fc2cb9840 --- /dev/null +++ b/test/cmdlineTests/storage_layout_transient_value_types/input.json @@ -0,0 +1,16 @@ +{ + "language": "Solidity", + "sources": { + "fileA": { + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0;\ncontract A { uint transient x; bytes32 transient b; address transient addr; }" + } + }, + "settings": { + "outputSelection": { + "fileA": { + "A": [ "storageLayout" ], + "": [ "storageLayout" ] + } + } + } +} diff --git a/test/cmdlineTests/storage_layout_transient_value_types/output.json b/test/cmdlineTests/storage_layout_transient_value_types/output.json new file mode 100644 index 000000000000..b6eb007805a4 --- /dev/null +++ b/test/cmdlineTests/storage_layout_transient_value_types/output.json @@ -0,0 +1,69 @@ +{ + "contracts": + { + "fileA": + { + "A": + { + "storageLayout": + { + "storage": + [ + { + "astId": 3, + "contract": "fileA:A", + "label": "x", + "offset": 0, + "slot": "0", + "type": "t_uint256" + }, + { + "astId": 5, + "contract": "fileA:A", + "label": "b", + "offset": 0, + "slot": "1", + "type": "t_bytes32" + }, + { + "astId": 7, + "contract": "fileA:A", + "label": "addr", + "offset": 0, + "slot": "2", + "type": "t_address" + } + ], + "types": + { + "t_address": + { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_bytes32": + { + "encoding": "inplace", + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_uint256": + { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + } + } + } + } + } + }, + "sources": + { + "fileA": + { + "id": 0 + } + } +} diff --git a/test/libsolidity/astPropertyTests/transient_data_location.sol b/test/libsolidity/astPropertyTests/transient_data_location.sol new file mode 100644 index 000000000000..6a937414d6bd --- /dev/null +++ b/test/libsolidity/astPropertyTests/transient_data_location.sol @@ -0,0 +1,8 @@ +contract C { + /// TestVarDataLocation: storageLocation + /// TestVarName: name + uint transient transient; +} +// ---- +// TestVarDataLocation: transient +// TestVarName: transient diff --git a/test/libsolidity/syntaxTests/dataLocations/multiple_transient_data_location_function_parameter.sol b/test/libsolidity/syntaxTests/dataLocations/multiple_transient_data_location_function_parameter.sol new file mode 100644 index 000000000000..feafa9fc75d2 --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/multiple_transient_data_location_function_parameter.sol @@ -0,0 +1,6 @@ +contract C { + function f(uint[] transient transient x) public pure { } +} + +// ---- +// ParserError 3548: (45-54): Location already specified. diff --git a/test/libsolidity/syntaxTests/dataLocations/state_variable_storage_transient.sol b/test/libsolidity/syntaxTests/dataLocations/state_variable_storage_transient.sol new file mode 100644 index 000000000000..d3fb023e0dbd --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/state_variable_storage_transient.sol @@ -0,0 +1,5 @@ +contract C { + uint storage transient x; +} +// ---- +// ParserError 2314: (22-29): Expected identifier but got 'storage' diff --git a/test/libsolidity/syntaxTests/dataLocations/state_variable_transient_storage.sol b/test/libsolidity/syntaxTests/dataLocations/state_variable_transient_storage.sol new file mode 100644 index 000000000000..53260194d1d2 --- /dev/null +++ b/test/libsolidity/syntaxTests/dataLocations/state_variable_transient_storage.sol @@ -0,0 +1,5 @@ +contract C { + uint transient storage x; +} +// ---- +// ParserError 2314: (32-39): Expected identifier but got 'storage' diff --git a/test/libsolidity/syntaxTests/dataLocations/variable_declaration_location_specifier_test_non_reference_type.sol b/test/libsolidity/syntaxTests/dataLocations/variable_declaration_location_specifier_test_non_reference_type.sol index 9d20bbf9250d..c34ba88e528e 100644 --- a/test/libsolidity/syntaxTests/dataLocations/variable_declaration_location_specifier_test_non_reference_type.sol +++ b/test/libsolidity/syntaxTests/dataLocations/variable_declaration_location_specifier_test_non_reference_type.sol @@ -1,17 +1,16 @@ -contract C { +contract test { function f() public { - uint storage a1; - bytes16 storage b1; - uint memory a2; - bytes16 memory b2; - uint transient a3; - bytes16 transient b3; + uint storage a1; + bytes16 storage b1; + uint memory a2; + bytes16 memory b2; + uint transient a3; + bytes16 b3; } } // ---- -// TypeError 6651: (47-62): Data location can only be specified for array, struct or mapping types, but "storage" was given. -// TypeError 6651: (72-90): Data location can only be specified for array, struct or mapping types, but "storage" was given. -// TypeError 6651: (100-114): Data location can only be specified for array, struct or mapping types, but "memory" was given. -// TypeError 6651: (124-141): Data location can only be specified for array, struct or mapping types, but "memory" was given. -// TypeError 6651: (151-168): Data location can only be specified for array, struct or mapping types, but "transient" was given. -// TypeError 6651: (178-198): Data location can only be specified for array, struct or mapping types, but "transient" was given. +// TypeError 6651: (48-63): Data location can only be specified for array, struct or mapping types, but "storage" was given. +// TypeError 6651: (71-89): Data location can only be specified for array, struct or mapping types, but "storage" was given. +// TypeError 6651: (97-111): Data location can only be specified for array, struct or mapping types, but "memory" was given. +// TypeError 6651: (119-136): Data location can only be specified for array, struct or mapping types, but "memory" was given. +// TypeError 6651: (144-161): Data location can only be specified for array, struct or mapping types, but "transient" was given. diff --git a/test/libsolidity/syntaxTests/errors/invalid_parameter_location.sol b/test/libsolidity/syntaxTests/errors/invalid_parameter_location.sol index a116188d2375..f02fd106ebf7 100644 --- a/test/libsolidity/syntaxTests/errors/invalid_parameter_location.sol +++ b/test/libsolidity/syntaxTests/errors/invalid_parameter_location.sol @@ -10,6 +10,10 @@ contract test { contract test { error e1(string calldata a); } +==== Source: D ==== +contract test { + error e1(string transient a); +} // ---- // ParserError 2314: (A:36-43): Expected ',' but got 'storage' // ParserError 2314: (B:36-42): Expected ',' but got 'memory' diff --git a/test/libsolidity/syntaxTests/events/invalid_parameter_location.sol b/test/libsolidity/syntaxTests/events/invalid_parameter_location.sol index 04ee9b7bc4b6..6cb8e19465a1 100644 --- a/test/libsolidity/syntaxTests/events/invalid_parameter_location.sol +++ b/test/libsolidity/syntaxTests/events/invalid_parameter_location.sol @@ -10,6 +10,10 @@ contract test { contract test { event e1(string calldata a); } +==== Source: D ==== +contract test { + event e1(string transient a); +} // ---- // ParserError 2314: (A:36-43): Expected ',' but got 'storage' // ParserError 2314: (B:36-42): Expected ',' but got 'memory' diff --git a/test/libsolidity/syntaxTests/events/transient_indexed_parameter.sol b/test/libsolidity/syntaxTests/events/transient_indexed_parameter.sol index 3a4e201bab30..52a9691b8b94 100644 --- a/test/libsolidity/syntaxTests/events/transient_indexed_parameter.sol +++ b/test/libsolidity/syntaxTests/events/transient_indexed_parameter.sol @@ -1,5 +1,5 @@ contract C { - event e(uint indexed transient a); + event e(string indexed transient a); } // ---- // TypeError 6651: (25-49): Data location can only be specified for array, struct or mapping types, but "transient" was given. diff --git a/test/libsolidity/syntaxTests/functionTypes/function_type_with_transient_param.sol b/test/libsolidity/syntaxTests/functionTypes/function_type_with_transient_param.sol new file mode 100644 index 000000000000..6c0cc737e6cf --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/function_type_with_transient_param.sol @@ -0,0 +1,9 @@ +contract C { + function (uint transient x) external y; + function (uint[] transient w) external z; +} +// ---- +// Warning 6162: (27-43): Naming function type parameters is deprecated. +// Warning 6162: (71-89): Naming function type parameters is deprecated. +// TypeError 6651: (27-43): Data location can only be specified for array, struct or mapping types, but "transient" was given. +// TypeError 6651: (71-89): Data location must be "memory" or "calldata" for parameter in function, but "transient" was given. diff --git a/test/libsolidity/syntaxTests/functionTypes/transient_function_type_with_param_named_transient.sol b/test/libsolidity/syntaxTests/functionTypes/transient_function_type_with_param_named_transient.sol new file mode 100644 index 000000000000..40fbecbafaaf --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/transient_function_type_with_param_named_transient.sol @@ -0,0 +1,5 @@ +contract C { + function (uint transient) external transient y; +} +// ---- +// Warning 6162: (27-41): Naming function type parameters is deprecated. diff --git a/test/libsolidity/syntaxTests/functionTypes/transient_function_type_with_transient_param.sol b/test/libsolidity/syntaxTests/functionTypes/transient_function_type_with_transient_param.sol new file mode 100644 index 000000000000..6c78a908a26c --- /dev/null +++ b/test/libsolidity/syntaxTests/functionTypes/transient_function_type_with_transient_param.sol @@ -0,0 +1,6 @@ +contract C { + function (uint transient x) external transient y; +} +// ---- +// Warning 6162: (27-43): Naming function type parameters is deprecated. +// TypeError 6651: (27-43): Data location can only be specified for array, struct or mapping types, but "transient" was given. diff --git a/test/libsolidity/syntaxTests/modifiers/multiple_parameter_location.sol b/test/libsolidity/syntaxTests/modifiers/multiple_parameter_location.sol index e264a593ff2c..03d0ff1201ec 100644 --- a/test/libsolidity/syntaxTests/modifiers/multiple_parameter_location.sol +++ b/test/libsolidity/syntaxTests/modifiers/multiple_parameter_location.sol @@ -8,6 +8,12 @@ contract A { modifier mod7(string calldata storage a) { _; } modifier mod8(string calldata memory a) { _; } modifier mod9(string calldata calldata a) { _; } + modifier modA(string transient storage a) { _; } + modifier modB(string transient memory a) { _; } + modifier modC(string transient calldata a) { _; } + modifier modD(string storage transient a) { _; } + modifier modE(string memory transient a) { _; } + modifier modF(string calldata transient a) { _; } } // ---- // ParserError 3548: (46-53): Location already specified. @@ -19,3 +25,9 @@ contract A { // ParserError 3548: (350-357): Location already specified. // ParserError 3548: (402-408): Location already specified. // ParserError 3548: (453-461): Location already specified. +// ParserError 3548: (507-514): Location already specified. +// ParserError 3548: (560-566): Location already specified. +// ParserError 3548: (612-620): Location already specified. +// ParserError 3548: (664-673): Location already specified. +// ParserError 3548: (716-725): Location already specified. +// ParserError 3548: (770-779): Location already specified. diff --git a/test/libsolidity/syntaxTests/modifiers/transient_parameter.sol b/test/libsolidity/syntaxTests/modifiers/transient_parameter.sol new file mode 100644 index 000000000000..00530880c9dd --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/transient_parameter.sol @@ -0,0 +1,6 @@ +contract A { + modifier mod2(uint[] transient b) { _; } +} +// ---- +// TypeError 6651: (31-46): Data location can only be specified for array, struct or mapping types, but "transient" was given. +// TypeError 6651: (73-91): Data location must be "storage", "memory" or "calldata" for parameter in function, but "transient" was given. diff --git a/test/libsolidity/syntaxTests/operators/transient_value_type.sol b/test/libsolidity/syntaxTests/operators/transient_value_type.sol new file mode 100644 index 000000000000..1e24abb11468 --- /dev/null +++ b/test/libsolidity/syntaxTests/operators/transient_value_type.sol @@ -0,0 +1,9 @@ +contract C { + int transient x; + function f() public view returns (int) { + int y = x; + int w = -x; + return (x + w) * (y / x); + } +} +// ----