Skip to content

Commit f01fd51

Browse files
authored
Merge pull request #15661 from ipsilon/eof-syntax-tests-update
eof: Syntax tests update
2 parents a417955 + 52a2557 commit f01fd51

File tree

106 files changed

+726
-46
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+726
-46
lines changed

libevmasm/Assembly.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1660,7 +1660,14 @@ LinkerObject const& Assembly::assembleEOF() const
16601660

16611661
ptrdiff_t const relativeJumpOffset = static_cast<ptrdiff_t>(tagPos) - (static_cast<ptrdiff_t>(refPos) + 2);
16621662
// This cannot happen in practice because we'll run into section size limit first.
1663-
solAssert(-0x8000 <= relativeJumpOffset && relativeJumpOffset <= 0x7FFF, "Relative jump too far");
1663+
if (!(-0x8000 <= relativeJumpOffset && relativeJumpOffset <= 0x7FFF))
1664+
// TODO: Include source location. Note that origin locations we have in debug data are
1665+
// not usable for error reporting when compiling pure Yul because they point at the optimized source.
1666+
throw Error(
1667+
2703_error,
1668+
Error::Type::CodeGenerationError,
1669+
"Relative jump too far"
1670+
);
16641671
solAssert(relativeJumpOffset < -2 || 0 <= relativeJumpOffset, "Relative jump offset into immediate argument.");
16651672
setBigEndianUint16(ret.bytecode, refPos, static_cast<size_t>(static_cast<uint16_t>(relativeJumpOffset)));
16661673
}

test/libsolidity/SyntaxTest.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ SyntaxTest::SyntaxTest(
4848
{
4949
static std::set<std::string> const compileViaYulAllowedValues{"true", "false"};
5050

51-
m_compileViaYul = m_reader.stringSetting("compileViaYul", "false");
51+
auto const eofEnabled = solidity::test::CommonOptions::get().eofVersion().has_value();
52+
53+
m_compileViaYul = m_reader.stringSetting("compileViaYul", eofEnabled ? "true" : "false");
5254
if (!util::contains(compileViaYulAllowedValues, m_compileViaYul))
5355
BOOST_THROW_EXCEPTION(std::runtime_error("Invalid compileViaYul value: " + m_compileViaYul + "."));
5456
m_optimiseYul = m_reader.boolSetting("optimize-yul", true);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
pragma abicoder v2;
2+
3+
contract C {
4+
uint[][2] public tmp_i;
5+
function i(uint[][2] calldata s) external { tmp_i = s; }
6+
}
7+
// ====
8+
// compileViaYul: true
9+
// ----
10+
// i(uint256[][2]): 0x20, 0x40, 0xC0, 3, 0x0A01, 0x0A02, 0x0A03, 4, 0x0B01, 0x0B02, 0x0B03, 0x0B04
11+
// gas irOptimized: 223100
12+
// tmp_i(uint256,uint256): 0, 0 -> 0x0A01
13+
// tmp_i(uint256,uint256): 1, 0 -> 0x0B01
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
pragma abicoder v2;
2+
3+
contract C {
4+
uint[][] public tmp_i;
5+
function i(uint[][] calldata s) external { tmp_i = s; }
6+
}
7+
// ====
8+
// compileViaYul: true
9+
// ----
10+
// i(uint256[][]): 0x20, 2, 0x40, 0xC0, 3, 0x0A01, 0x0A02, 0x0A03, 4, 0x0B01, 0x0B02, 0x0B03, 0x0B04
11+
// gas irOptimized: 245506
12+
// tmp_i(uint256,uint256): 0, 0 -> 0x0A01
13+
// tmp_i(uint256,uint256): 1, 0 -> 0x0B01

test/libsolidity/syntaxTests/abiEncoder/v1_accessing_public_state_variable_via_v1_type.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ contract D {
1313
return a + b;
1414
}
1515
}
16+
// ====
17+
// bytecodeFormat: legacy
1618
// ----

test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v1_library_function_accepting_storage_struct.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@ contract Test {
1919
L.set(item);
2020
}
2121
}
22+
// ====
23+
// bytecodeFormat: legacy
2224
// ----

test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_library_function_accepting_storage_struct.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@ contract Test {
1919
L.get(item);
2020
}
2121
}
22+
// ====
23+
// bytecodeFormat: legacy
2224
// ----

test/libsolidity/syntaxTests/abiEncoder/v1_call_to_v2_modifier.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ contract C is B {
2525
validate()
2626
{}
2727
}
28+
// ====
29+
// bytecodeFormat: legacy
2830
// ----

test/libsolidity/syntaxTests/abiEncoder/v1_constructor_with_v2_modifier.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,6 @@ import "B";
3232
contract D is C {
3333
constructor() validate B() validate C() validate {}
3434
}
35+
// ====
36+
// bytecodeFormat: legacy
3537
// ----

test/libsolidity/syntaxTests/abiEncoder/v1_inheritance_from_contract_calling_v2_function.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ pragma abicoder v1;
2323
import "A";
2424

2525
contract C is B {}
26+
// ====
27+
// bytecodeFormat: legacy
2628
// ----

0 commit comments

Comments
 (0)