mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Tests.
This commit is contained in:
parent
290b1c3a90
commit
93dd8ad553
@ -0,0 +1,17 @@
|
||||
contract C {
|
||||
constructor() {
|
||||
uint256 x;
|
||||
assembly { x := 0 }
|
||||
f();
|
||||
}
|
||||
function f() internal pure {
|
||||
assembly "evmasm" ("memory-safe") { mstore(0, 0) }
|
||||
assembly ("memory-safe") { mstore(0, 0) }
|
||||
}
|
||||
function g() public pure {
|
||||
assembly { mstore(0, 0) }
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// :C(creation) true
|
||||
// :C(runtime) false
|
@ -0,0 +1,16 @@
|
||||
contract C {
|
||||
constructor() {
|
||||
uint256 x;
|
||||
assembly { x := 0 }
|
||||
f();
|
||||
}
|
||||
function f() internal pure {
|
||||
assembly { mstore(0, 0) }
|
||||
}
|
||||
function g() public pure {
|
||||
assembly "evmasm" ("memory-safe") { mstore(0, 0) }
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// :C(creation) false
|
||||
// :C(runtime) true
|
@ -0,0 +1,28 @@
|
||||
function safe() pure returns (uint256 x) {
|
||||
assembly { x := 42 }
|
||||
assembly "evmasm" ("memory-safe") { mstore(0, 0) }
|
||||
}
|
||||
function unsafe() pure returns (uint256 x) {
|
||||
assembly { pop(mload(0)) }
|
||||
}
|
||||
contract C {
|
||||
constructor() {
|
||||
unsafe();
|
||||
}
|
||||
function f() public pure {
|
||||
safe();
|
||||
}
|
||||
}
|
||||
contract D {
|
||||
constructor() {
|
||||
safe();
|
||||
}
|
||||
function f() public pure {
|
||||
unsafe();
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// :C(creation) false
|
||||
// :C(runtime) true
|
||||
// :D(creation) true
|
||||
// :D(runtime) false
|
@ -0,0 +1,23 @@
|
||||
contract C {
|
||||
constructor(uint256 x) {
|
||||
assembly { x := 4 }
|
||||
assembly "evmasm" ("memory-safe") { mstore(0, 0) }
|
||||
}
|
||||
function f() public pure {
|
||||
assembly { mstore(0,0) }
|
||||
}
|
||||
}
|
||||
contract D {
|
||||
constructor() {
|
||||
assembly { mstore(0,0) }
|
||||
}
|
||||
function f(uint256 x) public pure {
|
||||
assembly { x := 4 }
|
||||
assembly ("memory-safe") { mstore(0, 0) }
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// :C(creation) true
|
||||
// :C(runtime) false
|
||||
// :D(creation) false
|
||||
// :D(runtime) true
|
@ -0,0 +1,9 @@
|
||||
contract C {
|
||||
function f() external pure {
|
||||
assembly "evmasm" ("memory-safe") {}
|
||||
assembly {}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// :C(creation) true
|
||||
// :C(runtime) true
|
@ -0,0 +1,9 @@
|
||||
contract C {
|
||||
function f() external pure {
|
||||
assembly "evmasm" ("memory-safe") {}
|
||||
assembly { mstore(0,0) }
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// :C(creation) true
|
||||
// :C(runtime) false
|
4
test/libsolidity/memoryGuardTests/dialectString/stub.sol
Normal file
4
test/libsolidity/memoryGuardTests/dialectString/stub.sol
Normal file
@ -0,0 +1,4 @@
|
||||
contract C {}
|
||||
// ----
|
||||
// :C(creation) true
|
||||
// :C(runtime) true
|
@ -0,0 +1,5 @@
|
||||
function f() pure {
|
||||
assembly "evmasm" ("memory-safe", "memory-safe") {}
|
||||
}
|
||||
// ----
|
||||
// SyntaxError 7026: (24-75): Inline assembly marked memory-safe multiple times.
|
@ -0,0 +1,8 @@
|
||||
function f() pure {
|
||||
assembly "evmasm" ("a", "b", "c", "c") {}
|
||||
}
|
||||
// ----
|
||||
// Warning 4430: (24-65): Unknown inline assembly flag: "a"
|
||||
// Warning 4430: (24-65): Unknown inline assembly flag: "b"
|
||||
// Warning 4430: (24-65): Unknown inline assembly flag: "c"
|
||||
// Warning 4430: (24-65): Unknown inline assembly flag: "c"
|
@ -0,0 +1,5 @@
|
||||
function f() pure {
|
||||
assembly " evmasm" {}
|
||||
}
|
||||
// ----
|
||||
// ParserError 4531: (33-42): Only "evmasm" supported.
|
@ -0,0 +1,5 @@
|
||||
function f() pure {
|
||||
assembly ("memory-safe", "memory-safe") {}
|
||||
}
|
||||
// ----
|
||||
// SyntaxError 7026: (24-66): Inline assembly marked memory-safe multiple times.
|
@ -0,0 +1,5 @@
|
||||
function f() pure {
|
||||
assembly () {}
|
||||
}
|
||||
// ----
|
||||
// ParserError 2314: (34-35): Expected 'StringLiteral' but got ')'
|
@ -0,0 +1,5 @@
|
||||
function f() pure {
|
||||
assembly "evmasm" () {}
|
||||
}
|
||||
// ----
|
||||
// ParserError 2314: (43-44): Expected 'StringLiteral' but got ')'
|
@ -0,0 +1,5 @@
|
||||
function f() pure {
|
||||
assembly ("a" "b") {}
|
||||
}
|
||||
// ----
|
||||
// ParserError 2314: (35-38): Expected ')' but got 'StringLiteral'
|
@ -0,0 +1,8 @@
|
||||
function f() pure {
|
||||
assembly ("a", "b", "c", "c") {}
|
||||
}
|
||||
// ----
|
||||
// Warning 4430: (24-56): Unknown inline assembly flag: "a"
|
||||
// Warning 4430: (24-56): Unknown inline assembly flag: "b"
|
||||
// Warning 4430: (24-56): Unknown inline assembly flag: "c"
|
||||
// Warning 4430: (24-56): Unknown inline assembly flag: "c"
|
@ -0,0 +1,7 @@
|
||||
function f() pure {
|
||||
/// @solidity memory-safe-assembly
|
||||
assembly "evmasm" ("memory-safe") {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 8544: (63-104): Inline assembly marked as memory safe using both a NatSpec tag and an assembly flag. If you are not concerned with backwards compatibility, only use the assembly flag, otherwise only use the NatSpec tag.
|
@ -0,0 +1,3 @@
|
||||
function f() pure {
|
||||
assembly "evmasm" ("memory-safe") {}
|
||||
}
|
Loading…
Reference in New Issue
Block a user