aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-07-24 07:36:39 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-07-25 17:45:31 +0800
commitd647761058e3bb4b32846bd8b51f2de72fb85169 (patch)
tree56aca573199cc89c556ef8947d08e58d2c5e7ddb
parent167fe7c3706ba19713cd5727b62e7f019ad664d6 (diff)
downloaddexon-solidity-d647761058e3bb4b32846bd8b51f2de72fb85169.tar
dexon-solidity-d647761058e3bb4b32846bd8b51f2de72fb85169.tar.gz
dexon-solidity-d647761058e3bb4b32846bd8b51f2de72fb85169.tar.bz2
dexon-solidity-d647761058e3bb4b32846bd8b51f2de72fb85169.tar.lz
dexon-solidity-d647761058e3bb4b32846bd8b51f2de72fb85169.tar.xz
dexon-solidity-d647761058e3bb4b32846bd8b51f2de72fb85169.tar.zst
dexon-solidity-d647761058e3bb4b32846bd8b51f2de72fb85169.zip
Add more comprehensive tests for embedded inline assembly LValue/RValue access
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/assignment_from_contract.sol9
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/assignment_from_functiontype.sol7
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/assignment_from_library.sol10
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/assignment_from_super.sol9
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/assignment_to_special.sol13
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol13
-rw-r--r--test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol13
7 files changed, 74 insertions, 0 deletions
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_contract.sol b/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_contract.sol
new file mode 100644
index 00000000..a87a3e66
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_contract.sol
@@ -0,0 +1,9 @@
+contract C {
+ function f() public pure {
+ assembly {
+ let x := C
+ }
+ }
+}
+// ----
+// TypeError: (72-73): Expected a library.
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_functiontype.sol b/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_functiontype.sol
new file mode 100644
index 00000000..ecda3e99
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_functiontype.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public pure {
+ assembly {
+ let x := f
+ }
+ }
+}
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_library.sol b/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_library.sol
new file mode 100644
index 00000000..3c551c18
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_library.sol
@@ -0,0 +1,10 @@
+library L {
+}
+
+contract C {
+ function f() public pure {
+ assembly {
+ let x := L
+ }
+ }
+}
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_super.sol b/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_super.sol
new file mode 100644
index 00000000..bd5562d5
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_super.sol
@@ -0,0 +1,9 @@
+contract C {
+ function f() public pure {
+ assembly {
+ let x := super
+ }
+ }
+}
+// ----
+// DeclarationError: (72-77): Identifier not found.
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/assignment_to_special.sol b/test/libsolidity/syntaxTests/inlineAssembly/assignment_to_special.sol
new file mode 100644
index 00000000..db28e507
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inlineAssembly/assignment_to_special.sol
@@ -0,0 +1,13 @@
+contract C {
+ function f() public {
+ assembly {
+ super := 1
+ f := 1
+ C := 1
+ }
+ }
+}
+// ----
+// TypeError: (58-63): Only local variables can be assigned to in inline assembly.
+// TypeError: (75-76): Only local variables can be assigned to in inline assembly.
+// TypeError: (88-89): Only local variables can be assigned to in inline assembly.
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol
new file mode 100644
index 00000000..d5c8eaf5
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol
@@ -0,0 +1,13 @@
+contract C {
+ uint[] x;
+ function() external {
+ uint[] storage y = x;
+ assembly {
+ y_slot := 1
+ y_offset := 2
+ }
+ }
+}
+// ----
+// TypeError: (115-121): Storage variables cannot be assigned to.
+// TypeError: (139-147): Storage variables cannot be assigned to.
diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol
new file mode 100644
index 00000000..4025e11c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol
@@ -0,0 +1,13 @@
+contract C {
+ uint[] x;
+ function() external {
+ uint[] memory y = x;
+ assembly {
+ pop(y_slot)
+ pop(y_offset)
+ }
+ }
+}
+// ----
+// TypeError: (118-124): The suffixes _offset and _slot can only be used on storage variables.
+// TypeError: (142-150): The suffixes _offset and _slot can only be used on storage variables.