aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/syntaxTests
diff options
context:
space:
mode:
authormingchuan <mingc@skymizer.com>2018-05-23 12:31:20 +0800
committermingchuan <mingc@skymizer.com>2018-05-30 18:05:55 +0800
commitb7cafcbdf95c807f46fc07f4788d82981b7112b4 (patch)
tree5714a463da64eaf75a3ec56732165ec89e77d677 /test/libsolidity/syntaxTests
parent9d5064d04d178474b95d67e87aaa32d0e5e03b0f (diff)
downloaddexon-solidity-b7cafcbdf95c807f46fc07f4788d82981b7112b4.tar
dexon-solidity-b7cafcbdf95c807f46fc07f4788d82981b7112b4.tar.gz
dexon-solidity-b7cafcbdf95c807f46fc07f4788d82981b7112b4.tar.bz2
dexon-solidity-b7cafcbdf95c807f46fc07f4788d82981b7112b4.tar.lz
dexon-solidity-b7cafcbdf95c807f46fc07f4788d82981b7112b4.tar.xz
dexon-solidity-b7cafcbdf95c807f46fc07f4788d82981b7112b4.tar.zst
dexon-solidity-b7cafcbdf95c807f46fc07f4788d82981b7112b4.zip
Allow using `calldata` keyword to specify data location
Diffstat (limited to 'test/libsolidity/syntaxTests')
-rw-r--r--test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_calldata.sol4
-rw-r--r--test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_memory.sol5
-rw-r--r--test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_storage.sol5
-rw-r--r--test/libsolidity/syntaxTests/dataLocations/function_argument_location_specifier_test_library.sol5
-rw-r--r--test/libsolidity/syntaxTests/dataLocations/function_argument_location_specifier_test_non_reference_type.sol5
-rw-r--r--test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_calldata.sol5
-rw-r--r--test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_memory.sol4
-rw-r--r--test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_storage.sol4
-rw-r--r--test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_calldata.sol5
-rw-r--r--test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_memory.sol4
-rw-r--r--test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_storage.sol5
-rw-r--r--test/libsolidity/syntaxTests/dataLocations/variable_declaration_location_specifier_test_non_reference_type.sol13
-rw-r--r--test/libsolidity/syntaxTests/dataLocations/variable_declaration_location_specifier_test_reference_type.sol14
-rw-r--r--test/libsolidity/syntaxTests/parsing/location_specifiers_for_params.sol2
14 files changed, 79 insertions, 1 deletions
diff --git a/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_calldata.sol b/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_calldata.sol
new file mode 100644
index 00000000..781c645a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_calldata.sol
@@ -0,0 +1,4 @@
+contract test {
+ function f(bytes calldata) external;
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_memory.sol b/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_memory.sol
new file mode 100644
index 00000000..807cc064
--- /dev/null
+++ b/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_memory.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f(bytes memory) external;
+}
+// ----
+// TypeError: (31-36): Location has to be calldata for external functions (remove the "memory" or "storage" keyword).
diff --git a/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_storage.sol b/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_storage.sol
new file mode 100644
index 00000000..2664dbab
--- /dev/null
+++ b/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_storage.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f(bytes storage) external;
+}
+// ----
+// TypeError: (31-36): Location has to be calldata for external functions (remove the "memory" or "storage" keyword).
diff --git a/test/libsolidity/syntaxTests/dataLocations/function_argument_location_specifier_test_library.sol b/test/libsolidity/syntaxTests/dataLocations/function_argument_location_specifier_test_library.sol
new file mode 100644
index 00000000..4348482a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/dataLocations/function_argument_location_specifier_test_library.sol
@@ -0,0 +1,5 @@
+library test {
+ function f(bytes calldata) public;
+}
+// ----
+// TypeError: (30-35): Location cannot be calldata for non-external functions (remove the "calldata" keyword).
diff --git a/test/libsolidity/syntaxTests/dataLocations/function_argument_location_specifier_test_non_reference_type.sol b/test/libsolidity/syntaxTests/dataLocations/function_argument_location_specifier_test_non_reference_type.sol
new file mode 100644
index 00000000..70f6c5eb
--- /dev/null
+++ b/test/libsolidity/syntaxTests/dataLocations/function_argument_location_specifier_test_non_reference_type.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f(bytes4 memory) public;
+}
+// ----
+// TypeError: (31-37): Data location can only be given for array or struct types.
diff --git a/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_calldata.sol b/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_calldata.sol
new file mode 100644
index 00000000..f2740946
--- /dev/null
+++ b/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_calldata.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f(bytes calldata) internal;
+}
+// ----
+// TypeError: (31-36): Variable cannot be declared as "calldata" (remove the "calldata" keyword).
diff --git a/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_memory.sol b/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_memory.sol
new file mode 100644
index 00000000..1e5971c4
--- /dev/null
+++ b/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_memory.sol
@@ -0,0 +1,4 @@
+contract test {
+ function f(bytes memory) internal;
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_storage.sol b/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_storage.sol
new file mode 100644
index 00000000..56f0fe99
--- /dev/null
+++ b/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_storage.sol
@@ -0,0 +1,4 @@
+contract test {
+ function f(bytes storage) internal;
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_calldata.sol b/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_calldata.sol
new file mode 100644
index 00000000..cb00199f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_calldata.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f(bytes calldata) public;
+}
+// ----
+// TypeError: (31-36): Location has to be memory for publicly visible functions (remove the "storage" or "calldata" keyword).
diff --git a/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_memory.sol b/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_memory.sol
new file mode 100644
index 00000000..4eebf016
--- /dev/null
+++ b/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_memory.sol
@@ -0,0 +1,4 @@
+contract test {
+ function f(bytes memory) public;
+}
+// ----
diff --git a/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_storage.sol b/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_storage.sol
new file mode 100644
index 00000000..9380d9df
--- /dev/null
+++ b/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_storage.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f(bytes storage) public;
+}
+// ----
+// TypeError: (31-36): Location has to be memory for publicly visible functions (remove the "storage" or "calldata" keyword).
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
new file mode 100644
index 00000000..876d6fd6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/dataLocations/variable_declaration_location_specifier_test_non_reference_type.sol
@@ -0,0 +1,13 @@
+contract test {
+ function f() {
+ uint storage a1;
+ bytes16 storage b1;
+ uint memory a2;
+ bytes16 memory b2;
+ }
+}
+// ----
+// TypeError: (41-56): Data location can only be given for array or struct types.
+// TypeError: (64-82): Data location can only be given for array or struct types.
+// TypeError: (90-104): Data location can only be given for array or struct types.
+// TypeError: (112-129): Data location can only be given for array or struct types.
diff --git a/test/libsolidity/syntaxTests/dataLocations/variable_declaration_location_specifier_test_reference_type.sol b/test/libsolidity/syntaxTests/dataLocations/variable_declaration_location_specifier_test_reference_type.sol
new file mode 100644
index 00000000..bd011f2d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/dataLocations/variable_declaration_location_specifier_test_reference_type.sol
@@ -0,0 +1,14 @@
+contract test {
+ uint[] a;
+ uint[] b;
+ function f() public {
+ uint[] storage s1 = a;
+ uint[] memory s2 = new uint[](42);
+ uint[] s3 = b;
+ s1.push(42);
+ s2[3] = 12;
+ s3.push(42);
+ }
+}
+// ----
+// Warning: (147-156): Variable is declared as a storage pointer. Use an explicit "storage" keyword to silence this warning.
diff --git a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params.sol b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params.sol
index e021182a..72b6ce84 100644
--- a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params.sol
+++ b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params.sol
@@ -2,4 +2,4 @@ contract Foo {
function f(uint[] storage constant x, uint[] memory y) internal { }
}
// ----
-// TypeError: (30-55): Storage location has to be "memory" (or unspecified) for constants.
+// TypeError: (30-55): Data location has to be "memory" (or unspecified) for constants.