From 02d1f8c41aa4d9d36a002d12f3ced24ac21bdb85 Mon Sep 17 00:00:00 2001 From: a3d4 Date: Tue, 12 May 2020 18:13:17 +0200 Subject: [PATCH 01/15] Remove a dedicated error flag from DeclarationTypeChecker --- liblangutil/ErrorReporter.h | 6 ++++++ libsolidity/analysis/DeclarationTypeChecker.cpp | 6 ++---- libsolidity/analysis/DeclarationTypeChecker.h | 1 - .../nameAndTypeResolution/105_constant_input_parameter.sol | 2 -- .../syntaxTests/parsing/location_specifiers_for_params.sol | 2 -- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/liblangutil/ErrorReporter.h b/liblangutil/ErrorReporter.h index 466bb66cb..a52e978af 100644 --- a/liblangutil/ErrorReporter.h +++ b/liblangutil/ErrorReporter.h @@ -134,6 +134,12 @@ public: return m_errorCount > 0; } + /// @returns the number of errors (ignores warnings). + unsigned errorCount() const + { + return m_errorCount; + } + // @returns true if the maximum error count has been reached. bool hasExcessiveErrors() const; diff --git a/libsolidity/analysis/DeclarationTypeChecker.cpp b/libsolidity/analysis/DeclarationTypeChecker.cpp index 4e55151e9..a06679b97 100644 --- a/libsolidity/analysis/DeclarationTypeChecker.cpp +++ b/libsolidity/analysis/DeclarationTypeChecker.cpp @@ -361,24 +361,22 @@ void DeclarationTypeChecker::endVisit(VariableDeclaration const& _variable) void DeclarationTypeChecker::typeError(SourceLocation const& _location, string const& _description) { - m_errorOccurred = true; m_errorReporter.typeError(2311_error, _location, _description); } void DeclarationTypeChecker::fatalTypeError(SourceLocation const& _location, string const& _description) { - m_errorOccurred = true; m_errorReporter.fatalTypeError(5651_error, _location, _description); } void DeclarationTypeChecker::fatalDeclarationError(SourceLocation const& _location, string const& _description) { - m_errorOccurred = true; m_errorReporter.fatalDeclarationError(2046_error, _location, _description); } bool DeclarationTypeChecker::check(ASTNode const& _node) { + unsigned errorCount = m_errorReporter.errorCount(); _node.accept(*this); - return !m_errorOccurred; + return m_errorReporter.errorCount() == errorCount; } diff --git a/libsolidity/analysis/DeclarationTypeChecker.h b/libsolidity/analysis/DeclarationTypeChecker.h index b704c4fd2..e54075998 100644 --- a/libsolidity/analysis/DeclarationTypeChecker.h +++ b/libsolidity/analysis/DeclarationTypeChecker.h @@ -69,7 +69,6 @@ private: void fatalDeclarationError(langutil::SourceLocation const& _location, std::string const& _description); langutil::ErrorReporter& m_errorReporter; - bool m_errorOccurred = false; langutil::EVMVersion m_evmVersion; bool m_insideFunctionType = false; bool m_recursiveStructSeen = false; diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/105_constant_input_parameter.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/105_constant_input_parameter.sol index ba05fcb31..aab8a183a 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/105_constant_input_parameter.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/105_constant_input_parameter.sol @@ -3,5 +3,3 @@ contract test { } // ---- // DeclarationError: (31-55): The "constant" keyword can only be used for state variables. -// TypeError: (31-55): Constants of non-value type not yet implemented. -// TypeError: (31-55): Uninitialized "constant" variable. diff --git a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params.sol b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params.sol index bf78e59c6..b9b1f97cd 100644 --- a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params.sol +++ b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params.sol @@ -3,5 +3,3 @@ contract Foo { } // ---- // DeclarationError: (30-55): The "constant" keyword can only be used for state variables. -// TypeError: (30-55): Constants of non-value type not yet implemented. -// TypeError: (30-55): Uninitialized "constant" variable. From 47e9a13e8afc504d034119eac3edec6deb2f8a52 Mon Sep 17 00:00:00 2001 From: Harikrishnan Mulackal Date: Tue, 12 May 2020 12:36:21 +0530 Subject: [PATCH 02/15] Fix exponentiation bug --- Changelog.md | 1 + libsolidity/ast/Types.cpp | 7 +++++++ .../syntaxTests/literalOperations/exponent.sol | 10 ++++++++++ .../syntaxTests/literalOperations/exponent_fine.sol | 7 +++++++ 4 files changed, 25 insertions(+) create mode 100644 test/libsolidity/syntaxTests/literalOperations/exponent.sol create mode 100644 test/libsolidity/syntaxTests/literalOperations/exponent_fine.sol diff --git a/Changelog.md b/Changelog.md index 996904b27..8709aa947 100644 --- a/Changelog.md +++ b/Changelog.md @@ -19,6 +19,7 @@ Bugfixes: * Fixed an "Assembly Exception in Bytecode" error where requested functions were generated twice. * Natspec: Fixed a bug that ignored ``@return`` tag when no other developer-documentation tags were present. * Yul assembler: Fix source location of variable declarations without value. + * Type checker: Checks if a literal exponent in the ``**`` operation is too large or fractional. ### 0.6.7 (2020-05-04) diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index aa888d26b..c9d40a1ce 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -613,6 +613,13 @@ TypeResult IntegerType::binaryOperatorResult(Token _operator, Type const* _other } else if (dynamic_cast(_other)) return nullptr; + else if (auto rationalNumberType = dynamic_cast(_other)) + { + if (rationalNumberType->isFractional()) + return TypeResult::err("Exponent is fractional."); + if (!rationalNumberType->integerType()) + return TypeResult::err("Exponent too large."); + } return this; } diff --git a/test/libsolidity/syntaxTests/literalOperations/exponent.sol b/test/libsolidity/syntaxTests/literalOperations/exponent.sol new file mode 100644 index 000000000..cee6263b7 --- /dev/null +++ b/test/libsolidity/syntaxTests/literalOperations/exponent.sol @@ -0,0 +1,10 @@ +contract C { + function g() public pure { + int a; + a ** 1E1233; + a ** (1/2); + } +} +// ---- +// TypeError: (67-78): Operator ** not compatible with types int256 and int_const 1000...(1226 digits omitted)...0000. Exponent too large. +// TypeError: (88-98): Operator ** not compatible with types int256 and rational_const 1 / 2. Exponent is fractional. diff --git a/test/libsolidity/syntaxTests/literalOperations/exponent_fine.sol b/test/libsolidity/syntaxTests/literalOperations/exponent_fine.sol new file mode 100644 index 000000000..56fed09ae --- /dev/null +++ b/test/libsolidity/syntaxTests/literalOperations/exponent_fine.sol @@ -0,0 +1,7 @@ +contract C { + function f() public pure { + uint a; + a = a ** 1E5; + a = 0 ** 1E1233; + } +} From 6f04664cfa1d64c00a30760b643e1c17fcc44514 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Wed, 13 May 2020 11:00:47 +0200 Subject: [PATCH 03/15] Disallow array slicing for arrays with dyanmically encoded base types. --- Changelog.md | 1 + docs/bugs.json | 11 +++++++++++ docs/bugs_by_version.json | 8 ++++++++ libsolidity/analysis/TypeChecker.cpp | 2 ++ libsolidity/codegen/CompilerUtils.cpp | 3 ++- libsolidity/codegen/ExpressionCompiler.cpp | 14 ++++++++++++-- libsolidity/codegen/YulUtilFunctions.cpp | 1 + .../syntaxTests/parsing/array_range_nested.sol | 5 ++--- .../parsing/array_range_nested_invalid.sol | 14 ++++++++++++++ 9 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 test/libsolidity/syntaxTests/parsing/array_range_nested_invalid.sol diff --git a/Changelog.md b/Changelog.md index 996904b27..25b457873 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,7 @@ Important Bugfixes: * Add missing callvalue check to the creation code of a contract that does not define a constructor but has a base that does define a constructor. + * Disallow index range accesses for arrays with dynamically encoded base types. Language Features: diff --git a/docs/bugs.json b/docs/bugs.json index c251fa114..a32b27fb4 100644 --- a/docs/bugs.json +++ b/docs/bugs.json @@ -1,4 +1,15 @@ [ + { + "name": "ArraySliceDynamicallyEncodedBaseType", + "summary": "Accessing array slices of arrays with dynamically encoded base types (e.g. multi-dimensional arrays) can result in invalid data being read.", + "description": "For arrays with dynamically sized base types, index range accesses that use a start expression that is non-zero will result in invalid array slices. Any index access to such array slices will result in data being read from incorrect calldata offsets. Array slices are only supported for dynamic calldata types and all problematic type require ABIEncoderV2 to be enabled.", + "introduced": "0.6.0", + "fixed": "0.6.8", + "severity": "very low", + "conditions": { + "ABIEncoderV2": true + } + }, { "name": "ImplicitConstructorCallvalueCheck", "summary": "The creation code of a contract that does not define a constructor but has a base that does define a constructor did not revert for calls with non-zero value.", diff --git a/docs/bugs_by_version.json b/docs/bugs_by_version.json index 0398e4cd7..ac0c4b9f1 100644 --- a/docs/bugs_by_version.json +++ b/docs/bugs_by_version.json @@ -1082,6 +1082,7 @@ }, "0.6.0": { "bugs": [ + "ArraySliceDynamicallyEncodedBaseType", "ImplicitConstructorCallvalueCheck", "TupleAssignmentMultiStackSlotComponents", "MemoryArrayCreationOverflow", @@ -1091,6 +1092,7 @@ }, "0.6.1": { "bugs": [ + "ArraySliceDynamicallyEncodedBaseType", "ImplicitConstructorCallvalueCheck", "TupleAssignmentMultiStackSlotComponents", "MemoryArrayCreationOverflow" @@ -1099,6 +1101,7 @@ }, "0.6.2": { "bugs": [ + "ArraySliceDynamicallyEncodedBaseType", "ImplicitConstructorCallvalueCheck", "TupleAssignmentMultiStackSlotComponents", "MemoryArrayCreationOverflow" @@ -1107,6 +1110,7 @@ }, "0.6.3": { "bugs": [ + "ArraySliceDynamicallyEncodedBaseType", "ImplicitConstructorCallvalueCheck", "TupleAssignmentMultiStackSlotComponents", "MemoryArrayCreationOverflow" @@ -1115,6 +1119,7 @@ }, "0.6.4": { "bugs": [ + "ArraySliceDynamicallyEncodedBaseType", "ImplicitConstructorCallvalueCheck", "TupleAssignmentMultiStackSlotComponents", "MemoryArrayCreationOverflow" @@ -1123,6 +1128,7 @@ }, "0.6.5": { "bugs": [ + "ArraySliceDynamicallyEncodedBaseType", "ImplicitConstructorCallvalueCheck", "TupleAssignmentMultiStackSlotComponents" ], @@ -1130,12 +1136,14 @@ }, "0.6.6": { "bugs": [ + "ArraySliceDynamicallyEncodedBaseType", "ImplicitConstructorCallvalueCheck" ], "released": "2020-04-09" }, "0.6.7": { "bugs": [ + "ArraySliceDynamicallyEncodedBaseType", "ImplicitConstructorCallvalueCheck" ], "released": "2020-05-04" diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 380879c73..ebb7bf6e6 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -2864,6 +2864,8 @@ bool TypeChecker::visit(IndexRangeAccess const& _access) if (arrayType->location() != DataLocation::CallData || !arrayType->isDynamicallySized()) m_errorReporter.typeError(1227_error, _access.location(), "Index range access is only supported for dynamic calldata arrays."); + else if (arrayType->baseType()->isDynamicallyEncoded()) + m_errorReporter.typeError(1878_error, _access.location(), "Index range access is not supported for arrays with dynamically encoded base types."); _access.annotation().type = TypeProvider::arraySlice(*arrayType); _access.annotation().isLValue = isLValue; _access.annotation().isPure = isPure; diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp index 156cee565..feae52caa 100644 --- a/libsolidity/codegen/CompilerUtils.cpp +++ b/libsolidity/codegen/CompilerUtils.cpp @@ -990,7 +990,8 @@ void CompilerUtils::convertType( solAssert(_targetType == typeOnStack.arrayType(), ""); solUnimplementedAssert( typeOnStack.arrayType().location() == DataLocation::CallData && - typeOnStack.arrayType().isDynamicallySized(), + typeOnStack.arrayType().isDynamicallySized() && + !typeOnStack.arrayType().baseType()->isDynamicallyEncoded(), "" ); break; diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 7b07cc48a..f05ffda8f 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -1769,7 +1769,12 @@ bool ExpressionCompiler::visit(IndexAccess const& _indexAccess) case Type::Category::ArraySlice: { auto const& arrayType = dynamic_cast(baseType).arrayType(); - solAssert(arrayType.location() == DataLocation::CallData && arrayType.isDynamicallySized(), ""); + solAssert( + arrayType.location() == DataLocation::CallData && + arrayType.isDynamicallySized() && + !arrayType.baseType()->isDynamicallyEncoded(), + "" + ); solAssert(_indexAccess.indexExpression(), "Index expression expected."); acceptAndConvert(*_indexAccess.indexExpression(), *TypeProvider::uint256(), true); @@ -1852,7 +1857,12 @@ bool ExpressionCompiler::visit(IndexRangeAccess const& _indexAccess) arrayType = &sliceType->arrayType(); solAssert(arrayType, ""); - solUnimplementedAssert(arrayType->location() == DataLocation::CallData && arrayType->isDynamicallySized(), ""); + solUnimplementedAssert( + arrayType->location() == DataLocation::CallData && + arrayType->isDynamicallySized() && + !arrayType->baseType()->isDynamicallyEncoded(), + "" + ); if (_indexAccess.startExpression()) acceptAndConvert(*_indexAccess.startExpression(), *TypeProvider::uint256()); diff --git a/libsolidity/codegen/YulUtilFunctions.cpp b/libsolidity/codegen/YulUtilFunctions.cpp index f7bb31447..4fd681e1f 100644 --- a/libsolidity/codegen/YulUtilFunctions.cpp +++ b/libsolidity/codegen/YulUtilFunctions.cpp @@ -1599,6 +1599,7 @@ string YulUtilFunctions::conversionFunction(Type const& _from, Type const& _to) ArraySliceType const& fromType = dynamic_cast(_from); ArrayType const& targetType = dynamic_cast(_to); + solAssert(!fromType.arrayType().baseType()->isDynamicallyEncoded(), ""); solAssert( *fromType.arrayType().baseType() == *targetType.baseType(), "Converting arrays of different type is not possible" diff --git a/test/libsolidity/syntaxTests/parsing/array_range_nested.sol b/test/libsolidity/syntaxTests/parsing/array_range_nested.sol index 847d7596d..16fde7999 100644 --- a/test/libsolidity/syntaxTests/parsing/array_range_nested.sol +++ b/test/libsolidity/syntaxTests/parsing/array_range_nested.sol @@ -2,9 +2,8 @@ pragma experimental ABIEncoderV2; contract C { function f(uint256[][] calldata x) external pure { x[0][1:2]; - x[1:2][1:2]; - uint256 a = x[1:2][1:2][1:][3:][0][2]; - uint256 b = x[1:][3:4][1][1:][2:3][0]; + uint256 a = x[0][1:2][1:2][1:][3:][0]; + uint256 b = x[1][1:][3:4][1:][2:3][0]; a; b; } } diff --git a/test/libsolidity/syntaxTests/parsing/array_range_nested_invalid.sol b/test/libsolidity/syntaxTests/parsing/array_range_nested_invalid.sol new file mode 100644 index 000000000..bc53d3faf --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/array_range_nested_invalid.sol @@ -0,0 +1,14 @@ +pragma experimental ABIEncoderV2; +contract C { + function f(uint256[][] calldata x) external pure { + x[1:2]; + x[:]; + x[1:]; + x[:2]; + } +} +// ---- +// TypeError: (110-116): Index range access is not supported for arrays with dynamically encoded base types. +// TypeError: (126-130): Index range access is not supported for arrays with dynamically encoded base types. +// TypeError: (140-145): Index range access is not supported for arrays with dynamically encoded base types. +// TypeError: (155-160): Index range access is not supported for arrays with dynamically encoded base types. From 820fdd9bf70a74af470d0f841d9fdfe8f3521a28 Mon Sep 17 00:00:00 2001 From: Mathias Baumann Date: Thu, 7 May 2020 19:19:54 +0200 Subject: [PATCH 04/15] Escape backslashes when formatting --- Changelog.md | 1 + docs/bugs.json | 11 ++++++ docs/bugs_by_version.json | 12 +++++++ libsolutil/CommonData.cpp | 36 ++++++++++++++++++- libsolutil/CommonData.h | 4 +++ libyul/AsmPrinter.cpp | 28 +-------------- .../semanticTests/literals/escape.sol | 13 +++++++ 7 files changed, 77 insertions(+), 28 deletions(-) create mode 100644 test/libsolidity/semanticTests/literals/escape.sol diff --git a/Changelog.md b/Changelog.md index 8d7ff006a..10d6b3fc3 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,6 +3,7 @@ Important Bugfixes: * Add missing callvalue check to the creation code of a contract that does not define a constructor but has a base that does define a constructor. * Disallow index range accesses for arrays with dynamically encoded base types. + * Code Generator: Fixed that string literals containing backslash characters could cause incorrect code to be generated when passed directly to function calls or encoding functions when ABIEncoderV2 is active. Language Features: diff --git a/docs/bugs.json b/docs/bugs.json index a32b27fb4..90f211c1f 100644 --- a/docs/bugs.json +++ b/docs/bugs.json @@ -1,4 +1,15 @@ [ + { + "name": "MissingEscapingInFormatting", + "summary": "String literals containing double backslash characters passed directly to external or encoding function calls can lead to a different string being used when ABIEncoderV2 is enabled.", + "description": "When ABIEncoderV2 is enabled, string literals passed directly to encoding functions or external function calls are stored as strings in the intemediate code. Characters outside the printable range are handled correctly, but backslashes are not escaped in this procedure. This leads to double backslashes being reduced to single backslashes and consequently re-interpreted as escapes potentially resulting in a different string being encoded.", + "introduced": "0.5.14", + "fixed": "0.6.8", + "severity": "very low", + "conditions": { + "ABIEncoderV2": true + } + }, { "name": "ArraySliceDynamicallyEncodedBaseType", "summary": "Accessing array slices of arrays with dynamically encoded base types (e.g. multi-dimensional arrays) can result in invalid data being read.", diff --git a/docs/bugs_by_version.json b/docs/bugs_by_version.json index ac0c4b9f1..0f96fb509 100644 --- a/docs/bugs_by_version.json +++ b/docs/bugs_by_version.json @@ -923,6 +923,7 @@ }, "0.5.14": { "bugs": [ + "MissingEscapingInFormatting", "ImplicitConstructorCallvalueCheck", "TupleAssignmentMultiStackSlotComponents", "MemoryArrayCreationOverflow", @@ -934,6 +935,7 @@ }, "0.5.15": { "bugs": [ + "MissingEscapingInFormatting", "ImplicitConstructorCallvalueCheck", "TupleAssignmentMultiStackSlotComponents", "MemoryArrayCreationOverflow", @@ -944,6 +946,7 @@ }, "0.5.16": { "bugs": [ + "MissingEscapingInFormatting", "ImplicitConstructorCallvalueCheck", "TupleAssignmentMultiStackSlotComponents", "MemoryArrayCreationOverflow", @@ -953,6 +956,7 @@ }, "0.5.17": { "bugs": [ + "MissingEscapingInFormatting", "ImplicitConstructorCallvalueCheck", "TupleAssignmentMultiStackSlotComponents", "MemoryArrayCreationOverflow" @@ -1082,6 +1086,7 @@ }, "0.6.0": { "bugs": [ + "MissingEscapingInFormatting", "ArraySliceDynamicallyEncodedBaseType", "ImplicitConstructorCallvalueCheck", "TupleAssignmentMultiStackSlotComponents", @@ -1092,6 +1097,7 @@ }, "0.6.1": { "bugs": [ + "MissingEscapingInFormatting", "ArraySliceDynamicallyEncodedBaseType", "ImplicitConstructorCallvalueCheck", "TupleAssignmentMultiStackSlotComponents", @@ -1101,6 +1107,7 @@ }, "0.6.2": { "bugs": [ + "MissingEscapingInFormatting", "ArraySliceDynamicallyEncodedBaseType", "ImplicitConstructorCallvalueCheck", "TupleAssignmentMultiStackSlotComponents", @@ -1110,6 +1117,7 @@ }, "0.6.3": { "bugs": [ + "MissingEscapingInFormatting", "ArraySliceDynamicallyEncodedBaseType", "ImplicitConstructorCallvalueCheck", "TupleAssignmentMultiStackSlotComponents", @@ -1119,6 +1127,7 @@ }, "0.6.4": { "bugs": [ + "MissingEscapingInFormatting", "ArraySliceDynamicallyEncodedBaseType", "ImplicitConstructorCallvalueCheck", "TupleAssignmentMultiStackSlotComponents", @@ -1128,6 +1137,7 @@ }, "0.6.5": { "bugs": [ + "MissingEscapingInFormatting", "ArraySliceDynamicallyEncodedBaseType", "ImplicitConstructorCallvalueCheck", "TupleAssignmentMultiStackSlotComponents" @@ -1136,6 +1146,7 @@ }, "0.6.6": { "bugs": [ + "MissingEscapingInFormatting", "ArraySliceDynamicallyEncodedBaseType", "ImplicitConstructorCallvalueCheck" ], @@ -1143,6 +1154,7 @@ }, "0.6.7": { "bugs": [ + "MissingEscapingInFormatting", "ArraySliceDynamicallyEncodedBaseType", "ImplicitConstructorCallvalueCheck" ], diff --git a/libsolutil/CommonData.cpp b/libsolutil/CommonData.cpp index 2024a1b1f..bb1a7696c 100644 --- a/libsolutil/CommonData.cpp +++ b/libsolutil/CommonData.cpp @@ -188,5 +188,39 @@ string solidity::util::formatAsStringOrNumber(string const& _value) if (c <= 0x1f || c >= 0x7f || c == '"') return "0x" + h256(_value, h256::AlignLeft).hex(); - return "\"" + _value + "\""; + return escapeAndQuoteString(_value); +} + + +string solidity::util::escapeAndQuoteString(string const& _input) +{ + string out; + + for (char c: _input) + if (c == '\\') + out += "\\\\"; + else if (c == '"') + out += "\\\""; + else if (c == '\b') + out += "\\b"; + else if (c == '\f') + out += "\\f"; + else if (c == '\n') + out += "\\n"; + else if (c == '\r') + out += "\\r"; + else if (c == '\t') + out += "\\t"; + else if (c == '\v') + out += "\\v"; + else if (!isprint(c, locale::classic())) + { + ostringstream o; + o << "\\x" << std::hex << setfill('0') << setw(2) << (unsigned)(unsigned char)(c); + out += o.str(); + } + else + out += c; + + return "\"" + std::move(out) + "\""; } diff --git a/libsolutil/CommonData.h b/libsolutil/CommonData.h index bd1133511..adac1fb05 100644 --- a/libsolutil/CommonData.h +++ b/libsolutil/CommonData.h @@ -460,6 +460,10 @@ bool isValidDecimal(std::string const& _string); /// _value cannot be longer than 32 bytes. std::string formatAsStringOrNumber(std::string const& _value); +/// @returns a string with the usual backslash-escapes for non-ASCII +/// characters and surrounded by '"'-characters. +std::string escapeAndQuoteString(std::string const& _input); + template bool containerEqual(Container const& _lhs, Container const& _rhs, Compare&& _compare) { diff --git a/libyul/AsmPrinter.cpp b/libyul/AsmPrinter.cpp index 93fb089ed..97a7dc3ad 100644 --- a/libyul/AsmPrinter.cpp +++ b/libyul/AsmPrinter.cpp @@ -55,33 +55,7 @@ string AsmPrinter::operator()(Literal const& _literal) const break; } - string out; - for (char c: _literal.value.str()) - if (c == '\\') - out += "\\\\"; - else if (c == '"') - out += "\\\""; - else if (c == '\b') - out += "\\b"; - else if (c == '\f') - out += "\\f"; - else if (c == '\n') - out += "\\n"; - else if (c == '\r') - out += "\\r"; - else if (c == '\t') - out += "\\t"; - else if (c == '\v') - out += "\\v"; - else if (!isprint(c, locale::classic())) - { - ostringstream o; - o << std::hex << setfill('0') << setw(2) << (unsigned)(unsigned char)(c); - out += "\\x" + o.str(); - } - else - out += c; - return "\"" + out + "\"" + appendTypeName(_literal.type); + return escapeAndQuoteString(_literal.value.str()) + appendTypeName(_literal.type); } string AsmPrinter::operator()(Identifier const& _identifier) const diff --git a/test/libsolidity/semanticTests/literals/escape.sol b/test/libsolidity/semanticTests/literals/escape.sol new file mode 100644 index 000000000..8f015297e --- /dev/null +++ b/test/libsolidity/semanticTests/literals/escape.sol @@ -0,0 +1,13 @@ +pragma experimental ABIEncoderV2; + +contract C +{ + function f() public pure returns (uint, byte, byte) { + bytes memory encoded = abi.encodePacked("\\\\"); + return (encoded.length, encoded[0], encoded[1]); + } +} +// ==== +// compileViaYul: also +// ---- +// f() -> 2, 0x5c00000000000000000000000000000000000000000000000000000000000000, 0x5c00000000000000000000000000000000000000000000000000000000000000 From 3872a1f000f7aa19b05b003d99a82f17c73e98ff Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 12 May 2020 11:56:28 +0200 Subject: [PATCH 05/15] Add support for SPDX license identifiers. --- liblangutil/ParserBase.cpp | 5 ++ liblangutil/ParserBase.h | 1 + libsolidity/ast/AST.h | 11 +++- libsolidity/ast/ASTJsonConverter.cpp | 1 + libsolidity/ast/ASTJsonImporter.cpp | 7 ++- libsolidity/interface/CompilerStack.cpp | 2 + libsolidity/parsing/Parser.cpp | 60 ++++++++++++++++++- libsolidity/parsing/Parser.h | 2 + test/libsolidity/ABIJsonTest.cpp | 5 +- test/libsolidity/AnalysisFramework.cpp | 8 ++- test/libsolidity/AnalysisFramework.h | 2 +- test/libsolidity/GasMeter.cpp | 3 +- test/libsolidity/GasTest.cpp | 4 +- test/libsolidity/SMTChecker.cpp | 4 +- test/libsolidity/SMTCheckerJSONTest.cpp | 12 ++-- .../SolidityNameAndTypeResolution.cpp | 1 + test/libsolidity/SolidityTypes.cpp | 2 +- test/libsolidity/StandardCompiler.cpp | 2 +- test/libsolidity/SyntaxTest.cpp | 16 ++--- 19 files changed, 119 insertions(+), 29 deletions(-) diff --git a/liblangutil/ParserBase.cpp b/liblangutil/ParserBase.cpp index f0ebefd93..be8ec3eb9 100644 --- a/liblangutil/ParserBase.cpp +++ b/liblangutil/ParserBase.cpp @@ -148,6 +148,11 @@ void ParserBase::parserWarning(ErrorId _error, string const& _description) m_errorReporter.warning(_error, currentLocation(), _description); } +void ParserBase::parserWarning(ErrorId _error, SourceLocation const& _location, string const& _description) +{ + m_errorReporter.warning(_error, _location, _description); +} + void ParserBase::parserError(ErrorId _error, SourceLocation const& _location, string const& _description) { m_errorReporter.parserError(_error, _location, _description); diff --git a/liblangutil/ParserBase.h b/liblangutil/ParserBase.h index 8a8073696..bb4123b9f 100644 --- a/liblangutil/ParserBase.h +++ b/liblangutil/ParserBase.h @@ -95,6 +95,7 @@ protected: /// Creates a @ref ParserWarning and annotates it with the current position and the /// given @a _description. void parserWarning(ErrorId _error, std::string const& _description); + void parserWarning(ErrorId _error, SourceLocation const& _location, std::string const& _description); /// Creates a @ref ParserError and annotates it with the current position and the /// given @a _description. Throws the FatalError. diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index 3c79912c2..0c4e181e8 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -156,19 +156,26 @@ std::vector ASTNode::filteredNodes(std::vector> co class SourceUnit: public ASTNode { public: - SourceUnit(int64_t _id, SourceLocation const& _location, std::vector> _nodes): - ASTNode(_id, _location), m_nodes(std::move(_nodes)) {} + SourceUnit( + int64_t _id, + SourceLocation const& _location, + std::optional _licenseString, + std::vector> _nodes + ): + ASTNode(_id, _location), m_licenseString(std::move(_licenseString)), m_nodes(std::move(_nodes)) {} void accept(ASTVisitor& _visitor) override; void accept(ASTConstVisitor& _visitor) const override; SourceUnitAnnotation& annotation() const override; + std::optional const& licenseString() const { return m_licenseString; } std::vector> nodes() const { return m_nodes; } /// @returns a set of referenced SourceUnits. Recursively if @a _recurse is true. std::set referencedSourceUnits(bool _recurse = false, std::set _skipList = std::set()) const; private: + std::optional m_licenseString; std::vector> m_nodes; }; diff --git a/libsolidity/ast/ASTJsonConverter.cpp b/libsolidity/ast/ASTJsonConverter.cpp index 9f61184be..603781b26 100644 --- a/libsolidity/ast/ASTJsonConverter.cpp +++ b/libsolidity/ast/ASTJsonConverter.cpp @@ -225,6 +225,7 @@ bool ASTJsonConverter::visit(SourceUnit const& _node) { make_pair("absolutePath", _node.annotation().path), make_pair("exportedSymbols", move(exportedSymbols)), + make_pair("license", _node.licenseString() ? Json::Value(*_node.licenseString()) : Json::nullValue), make_pair("nodes", toJson(_node.nodes())) } ); diff --git a/libsolidity/ast/ASTJsonImporter.cpp b/libsolidity/ast/ASTJsonImporter.cpp index e4538059d..c0bee4c60 100644 --- a/libsolidity/ast/ASTJsonImporter.cpp +++ b/libsolidity/ast/ASTJsonImporter.cpp @@ -218,10 +218,15 @@ ASTPointer ASTJsonImporter::convertJsonToASTNode(Json::Value const& _js ASTPointer ASTJsonImporter::createSourceUnit(Json::Value const& _node, string const& _srcName) { + optional license; + if (_node.isMember("license") && !_node["license"].isNull()) + license = _node["license"].asString(); + vector> nodes; for (auto& child: member(_node, "nodes")) nodes.emplace_back(convertJsonToASTNode(child)); - ASTPointer tmp = createASTNode(_node, nodes); + + ASTPointer tmp = createASTNode(_node, license, nodes); tmp->annotation().path = _srcName; return tmp; } diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index da561050b..e50d8990a 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -1236,6 +1236,8 @@ string CompilerStack::createMetadata(Contract const& _contract) const solAssert(s.second.scanner, "Scanner not available"); meta["sources"][s.first]["keccak256"] = "0x" + toHex(s.second.keccak256().asBytes()); + if (optional licenseString = s.second.ast->licenseString()) + meta["sources"][s.first]["license"] = *licenseString; if (m_metadataLiteralSources) meta["sources"][s.first]["content"] = s.second.scanner->source(); else diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index 99b9a2cac..7ae22dc70 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -30,8 +30,11 @@ #include #include #include +#include +#include #include #include +#include using namespace std; using namespace solidity::langutil; @@ -79,6 +82,7 @@ ASTPointer Parser::parse(shared_ptr const& _scanner) m_recursionDepth = 0; m_scanner = _scanner; ASTNodeFactory nodeFactory(*this); + vector> nodes; while (m_scanner->currentToken() != Token::EOS) { @@ -107,7 +111,7 @@ ASTPointer Parser::parse(shared_ptr const& _scanner) } } solAssert(m_recursionDepth == 0, ""); - return nodeFactory.createNode(nodes); + return nodeFactory.createNode(findLicenseString(nodes), nodes); } catch (FatalError const&) { @@ -1981,6 +1985,60 @@ pair>, vector>> Parser::pars return ret; } +optional Parser::findLicenseString(std::vector> const& _nodes) +{ + // We circumvent the scanner here, because it skips non-docstring comments. + static regex const licenseRegex("SPDX-License-Identifier:\\s*([a-zA-Z0-9 ()+.-]+)"); + + // Search inside all parts of the source not covered by parsed nodes. + // This will leave e.g. "global comments". + string const& source = m_scanner->source(); + using iter = decltype(source.begin()); + vector> sequencesToSearch; + sequencesToSearch.emplace_back(source.begin(), source.end()); + for (ASTPointer const& node: _nodes) + if (node->location().hasText()) + { + sequencesToSearch.back().second = source.begin() + node->location().start; + sequencesToSearch.emplace_back(source.begin() + node->location().end, source.end()); + } + + vector matches; + for (auto const& [start, end]: sequencesToSearch) + { + smatch match; + if (regex_search(start, end, match, licenseRegex)) + { + string license{boost::trim_copy(string(match[1]))}; + if (!license.empty()) + matches.emplace_back(std::move(license)); + } + } + + if (matches.size() == 1) + return matches.front(); + else if (matches.empty()) + parserWarning( + 1878_error, + {-1, -1, m_scanner->charStream()}, + "SPDX license identifier not provided in source file. " + "Before publishing, consider adding a comment containing " + "\"SPDX-License-Identifier: \" to each source file. " + "Use \"SPDX-License-Identifier: UNLICENSED\" for non-open-source code. " + "Please see https://spdx.org for more information." + ); + else + parserError( + 3716_error, + {-1, -1, m_scanner->charStream()}, + "Multiple SPDX license identifiers found in source file. " + "Use \"AND\" or \"OR\" to combine multiple licenses. " + "Please see https://spdx.org for more information." + ); + + return {}; +} + Parser::LookAheadInfo Parser::peekStatementType() const { // Distinguish between variable declaration (and potentially assignment) and expression statement diff --git a/libsolidity/parsing/Parser.h b/libsolidity/parsing/Parser.h index 25bb2b93f..f66754045 100644 --- a/libsolidity/parsing/Parser.h +++ b/libsolidity/parsing/Parser.h @@ -175,6 +175,8 @@ private: bool empty() const; }; + std::optional findLicenseString(std::vector> const& _nodes); + /// Returns the next AST node ID int64_t nextID() { return ++m_currentNodeID; } diff --git a/test/libsolidity/ABIJsonTest.cpp b/test/libsolidity/ABIJsonTest.cpp index d144e2ee7..a46c1d470 100644 --- a/test/libsolidity/ABIJsonTest.cpp +++ b/test/libsolidity/ABIJsonTest.cpp @@ -45,7 +45,10 @@ TestCase::TestResult ABIJsonTest::run(ostream& _stream, string const& _linePrefi { CompilerStack compiler; - compiler.setSources({{"", "pragma solidity >=0.0;\n" + m_source}}); + compiler.setSources({{ + "", + "pragma solidity >=0.0;\n// SPDX-License-Identifier: GPL-3.0\n" + m_source + }}); compiler.setEVMVersion(solidity::test::CommonOptions::get().evmVersion()); compiler.setOptimiserSettings(solidity::test::CommonOptions::get().optimize); if (!compiler.parseAndAnalyze()) diff --git a/test/libsolidity/AnalysisFramework.cpp b/test/libsolidity/AnalysisFramework.cpp index be14d1cf1..80c20c760 100644 --- a/test/libsolidity/AnalysisFramework.cpp +++ b/test/libsolidity/AnalysisFramework.cpp @@ -44,13 +44,17 @@ pair AnalysisFramework::parseAnalyseAndReturnError( string const& _source, bool _reportWarnings, - bool _insertVersionPragma, + bool _insertLicenseAndVersionPragma, bool _allowMultipleErrors, bool _allowRecoveryErrors ) { compiler().reset(); - compiler().setSources({{"", _insertVersionPragma ? "pragma solidity >=0.0;\n" + _source : _source}}); + compiler().setSources({{"", + _insertLicenseAndVersionPragma ? + "pragma solidity >=0.0;\n// SPDX-License-Identifier: GPL-3.0\n" + _source : + _source + }}); compiler().setEVMVersion(solidity::test::CommonOptions::get().evmVersion()); compiler().setParserErrorRecovery(_allowRecoveryErrors); _allowMultipleErrors = _allowMultipleErrors || _allowRecoveryErrors; diff --git a/test/libsolidity/AnalysisFramework.h b/test/libsolidity/AnalysisFramework.h index 26ca9e916..db75ad301 100644 --- a/test/libsolidity/AnalysisFramework.h +++ b/test/libsolidity/AnalysisFramework.h @@ -47,7 +47,7 @@ protected: parseAnalyseAndReturnError( std::string const& _source, bool _reportWarnings = false, - bool _insertVersionPragma = true, + bool _insertLicenseAndVersionPragma = true, bool _allowMultipleErrors = false, bool _allowRecoveryErrors = false ); diff --git a/test/libsolidity/GasMeter.cpp b/test/libsolidity/GasMeter.cpp index 79394855a..09e257664 100644 --- a/test/libsolidity/GasMeter.cpp +++ b/test/libsolidity/GasMeter.cpp @@ -43,7 +43,8 @@ public: void compile(string const& _sourceCode) { m_compiler.reset(); - m_compiler.setSources({{"", "pragma solidity >=0.0;\n" + _sourceCode}}); + m_compiler.setSources({{"", "pragma solidity >=0.0;\n" + "// SPDX-License-Identifier: GPL-3.0\n" + _sourceCode}}); m_compiler.setOptimiserSettings(solidity::test::CommonOptions::get().optimize); m_compiler.setEVMVersion(m_evmVersion); BOOST_REQUIRE_MESSAGE(m_compiler.compile(), "Compiling contract failed"); diff --git a/test/libsolidity/GasTest.cpp b/test/libsolidity/GasTest.cpp index 694839b99..893a20715 100644 --- a/test/libsolidity/GasTest.cpp +++ b/test/libsolidity/GasTest.cpp @@ -100,7 +100,7 @@ void GasTest::printUpdatedExpectations(ostream& _stream, string const& _linePref TestCase::TestResult GasTest::run(ostream& _stream, string const& _linePrefix, bool _formatted) { - string const versionPragma = "pragma solidity >=0.0;\n"; + string const preamble = "pragma solidity >=0.0;\n// SPDX-License-Identifier: GPL-3.0\n"; compiler().reset(); // Prerelease CBOR metadata varies in size due to changing version numbers and build dates. // This leads to volatile creation cost estimates. Therefore we force the compiler to @@ -114,7 +114,7 @@ TestCase::TestResult GasTest::run(ostream& _stream, string const& _linePrefix, b } settings.expectedExecutionsPerDeployment = m_optimiseRuns; compiler().setOptimiserSettings(settings); - compiler().setSources({{"", versionPragma + m_source}}); + compiler().setSources({{"", preamble + m_source}}); if (!compiler().parseAndAnalyze() || !compiler().compile()) { diff --git a/test/libsolidity/SMTChecker.cpp b/test/libsolidity/SMTChecker.cpp index 6df19c1c7..66398381e 100644 --- a/test/libsolidity/SMTChecker.cpp +++ b/test/libsolidity/SMTChecker.cpp @@ -38,7 +38,7 @@ protected: parseAnalyseAndReturnError( std::string const& _source, bool _reportWarnings = false, - bool _insertVersionPragma = true, + bool _insertLicenseAndVersionPragma = true, bool _allowMultipleErrors = false, bool _allowRecoveryErrors = false ) override @@ -46,7 +46,7 @@ protected: return AnalysisFramework::parseAnalyseAndReturnError( "pragma experimental SMTChecker;\n" + _source, _reportWarnings, - _insertVersionPragma, + _insertLicenseAndVersionPragma, _allowMultipleErrors, _allowRecoveryErrors ); diff --git a/test/libsolidity/SMTCheckerJSONTest.cpp b/test/libsolidity/SMTCheckerJSONTest.cpp index a1c23662a..484db13ff 100644 --- a/test/libsolidity/SMTCheckerJSONTest.cpp +++ b/test/libsolidity/SMTCheckerJSONTest.cpp @@ -64,8 +64,8 @@ TestCase::TestResult SMTCheckerJSONTest::run(ostream& _stream, string const& _li StandardCompiler compiler; // Run the compiler and retrieve the smtlib2queries (1st run) - string versionPragma = "pragma solidity >=0.0;\n"; - Json::Value input = buildJson(versionPragma); + string preamble = "pragma solidity >=0.0;\n// SPDX-License-Identifier: GPL-3.0\n"; + Json::Value input = buildJson(preamble); Json::Value result = compiler.compile(input); // This is the list of query hashes requested by the 1st run @@ -121,10 +121,10 @@ TestCase::TestResult SMTCheckerJSONTest::run(ostream& _stream, string const& _li std::string sourceName; if (location.isMember("source") && location["source"].isString()) sourceName = location["source"].asString(); - if (start >= static_cast(versionPragma.size())) - start -= versionPragma.size(); - if (end >= static_cast(versionPragma.size())) - end -= versionPragma.size(); + if (start >= static_cast(preamble.size())) + start -= preamble.size(); + if (end >= static_cast(preamble.size())) + end -= preamble.size(); m_errorList.emplace_back(SyntaxTestError{ error["type"].asString(), error["message"].asString(), diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 26d9ca989..b97d7bd4d 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -370,6 +370,7 @@ BOOST_AUTO_TEST_CASE(dynamic_return_types_not_possible) BOOST_AUTO_TEST_CASE(warn_nonpresent_pragma) { char const* text = R"( + // SPDX-License-Identifier: GPL-3.0 contract C {} )"; auto sourceAndError = parseAnalyseAndReturnError(text, true, false); diff --git a/test/libsolidity/SolidityTypes.cpp b/test/libsolidity/SolidityTypes.cpp index b21c8f2e1..bc9f16904 100644 --- a/test/libsolidity/SolidityTypes.cpp +++ b/test/libsolidity/SolidityTypes.cpp @@ -209,7 +209,7 @@ BOOST_AUTO_TEST_CASE(type_identifiers) ModifierDefinition mod(++id, SourceLocation{}, make_shared("modif"), {}, emptyParams, {}, {}, {}); BOOST_CHECK_EQUAL(ModifierType(mod).identifier(), "t_modifier$__$"); - SourceUnit su(++id, {}, {}); + SourceUnit su(++id, {}, {}, {}); BOOST_CHECK_EQUAL(ModuleType(su).identifier(), "t_module_7"); BOOST_CHECK_EQUAL(MagicType(MagicType::Kind::Block).identifier(), "t_magic_block"); BOOST_CHECK_EQUAL(MagicType(MagicType::Kind::Message).identifier(), "t_magic_message"); diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp index ce9a29268..288bba3fe 100644 --- a/test/libsolidity/StandardCompiler.cpp +++ b/test/libsolidity/StandardCompiler.cpp @@ -427,7 +427,7 @@ BOOST_AUTO_TEST_CASE(basic_compilation) BOOST_CHECK(result["sources"]["fileA"]["legacyAST"].isObject()); BOOST_CHECK_EQUAL( util::jsonCompactPrint(result["sources"]["fileA"]["legacyAST"]), - "{\"attributes\":{\"absolutePath\":\"fileA\",\"exportedSymbols\":{\"A\":[1]}},\"children\":" + "{\"attributes\":{\"absolutePath\":\"fileA\",\"exportedSymbols\":{\"A\":[1]},\"license\":null},\"children\":" "[{\"attributes\":{\"abstract\":false,\"baseContracts\":[null],\"contractDependencies\":[null],\"contractKind\":\"contract\"," "\"documentation\":null,\"fullyImplemented\":true,\"linearizedBaseContracts\":[1],\"name\":\"A\",\"nodes\":[null],\"scope\":2}," "\"id\":1,\"name\":\"ContractDefinition\",\"src\":\"0:14:0\"}],\"id\":2,\"name\":\"SourceUnit\",\"src\":\"0:14:0\"}" diff --git a/test/libsolidity/SyntaxTest.cpp b/test/libsolidity/SyntaxTest.cpp index 3ec506998..55a77ed30 100644 --- a/test/libsolidity/SyntaxTest.cpp +++ b/test/libsolidity/SyntaxTest.cpp @@ -52,11 +52,11 @@ TestCase::TestResult SyntaxTest::run(ostream& _stream, string const& _linePrefix void SyntaxTest::setupCompiler() { - string const versionPragma = "pragma solidity >=0.0;\n"; + string const preamble = "pragma solidity >=0.0;\n// SPDX-License-Identifier: GPL-3.0\n"; compiler().reset(); auto sourcesWithPragma = m_sources; for (auto& source: sourcesWithPragma) - source.second = versionPragma + source.second; + source.second = preamble + source.second; compiler().setSources(sourcesWithPragma); compiler().setEVMVersion(m_evmVersion); compiler().setParserErrorRecovery(m_parserErrorRecovery); @@ -89,18 +89,18 @@ void SyntaxTest::parseAndAnalyze() void SyntaxTest::filterObtainedErrors() { - string const versionPragma = "pragma solidity >=0.0;\n"; + string const preamble = "pragma solidity >=0.0;\n// SPDX-License-Identifier: GPL-3.0\n"; for (auto const& currentError: filterErrors(compiler().errors(), true)) { int locationStart = -1, locationEnd = -1; string sourceName; if (auto location = boost::get_error_info(*currentError)) { - // ignore the version pragma inserted by the testing tool when calculating locations. - if (location->start >= static_cast(versionPragma.size())) - locationStart = location->start - versionPragma.size(); - if (location->end >= static_cast(versionPragma.size())) - locationEnd = location->end - versionPragma.size(); + // ignore the version & license pragma inserted by the testing tool when calculating locations. + if (location->start >= static_cast(preamble.size())) + locationStart = location->start - (preamble.size()); + if (location->end >= static_cast(preamble.size())) + locationEnd = location->end - (preamble.size()); if (location->source) sourceName = location->source->name(); } From 52b9a92ff803f4b7cfcfee7d6e8559775e68c6c0 Mon Sep 17 00:00:00 2001 From: Alexander Arlt Date: Tue, 12 May 2020 20:52:11 -0500 Subject: [PATCH 06/15] Update existing tests. --- .../abiencoderv2_no_warning/input.sol | 2 + .../input.sol | 1 + test/cmdlineTests/ir_compiler_subobjects/err | 4 +- .../ir_compiler_subobjects/input.sol | 1 + test/cmdlineTests/message_format/input.sol | 2 +- .../cmdlineTests/optimizer_user_yul/input.sol | 1 + test/cmdlineTests/optimizer_user_yul/output | 50 +++++++++---------- .../output_selection_all_A1/input.json | 4 +- .../output_selection_all_A1/output.json | 4 +- .../output_selection_all_A2/input.json | 4 +- .../output_selection_all_A2/output.json | 4 +- .../output_selection_all_blank/input.json | 4 +- .../output_selection_all_blank/output.json | 4 +- .../output_selection_all_star/input.json | 4 +- .../output_selection_all_star/output.json | 4 +- .../output_selection_single_A1/input.json | 4 +- .../output_selection_single_B1/input.json | 4 +- .../output_selection_single_B1/output.json | 4 +- .../output_selection_single_all/input.json | 4 +- .../cmdlineTests/recovery_ast_constructor/err | 8 +-- .../recovery_ast_constructor/input.sol | 1 + .../recovery_ast_constructor/output | 33 ++++++------ .../recovery_ast_empty_contract/err | 4 +- .../recovery_ast_empty_contract/input.sol | 1 + .../recovery_standard_json/input.json | 2 +- .../recovery_standard_json/output.json | 6 +-- test/cmdlineTests/require_overload/err | 4 +- test/cmdlineTests/require_overload/input.sol | 1 + .../standard_default_success/input.json | 2 +- .../standard_eWasm_requested/input.json | 2 +- .../standard_empty_file_name/input.json | 2 +- .../standard_empty_file_name/output.json | 2 +- .../standard_immutable_references/input.json | 2 +- .../standard_immutable_references/output.json | 2 +- .../standard_irOptimized_requested/input.json | 2 +- .../standard_ir_requested/input.json | 2 +- .../input.json | 2 +- .../input.json | 2 +- .../standard_only_ast_requested/input.json | 2 +- .../standard_only_ast_requested/output.json | 2 +- .../input.json | 2 +- .../input.json | 2 +- .../standard_optimizer_no_yul/input.json | 2 +- .../standard_optimizer_yul/input.json | 2 +- .../standard_optimizer_yulDetails/input.json | 2 +- .../input.json | 2 +- .../input.json | 2 +- .../input.json | 2 +- .../input.json | 2 +- .../input.json | 2 +- .../input.json | 2 +- .../input.json | 2 +- .../input.json | 2 +- .../output.json | 8 +-- .../input.json | 2 +- .../standard_wrong_key_metadata/input.json | 2 +- .../standard_wrong_key_optimizer/input.json | 2 +- .../standard_wrong_key_root/input.json | 2 +- .../standard_wrong_key_settings/input.json | 2 +- .../standard_wrong_key_source/input.json | 2 +- .../input.json | 2 +- .../input.json | 2 +- .../input.json | 2 +- .../standard_wrong_type_metadata/input.json | 2 +- .../standard_wrong_type_optimizer/input.json | 2 +- .../input.json | 2 +- .../input.json | 2 +- .../input.json | 2 +- .../input.json | 2 +- .../standard_wrong_type_remappings/input.json | 2 +- .../input.json | 2 +- .../standard_wrong_type_settings/input.json | 2 +- .../standard_wrong_type_source/input.json | 2 +- .../input.json | 2 +- .../storage_layout_bytes/input.json | 2 +- .../storage_layout_dyn_array/input.json | 2 +- .../storage_layout_many/input.json | 2 +- .../storage_layout_mapping/input.json | 2 +- .../storage_layout_smoke/input.json | 2 +- .../input.json | 4 +- .../storage_layout_string/input.json | 2 +- .../storage_layout_struct/input.json | 2 +- .../storage_layout_struct_packed/input.json | 2 +- .../storage_layout_value_types/input.json | 2 +- .../input.json | 2 +- .../err | 8 +-- .../input.sol | 1 + test/cmdlineTests/too_long_line/err | 3 ++ .../too_long_line_both_sides_short/err | 3 ++ test/cmdlineTests/too_long_line_edge_in/err | 3 ++ test/cmdlineTests/too_long_line_edge_out/err | 3 ++ .../cmdlineTests/too_long_line_left_short/err | 3 ++ test/cmdlineTests/too_long_line_multiline/err | 3 ++ .../too_long_line_right_short/err | 3 ++ .../yul_optimizer_steps/input.sol | 1 + .../yul_optimizer_steps_disabled/input.sol | 1 + .../input.sol | 1 + .../input.sol | 1 + .../input.sol | 1 + .../yul_string_format_ascii/input.json | 2 +- .../input.json | 2 +- .../input.json | 2 +- .../yul_string_format_ascii_long/input.json | 2 +- .../yul_string_format_hex/input.json | 2 +- .../ASTJSON/abstract_contract.json | 1 + .../ASTJSON/abstract_contract_legacy.json | 3 +- test/libsolidity/ASTJSON/address_payable.json | 1 + .../ASTJSON/address_payable_legacy.json | 3 +- test/libsolidity/ASTJSON/array_type_name.json | 1 + .../ASTJSON/array_type_name_legacy.json | 3 +- test/libsolidity/ASTJSON/assembly/call.json | 1 + .../ASTJSON/assembly/call_legacy.json | 3 +- .../ASTJSON/assembly/empty_block.json | 1 + .../ASTJSON/assembly/empty_block_legacy.json | 3 +- .../ASTJSON/assembly/function.json | 1 + .../ASTJSON/assembly/function_legacy.json | 3 +- test/libsolidity/ASTJSON/assembly/leave.json | 1 + .../ASTJSON/assembly/leave_legacy.json | 3 +- test/libsolidity/ASTJSON/assembly/loop.json | 1 + .../ASTJSON/assembly/loop_legacy.json | 3 +- .../ASTJSON/assembly/nested_functions.json | 1 + .../assembly/nested_functions_legacy.json | 3 +- .../ASTJSON/assembly/slot_offset.json | 1 + .../ASTJSON/assembly/slot_offset_legacy.json | 3 +- .../ASTJSON/assembly/stringlit.json | 1 + .../ASTJSON/assembly/stringlit_legacy.json | 3 +- test/libsolidity/ASTJSON/assembly/switch.json | 1 + .../ASTJSON/assembly/switch_default.json | 1 + .../assembly/switch_default_legacy.json | 3 +- .../ASTJSON/assembly/switch_legacy.json | 3 +- .../ASTJSON/assembly/var_access.json | 1 + .../ASTJSON/assembly/var_access_legacy.json | 3 +- test/libsolidity/ASTJSON/constructor.json | 1 + .../ASTJSON/constructor_legacy.json | 3 +- .../ASTJSON/contract_dep_order.json | 1 + .../ASTJSON/contract_dep_order_legacy.json | 3 +- test/libsolidity/ASTJSON/documentation.json | 3 ++ .../ASTJSON/documentation_legacy.json | 3 +- test/libsolidity/ASTJSON/enum_value.json | 1 + .../ASTJSON/enum_value_legacy.json | 3 +- .../libsolidity/ASTJSON/event_definition.json | 1 + .../ASTJSON/event_definition_legacy.json | 3 +- test/libsolidity/ASTJSON/fallback.json | 1 + .../ASTJSON/fallback_and_reveice_ether.json | 1 + .../fallback_and_reveice_ether_legacy.json | 3 +- test/libsolidity/ASTJSON/fallback_legacy.json | 3 +- .../libsolidity/ASTJSON/fallback_payable.json | 1 + .../ASTJSON/fallback_payable_legacy.json | 3 +- test/libsolidity/ASTJSON/function_type.json | 1 + .../ASTJSON/function_type_legacy.json | 3 +- test/libsolidity/ASTJSON/global_enum.json | 1 + .../ASTJSON/global_enum_legacy.json | 3 +- test/libsolidity/ASTJSON/global_struct.json | 1 + .../ASTJSON/global_struct_legacy.json | 3 +- .../ASTJSON/inheritance_specifier.json | 1 + .../ASTJSON/inheritance_specifier_legacy.json | 3 +- .../long_type_name_binary_operation.json | 1 + ...ong_type_name_binary_operation_legacy.json | 3 +- .../ASTJSON/long_type_name_identifier.json | 1 + .../long_type_name_identifier_legacy.json | 3 +- test/libsolidity/ASTJSON/mappings.json | 1 + test/libsolidity/ASTJSON/mappings_legacy.json | 3 +- .../ASTJSON/modifier_definition.json | 1 + .../ASTJSON/modifier_definition_legacy.json | 3 +- .../ASTJSON/modifier_invocation.json | 1 + .../ASTJSON/modifier_invocation_legacy.json | 3 +- test/libsolidity/ASTJSON/mutability.json | 1 + .../ASTJSON/mutability_legacy.json | 3 +- test/libsolidity/ASTJSON/non_utf8.json | 1 + test/libsolidity/ASTJSON/non_utf8_legacy.json | 3 +- test/libsolidity/ASTJSON/override.json | 1 + test/libsolidity/ASTJSON/override_legacy.json | 3 +- .../ASTJSON/placeholder_statement.json | 1 + .../ASTJSON/placeholder_statement_legacy.json | 3 +- test/libsolidity/ASTJSON/receive_ether.json | 1 + .../ASTJSON/receive_ether_legacy.json | 3 +- test/libsolidity/ASTJSON/short_type_name.json | 1 + .../ASTJSON/short_type_name_legacy.json | 3 +- .../ASTJSON/short_type_name_ref.json | 1 + .../ASTJSON/short_type_name_ref_legacy.json | 3 +- test/libsolidity/ASTJSON/smoke.json | 1 + test/libsolidity/ASTJSON/smoke_legacy.json | 3 +- test/libsolidity/ASTJSON/source_location.json | 1 + .../ASTJSON/source_location_legacy.json | 3 +- .../ASTJSON/two_base_functions.json | 1 + .../ASTJSON/two_base_functions_legacy.json | 3 +- .../ASTJSON/using_for_directive.json | 1 + .../ASTJSON/using_for_directive_legacy.json | 3 +- 188 files changed, 314 insertions(+), 192 deletions(-) diff --git a/test/cmdlineTests/abiencoderv2_no_warning/input.sol b/test/cmdlineTests/abiencoderv2_no_warning/input.sol index fef512e55..c2eb120f8 100644 --- a/test/cmdlineTests/abiencoderv2_no_warning/input.sol +++ b/test/cmdlineTests/abiencoderv2_no_warning/input.sol @@ -1,5 +1,7 @@ +// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.0; pragma experimental ABIEncoderV2; + contract C { struct S { uint x; } function f(S memory) public pure { diff --git a/test/cmdlineTests/ir_compiler_inheritance_nosubobjects/input.sol b/test/cmdlineTests/ir_compiler_inheritance_nosubobjects/input.sol index 69f553304..160c4cd1d 100644 --- a/test/cmdlineTests/ir_compiler_inheritance_nosubobjects/input.sol +++ b/test/cmdlineTests/ir_compiler_inheritance_nosubobjects/input.sol @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0; contract C { diff --git a/test/cmdlineTests/ir_compiler_subobjects/err b/test/cmdlineTests/ir_compiler_subobjects/err index a28ad1966..d4394af57 100644 --- a/test/cmdlineTests/ir_compiler_subobjects/err +++ b/test/cmdlineTests/ir_compiler_subobjects/err @@ -1,5 +1,5 @@ Warning: Unused local variable. - --> ir_compiler_subobjects/input.sol:6:9: + --> ir_compiler_subobjects/input.sol:7:9: | -6 | C c = new C(); +7 | C c = new C(); | ^^^ diff --git a/test/cmdlineTests/ir_compiler_subobjects/input.sol b/test/cmdlineTests/ir_compiler_subobjects/input.sol index e0fdbbc13..13f9f3c60 100644 --- a/test/cmdlineTests/ir_compiler_subobjects/input.sol +++ b/test/cmdlineTests/ir_compiler_subobjects/input.sol @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0; contract C {} diff --git a/test/cmdlineTests/message_format/input.sol b/test/cmdlineTests/message_format/input.sol index 6f854f96a..cbb51c9d6 100644 --- a/test/cmdlineTests/message_format/input.sol +++ b/test/cmdlineTests/message_format/input.sol @@ -1,5 +1,5 @@ // checks that error messages around power-or-10 lines are formatted correctly - +// SPDX-License-Identifier: GPL-3.0 diff --git a/test/cmdlineTests/optimizer_user_yul/input.sol b/test/cmdlineTests/optimizer_user_yul/input.sol index 74dc84cbd..e61b132e4 100644 --- a/test/cmdlineTests/optimizer_user_yul/input.sol +++ b/test/cmdlineTests/optimizer_user_yul/input.sol @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.0; contract C diff --git a/test/cmdlineTests/optimizer_user_yul/output b/test/cmdlineTests/optimizer_user_yul/output index 8eef7b4f6..a160c37c4 100644 --- a/test/cmdlineTests/optimizer_user_yul/output +++ b/test/cmdlineTests/optimizer_user_yul/output @@ -1,69 +1,69 @@ ======= optimizer_user_yul/input.sol:C ======= EVM assembly: - /* "optimizer_user_yul/input.sol":24:489 contract C... */ + /* "optimizer_user_yul/input.sol":60:525 contract C... */ mstore(0x40, 0x80) - /* "optimizer_user_yul/input.sol":72:77 int a */ + /* "optimizer_user_yul/input.sol":108:113 int a */ 0x00 - /* "optimizer_user_yul/input.sol":152:161 let x,y,z */ + /* "optimizer_user_yul/input.sol":188:197 let x,y,z */ dup1 0x00 dup1 - /* "optimizer_user_yul/input.sol":176:177 1 */ + /* "optimizer_user_yul/input.sol":212:213 1 */ 0x01 - /* "optimizer_user_yul/input.sol":173:174 0 */ + /* "optimizer_user_yul/input.sol":209:210 0 */ 0x00 - /* "optimizer_user_yul/input.sol":166:178 sstore(0, 1) */ + /* "optimizer_user_yul/input.sol":202:214 sstore(0, 1) */ sstore - /* "optimizer_user_yul/input.sol":183:229 for { } sload(4) { } {... */ + /* "optimizer_user_yul/input.sol":219:265 for { } sload(4) { } {... */ tag_3: - /* "optimizer_user_yul/input.sol":197:198 4 */ + /* "optimizer_user_yul/input.sol":233:234 4 */ 0x04 - /* "optimizer_user_yul/input.sol":191:199 sload(4) */ + /* "optimizer_user_yul/input.sol":227:235 sload(4) */ sload - /* "optimizer_user_yul/input.sol":183:229 for { } sload(4) { } {... */ + /* "optimizer_user_yul/input.sol":219:265 for { } sload(4) { } {... */ iszero tag_5 jumpi pop - /* "optimizer_user_yul/input.sol":215:224 exp(x, y) */ + /* "optimizer_user_yul/input.sol":251:260 exp(x, y) */ dup1 dup3 exp - /* "optimizer_user_yul/input.sol":183:229 for { } sload(4) { } {... */ + /* "optimizer_user_yul/input.sol":219:265 for { } sload(4) { } {... */ jump(tag_3) tag_5: - /* "optimizer_user_yul/input.sol":187:190 { } */ + /* "optimizer_user_yul/input.sol":223:226 { } */ pop pop pop - /* "optimizer_user_yul/input.sol":239:240 2 */ + /* "optimizer_user_yul/input.sol":275:276 2 */ 0x02 - /* "optimizer_user_yul/input.sol":234:240 a := 2 */ + /* "optimizer_user_yul/input.sol":270:276 a := 2 */ swap1 pop - /* "optimizer_user_yul/input.sol":340:341 3 */ + /* "optimizer_user_yul/input.sol":376:377 3 */ 0x03 - /* "optimizer_user_yul/input.sol":337:338 2 */ + /* "optimizer_user_yul/input.sol":373:374 2 */ 0x02 - /* "optimizer_user_yul/input.sol":330:342 sstore(2, 3) */ + /* "optimizer_user_yul/input.sol":366:378 sstore(2, 3) */ sstore - /* "optimizer_user_yul/input.sol":347:480 for { } sload(5) { } {... */ + /* "optimizer_user_yul/input.sol":383:516 for { } sload(5) { } {... */ tag_6: - /* "optimizer_user_yul/input.sol":361:362 5 */ + /* "optimizer_user_yul/input.sol":397:398 5 */ 0x05 - /* "optimizer_user_yul/input.sol":355:363 sload(5) */ + /* "optimizer_user_yul/input.sol":391:399 sload(5) */ sload tag_9 jumpi jump(tag_8) tag_9: - /* "optimizer_user_yul/input.sol":347:480 for { } sload(5) { } {... */ + /* "optimizer_user_yul/input.sol":383:516 for { } sload(5) { } {... */ jump(tag_6) tag_8: - /* "optimizer_user_yul/input.sol":311:484 {... */ + /* "optimizer_user_yul/input.sol":347:520 {... */ pop - /* "optimizer_user_yul/input.sol":24:489 contract C... */ + /* "optimizer_user_yul/input.sol":60:525 contract C... */ dataSize(sub_0) dup1 dataOffset(sub_0) @@ -74,7 +74,7 @@ tag_8: stop sub_0: assembly { - /* "optimizer_user_yul/input.sol":24:489 contract C... */ + /* "optimizer_user_yul/input.sol":60:525 contract C... */ mstore(0x40, 0x80) /* "--CODEGEN--":12:13 */ 0x00 diff --git a/test/cmdlineTests/output_selection_all_A1/input.json b/test/cmdlineTests/output_selection_all_A1/input.json index 339077d0b..a7a84163d 100644 --- a/test/cmdlineTests/output_selection_all_A1/input.json +++ b/test/cmdlineTests/output_selection_all_A1/input.json @@ -2,10 +2,10 @@ "language": "Solidity", "sources": { "a.sol": { - "content": "contract A1 { function a(uint x) public pure { assert(x > 0); } } contract A2 { function a(uint x) public pure { assert(x > 0); } }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A1 { function a(uint x) public pure { assert(x > 0); } } contract A2 { function a(uint x) public pure { assert(x > 0); } }" }, "b.sol": { - "content": "contract A1 { function b(uint x) public { assert(x > 0); } } contract B2 { function b(uint x) public pure { assert(x > 0); } }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A1 { function b(uint x) public { assert(x > 0); } } contract B2 { function b(uint x) public pure { assert(x > 0); } }" } }, "settings": { diff --git a/test/cmdlineTests/output_selection_all_A1/output.json b/test/cmdlineTests/output_selection_all_A1/output.json index e87df2995..074b2062b 100644 --- a/test/cmdlineTests/output_selection_all_A1/output.json +++ b/test/cmdlineTests/output_selection_all_A1/output.json @@ -1,6 +1,6 @@ {"contracts":{"a.sol":{"A1":{"evm":{"bytecode":{"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}}},"b.sol":{"A1":{"evm":{"bytecode":{"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}}}},"errors":[{"component":"general","formattedMessage":"a.sol: Warning: Source file does not specify required compiler version! ","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":-1,"file":"a.sol","start":-1},"type":"Warning"},{"component":"general","formattedMessage":"b.sol: Warning: Source file does not specify required compiler version! -","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":-1,"file":"b.sol","start":-1},"type":"Warning"},{"component":"general","formattedMessage":"b.sol:1:15: Warning: Function state mutability can be restricted to pure +","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":-1,"file":"b.sol","start":-1},"type":"Warning"},{"component":"general","formattedMessage":"b.sol:2:15: Warning: Function state mutability can be restricted to pure contract A1 { function b(uint x) public { assert(x > 0); } } contract B2 { function b(uint x) public pure { assert(x > 0); } } ^------------------------------------------^ -","message":"Function state mutability can be restricted to pure","severity":"warning","sourceLocation":{"end":58,"file":"b.sol","start":14},"type":"Warning"}],"sources":{"a.sol":{"id":0},"b.sol":{"id":1}}} +","message":"Function state mutability can be restricted to pure","severity":"warning","sourceLocation":{"end":93,"file":"b.sol","start":49},"type":"Warning"}],"sources":{"a.sol":{"id":0},"b.sol":{"id":1}}} diff --git a/test/cmdlineTests/output_selection_all_A2/input.json b/test/cmdlineTests/output_selection_all_A2/input.json index 4a29266ad..3107a5e4c 100644 --- a/test/cmdlineTests/output_selection_all_A2/input.json +++ b/test/cmdlineTests/output_selection_all_A2/input.json @@ -2,10 +2,10 @@ "language": "Solidity", "sources": { "a.sol": { - "content": "contract A1 { function a(uint x) public pure { assert(x > 0); } } contract A2 { function a(uint x) public pure { assert(x > 0); } }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A1 { function a(uint x) public pure { assert(x > 0); } } contract A2 { function a(uint x) public pure { assert(x > 0); } }" }, "b.sol": { - "content": "contract A1 { function b(uint x) public { assert(x > 0); } } contract B2 { function b(uint x) public pure { assert(x > 0); } }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A1 { function b(uint x) public { assert(x > 0); } } contract B2 { function b(uint x) public pure { assert(x > 0); } }" } }, "settings": { diff --git a/test/cmdlineTests/output_selection_all_A2/output.json b/test/cmdlineTests/output_selection_all_A2/output.json index 7601952b6..aa2ca9d0e 100644 --- a/test/cmdlineTests/output_selection_all_A2/output.json +++ b/test/cmdlineTests/output_selection_all_A2/output.json @@ -1,6 +1,6 @@ {"contracts":{"a.sol":{"A2":{"evm":{"bytecode":{"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}}}},"errors":[{"component":"general","formattedMessage":"a.sol: Warning: Source file does not specify required compiler version! ","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":-1,"file":"a.sol","start":-1},"type":"Warning"},{"component":"general","formattedMessage":"b.sol: Warning: Source file does not specify required compiler version! -","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":-1,"file":"b.sol","start":-1},"type":"Warning"},{"component":"general","formattedMessage":"b.sol:1:15: Warning: Function state mutability can be restricted to pure +","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":-1,"file":"b.sol","start":-1},"type":"Warning"},{"component":"general","formattedMessage":"b.sol:2:15: Warning: Function state mutability can be restricted to pure contract A1 { function b(uint x) public { assert(x > 0); } } contract B2 { function b(uint x) public pure { assert(x > 0); } } ^------------------------------------------^ -","message":"Function state mutability can be restricted to pure","severity":"warning","sourceLocation":{"end":58,"file":"b.sol","start":14},"type":"Warning"}],"sources":{"a.sol":{"id":0},"b.sol":{"id":1}}} +","message":"Function state mutability can be restricted to pure","severity":"warning","sourceLocation":{"end":93,"file":"b.sol","start":49},"type":"Warning"}],"sources":{"a.sol":{"id":0},"b.sol":{"id":1}}} diff --git a/test/cmdlineTests/output_selection_all_blank/input.json b/test/cmdlineTests/output_selection_all_blank/input.json index 08c2946c6..85bc114b3 100644 --- a/test/cmdlineTests/output_selection_all_blank/input.json +++ b/test/cmdlineTests/output_selection_all_blank/input.json @@ -2,10 +2,10 @@ "language": "Solidity", "sources": { "a.sol": { - "content": "contract A1 { function a(uint x) public pure { assert(x > 0); } } contract A2 { function a(uint x) public pure { assert(x > 0); } }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A1 { function a(uint x) public pure { assert(x > 0); } } contract A2 { function a(uint x) public pure { assert(x > 0); } }" }, "b.sol": { - "content": "contract A1 { function b(uint x) public { assert(x > 0); } } contract B2 { function b(uint x) public pure { assert(x > 0); } }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A1 { function b(uint x) public { assert(x > 0); } } contract B2 { function b(uint x) public pure { assert(x > 0); } }" } }, "settings": { diff --git a/test/cmdlineTests/output_selection_all_blank/output.json b/test/cmdlineTests/output_selection_all_blank/output.json index 81c98e790..e0872ca8c 100644 --- a/test/cmdlineTests/output_selection_all_blank/output.json +++ b/test/cmdlineTests/output_selection_all_blank/output.json @@ -1,6 +1,6 @@ {"errors":[{"component":"general","formattedMessage":"a.sol: Warning: Source file does not specify required compiler version! ","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":-1,"file":"a.sol","start":-1},"type":"Warning"},{"component":"general","formattedMessage":"b.sol: Warning: Source file does not specify required compiler version! -","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":-1,"file":"b.sol","start":-1},"type":"Warning"},{"component":"general","formattedMessage":"b.sol:1:15: Warning: Function state mutability can be restricted to pure +","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":-1,"file":"b.sol","start":-1},"type":"Warning"},{"component":"general","formattedMessage":"b.sol:2:15: Warning: Function state mutability can be restricted to pure contract A1 { function b(uint x) public { assert(x > 0); } } contract B2 { function b(uint x) public pure { assert(x > 0); } } ^------------------------------------------^ -","message":"Function state mutability can be restricted to pure","severity":"warning","sourceLocation":{"end":58,"file":"b.sol","start":14},"type":"Warning"}],"sources":{"a.sol":{"id":0},"b.sol":{"id":1}}} +","message":"Function state mutability can be restricted to pure","severity":"warning","sourceLocation":{"end":93,"file":"b.sol","start":49},"type":"Warning"}],"sources":{"a.sol":{"id":0},"b.sol":{"id":1}}} diff --git a/test/cmdlineTests/output_selection_all_star/input.json b/test/cmdlineTests/output_selection_all_star/input.json index 5d079abd3..450286311 100644 --- a/test/cmdlineTests/output_selection_all_star/input.json +++ b/test/cmdlineTests/output_selection_all_star/input.json @@ -2,10 +2,10 @@ "language": "Solidity", "sources": { "a.sol": { - "content": "contract A1 { function a(uint x) public pure { assert(x > 0); } } contract A2 { function a(uint x) public pure { assert(x > 0); } }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A1 { function a(uint x) public pure { assert(x > 0); } } contract A2 { function a(uint x) public pure { assert(x > 0); } }" }, "b.sol": { - "content": "contract A1 { function b(uint x) public { assert(x > 0); } } contract B2 { function b(uint x) public pure { assert(x > 0); } }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A1 { function b(uint x) public { assert(x > 0); } } contract B2 { function b(uint x) public pure { assert(x > 0); } }" } }, "settings": { diff --git a/test/cmdlineTests/output_selection_all_star/output.json b/test/cmdlineTests/output_selection_all_star/output.json index 0a8071aaf..8997ed8e2 100644 --- a/test/cmdlineTests/output_selection_all_star/output.json +++ b/test/cmdlineTests/output_selection_all_star/output.json @@ -1,6 +1,6 @@ {"contracts":{"a.sol":{"A1":{"evm":{"bytecode":{"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}},"A2":{"evm":{"bytecode":{"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}}},"b.sol":{"A1":{"evm":{"bytecode":{"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}},"B2":{"evm":{"bytecode":{"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}}}},"errors":[{"component":"general","formattedMessage":"a.sol: Warning: Source file does not specify required compiler version! ","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":-1,"file":"a.sol","start":-1},"type":"Warning"},{"component":"general","formattedMessage":"b.sol: Warning: Source file does not specify required compiler version! -","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":-1,"file":"b.sol","start":-1},"type":"Warning"},{"component":"general","formattedMessage":"b.sol:1:15: Warning: Function state mutability can be restricted to pure +","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":-1,"file":"b.sol","start":-1},"type":"Warning"},{"component":"general","formattedMessage":"b.sol:2:15: Warning: Function state mutability can be restricted to pure contract A1 { function b(uint x) public { assert(x > 0); } } contract B2 { function b(uint x) public pure { assert(x > 0); } } ^------------------------------------------^ -","message":"Function state mutability can be restricted to pure","severity":"warning","sourceLocation":{"end":58,"file":"b.sol","start":14},"type":"Warning"}],"sources":{"a.sol":{"id":0},"b.sol":{"id":1}}} +","message":"Function state mutability can be restricted to pure","severity":"warning","sourceLocation":{"end":93,"file":"b.sol","start":49},"type":"Warning"}],"sources":{"a.sol":{"id":0},"b.sol":{"id":1}}} diff --git a/test/cmdlineTests/output_selection_single_A1/input.json b/test/cmdlineTests/output_selection_single_A1/input.json index 5f11ce6da..2ea69a594 100644 --- a/test/cmdlineTests/output_selection_single_A1/input.json +++ b/test/cmdlineTests/output_selection_single_A1/input.json @@ -2,10 +2,10 @@ "language": "Solidity", "sources": { "a.sol": { - "content": "contract A1 { function a(uint x) public pure { assert(x > 0); } } contract A2 { function a(uint x) public pure { assert(x > 0); } }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A1 { function a(uint x) public pure { assert(x > 0); } } contract A2 { function a(uint x) public pure { assert(x > 0); } }" }, "b.sol": { - "content": "contract A1 { function b(uint x) public { assert(x > 0); } } contract B2 { function b(uint x) public pure { assert(x > 0); } }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A1 { function b(uint x) public { assert(x > 0); } } contract B2 { function b(uint x) public pure { assert(x > 0); } }" } }, "settings": { diff --git a/test/cmdlineTests/output_selection_single_B1/input.json b/test/cmdlineTests/output_selection_single_B1/input.json index 6adcd139e..f25a1b57d 100644 --- a/test/cmdlineTests/output_selection_single_B1/input.json +++ b/test/cmdlineTests/output_selection_single_B1/input.json @@ -2,10 +2,10 @@ "language": "Solidity", "sources": { "a.sol": { - "content": "contract A1 { function a(uint x) public pure { assert(x > 0); } } contract A2 { function a(uint x) public pure { assert(x > 0); } }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A1 { function a(uint x) public pure { assert(x > 0); } } contract A2 { function a(uint x) public pure { assert(x > 0); } }" }, "b.sol": { - "content": "contract A1 { function b(uint x) public { assert(x > 0); } } contract B2 { function b(uint x) public pure { assert(x > 0); } }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A1 { function b(uint x) public { assert(x > 0); } } contract B2 { function b(uint x) public pure { assert(x > 0); } }" } }, "settings": { diff --git a/test/cmdlineTests/output_selection_single_B1/output.json b/test/cmdlineTests/output_selection_single_B1/output.json index fafe87ebd..c9c929b97 100644 --- a/test/cmdlineTests/output_selection_single_B1/output.json +++ b/test/cmdlineTests/output_selection_single_B1/output.json @@ -1,5 +1,5 @@ {"contracts":{"b.sol":{"B2":{"evm":{"bytecode":{"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"sourceMap removed"}}}}},"errors":[{"component":"general","formattedMessage":"b.sol: Warning: Source file does not specify required compiler version! -","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":-1,"file":"b.sol","start":-1},"type":"Warning"},{"component":"general","formattedMessage":"b.sol:1:15: Warning: Function state mutability can be restricted to pure +","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":-1,"file":"b.sol","start":-1},"type":"Warning"},{"component":"general","formattedMessage":"b.sol:2:15: Warning: Function state mutability can be restricted to pure contract A1 { function b(uint x) public { assert(x > 0); } } contract B2 { function b(uint x) public pure { assert(x > 0); } } ^------------------------------------------^ -","message":"Function state mutability can be restricted to pure","severity":"warning","sourceLocation":{"end":58,"file":"b.sol","start":14},"type":"Warning"}],"sources":{"a.sol":{"id":0},"b.sol":{"id":1}}} +","message":"Function state mutability can be restricted to pure","severity":"warning","sourceLocation":{"end":93,"file":"b.sol","start":49},"type":"Warning"}],"sources":{"a.sol":{"id":0},"b.sol":{"id":1}}} diff --git a/test/cmdlineTests/output_selection_single_all/input.json b/test/cmdlineTests/output_selection_single_all/input.json index 1dddfe771..a4137b063 100644 --- a/test/cmdlineTests/output_selection_single_all/input.json +++ b/test/cmdlineTests/output_selection_single_all/input.json @@ -2,10 +2,10 @@ "language": "Solidity", "sources": { "a.sol": { - "content": "contract A1 { function a(uint x) public pure { assert(x > 0); } } contract A2 { function a(uint x) public pure { assert(x > 0); } }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A1 { function a(uint x) public pure { assert(x > 0); } } contract A2 { function a(uint x) public pure { assert(x > 0); } }" }, "b.sol": { - "content": "contract A1 { function b(uint x) public { assert(x > 0); } } contract B2 { function b(uint x) public pure { assert(x > 0); } }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A1 { function b(uint x) public { assert(x > 0); } } contract B2 { function b(uint x) public pure { assert(x > 0); } }" } }, "settings": { diff --git a/test/cmdlineTests/recovery_ast_constructor/err b/test/cmdlineTests/recovery_ast_constructor/err index 81c911386..ecff59f7a 100644 --- a/test/cmdlineTests/recovery_ast_constructor/err +++ b/test/cmdlineTests/recovery_ast_constructor/err @@ -1,13 +1,13 @@ Error: Expected primary expression. - --> recovery_ast_constructor/input.sol:5:27: + --> recovery_ast_constructor/input.sol:6:27: | -5 | balances[tx.origin] = ; // missing RHS. +6 | balances[tx.origin] = ; // missing RHS. | ^ Warning: Recovered in Statement at ';'. - --> recovery_ast_constructor/input.sol:5:27: + --> recovery_ast_constructor/input.sol:6:27: | -5 | balances[tx.origin] = ; // missing RHS. +6 | balances[tx.origin] = ; // missing RHS. | ^ diff --git a/test/cmdlineTests/recovery_ast_constructor/input.sol b/test/cmdlineTests/recovery_ast_constructor/input.sol index a6b55ab7f..9035590d9 100644 --- a/test/cmdlineTests/recovery_ast_constructor/input.sol +++ b/test/cmdlineTests/recovery_ast_constructor/input.sol @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.0.0; contract Error1 { diff --git a/test/cmdlineTests/recovery_ast_constructor/output b/test/cmdlineTests/recovery_ast_constructor/output index f2cc2ccf8..06d7bb95c 100644 --- a/test/cmdlineTests/recovery_ast_constructor/output +++ b/test/cmdlineTests/recovery_ast_constructor/output @@ -12,7 +12,8 @@ JSON AST: [ 18 ] - } + }, + "license": "GPL-3.0" }, "children": [ @@ -29,7 +30,7 @@ JSON AST: }, "id": 1, "name": "PragmaDirective", - "src": "0:24:0" + "src": "36:24:0" }, { "attributes": @@ -86,7 +87,7 @@ JSON AST: "children": [], "id": 2, "name": "ParameterList", - "src": "57:2:0" + "src": "93:2:0" }, { "attributes": @@ -99,7 +100,7 @@ JSON AST: "children": [], "id": 3, "name": "ParameterList", - "src": "67:0:0" + "src": "103:0:0" }, { "attributes": @@ -112,12 +113,12 @@ JSON AST: "children": [], "id": 8, "name": "Block", - "src": "67:49:0" + "src": "103:49:0" } ], "id": 9, "name": "FunctionDefinition", - "src": "46:70:0" + "src": "82:70:0" }, { "attributes": @@ -151,7 +152,7 @@ JSON AST: "children": [], "id": 10, "name": "ParameterList", - "src": "382:2:0" + "src": "418:2:0" }, { "children": @@ -180,17 +181,17 @@ JSON AST: }, "id": 11, "name": "ElementaryTypeName", - "src": "405:4:0" + "src": "441:4:0" } ], "id": 12, "name": "VariableDeclaration", - "src": "405:4:0" + "src": "441:4:0" } ], "id": 13, "name": "ParameterList", - "src": "404:6:0" + "src": "440:6:0" }, { "children": @@ -218,30 +219,30 @@ JSON AST: }, "id": 14, "name": "Literal", - "src": "424:1:0" + "src": "460:1:0" } ], "id": 15, "name": "Return", - "src": "417:8:0" + "src": "453:8:0" } ], "id": 16, "name": "Block", - "src": "411:19:0" + "src": "447:19:0" } ], "id": 17, "name": "FunctionDefinition", - "src": "369:61:0" + "src": "405:61:0" } ], "id": 18, "name": "ContractDefinition", - "src": "26:406:0" + "src": "62:406:0" } ], "id": 19, "name": "SourceUnit", - "src": "0:433:0" + "src": "36:433:0" } diff --git a/test/cmdlineTests/recovery_ast_empty_contract/err b/test/cmdlineTests/recovery_ast_empty_contract/err index 3de346d51..588067877 100644 --- a/test/cmdlineTests/recovery_ast_empty_contract/err +++ b/test/cmdlineTests/recovery_ast_empty_contract/err @@ -1,7 +1,7 @@ Error: Expected pragma, import directive or contract/interface/library/struct/enum definition. - --> recovery_ast_empty_contract/input.sol:2:1: + --> recovery_ast_empty_contract/input.sol:3:1: | -2 | c +3 | c | ^ diff --git a/test/cmdlineTests/recovery_ast_empty_contract/input.sol b/test/cmdlineTests/recovery_ast_empty_contract/input.sol index c54a818bf..bdc83a2c9 100644 --- a/test/cmdlineTests/recovery_ast_empty_contract/input.sol +++ b/test/cmdlineTests/recovery_ast_empty_contract/input.sol @@ -1,2 +1,3 @@ +// SPDX-License-Identifier: GPL-3.0 pragma 0.5.11; c \ No newline at end of file diff --git a/test/cmdlineTests/recovery_standard_json/input.json b/test/cmdlineTests/recovery_standard_json/input.json index bc0d019d2..9c8b15066 100644 --- a/test/cmdlineTests/recovery_standard_json/input.json +++ b/test/cmdlineTests/recovery_standard_json/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract Errort6 { using foo for ; /* missing type name */ }" + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract Errort6 { using foo for ; /* missing type name */ }" } }, "settings": diff --git a/test/cmdlineTests/recovery_standard_json/output.json b/test/cmdlineTests/recovery_standard_json/output.json index 1f2ab6eb6..18a3b97ce 100644 --- a/test/cmdlineTests/recovery_standard_json/output.json +++ b/test/cmdlineTests/recovery_standard_json/output.json @@ -1,7 +1,7 @@ -{"errors":[{"component":"general","formattedMessage":"A:1:58: ParserError: Expected type name +{"errors":[{"component":"general","formattedMessage":"A:2:58: ParserError: Expected type name pragma solidity >=0.0; contract Errort6 { using foo for ; /* missing type name */ } ^ -","message":"Expected type name","severity":"error","sourceLocation":{"end":58,"file":"A","start":57},"type":"ParserError"},{"component":"general","formattedMessage":"A:1:84: Warning: Recovered in ContractDefinition at '}'. +","message":"Expected type name","severity":"error","sourceLocation":{"end":94,"file":"A","start":93},"type":"ParserError"},{"component":"general","formattedMessage":"A:2:84: Warning: Recovered in ContractDefinition at '}'. pragma solidity >=0.0; contract Errort6 { using foo for ; /* missing type name */ } ^ -","message":"Recovered in ContractDefinition at '}'.","severity":"warning","sourceLocation":{"end":84,"file":"A","start":83},"type":"Warning"}],"sources":{"A":{"ast":{"absolutePath":"A","exportedSymbols":{"Errort6":[3]},"id":4,"nodeType":"SourceUnit","nodes":[{"id":1,"literals":["solidity",">=","0.0"],"nodeType":"PragmaDirective","src":"0:22:0"},{"abstract":false,"baseContracts":[],"contractDependencies":[],"contractKind":"contract","documentation":null,"fullyImplemented":true,"id":3,"linearizedBaseContracts":[3],"name":"Errort6","nodeType":"ContractDefinition","nodes":[],"scope":4,"src":"23:35:0"}],"src":"0:84:0"},"id":0}}} +","message":"Recovered in ContractDefinition at '}'.","severity":"warning","sourceLocation":{"end":120,"file":"A","start":119},"type":"Warning"}],"sources":{"A":{"ast":{"absolutePath":"A","exportedSymbols":{"Errort6":[3]},"id":4,"license":"GPL-3.0","nodeType":"SourceUnit","nodes":[{"id":1,"literals":["solidity",">=","0.0"],"nodeType":"PragmaDirective","src":"36:22:0"},{"abstract":false,"baseContracts":[],"contractDependencies":[],"contractKind":"contract","documentation":null,"fullyImplemented":true,"id":3,"linearizedBaseContracts":[3],"name":"Errort6","nodeType":"ContractDefinition","nodes":[],"scope":4,"src":"59:35:0"}],"src":"36:84:0"},"id":0}}} diff --git a/test/cmdlineTests/require_overload/err b/test/cmdlineTests/require_overload/err index 83f027608..4c33672d4 100644 --- a/test/cmdlineTests/require_overload/err +++ b/test/cmdlineTests/require_overload/err @@ -1,7 +1,7 @@ Error: No matching declaration found after argument-dependent lookup. - --> require_overload/input.sol:4:9: + --> require_overload/input.sol:5:9: | -4 | require(this); +5 | require(this); | ^^^^^^^ Note: Candidate: function require(bool) Note: Candidate: function require(bool, string memory) diff --git a/test/cmdlineTests/require_overload/input.sol b/test/cmdlineTests/require_overload/input.sol index 6d48ac24a..b927c043c 100644 --- a/test/cmdlineTests/require_overload/input.sol +++ b/test/cmdlineTests/require_overload/input.sol @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.0; contract C { function f() public pure { diff --git a/test/cmdlineTests/standard_default_success/input.json b/test/cmdlineTests/standard_default_success/input.json index 826253b85..47a367113 100644 --- a/test/cmdlineTests/standard_default_success/input.json +++ b/test/cmdlineTests/standard_default_success/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } } } diff --git a/test/cmdlineTests/standard_eWasm_requested/input.json b/test/cmdlineTests/standard_eWasm_requested/input.json index 9476629e1..25cc1705d 100644 --- a/test/cmdlineTests/standard_eWasm_requested/input.json +++ b/test/cmdlineTests/standard_eWasm_requested/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { }" + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { }" } }, "settings": diff --git a/test/cmdlineTests/standard_empty_file_name/input.json b/test/cmdlineTests/standard_empty_file_name/input.json index 95c2cdd30..209f994c5 100644 --- a/test/cmdlineTests/standard_empty_file_name/input.json +++ b/test/cmdlineTests/standard_empty_file_name/input.json @@ -4,7 +4,7 @@ { "": { - "content": "pragma solidity >=0.0; import {A} from \".\";" + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; import {A} from \".\";" } } } diff --git a/test/cmdlineTests/standard_empty_file_name/output.json b/test/cmdlineTests/standard_empty_file_name/output.json index b31ceb152..d1ab4c870 100644 --- a/test/cmdlineTests/standard_empty_file_name/output.json +++ b/test/cmdlineTests/standard_empty_file_name/output.json @@ -1,4 +1,4 @@ -{"errors":[{"component":"general","formattedMessage":":1:24: DeclarationError: Declaration \"A\" not found in \"\" (referenced as \".\"). +{"errors":[{"component":"general","formattedMessage":":2:24: DeclarationError: Declaration \"A\" not found in \"\" (referenced as \".\"). pragma solidity >=0.0; import {A} from \".\"; ^------------------^ ","message":"Declaration \"A\" not found in \"\" (referenced as \".\").","severity":"error","type":"DeclarationError"}],"sources":{}} diff --git a/test/cmdlineTests/standard_immutable_references/input.json b/test/cmdlineTests/standard_immutable_references/input.json index 15213be74..d81365c8a 100644 --- a/test/cmdlineTests/standard_immutable_references/input.json +++ b/test/cmdlineTests/standard_immutable_references/input.json @@ -2,7 +2,7 @@ "language": "Solidity", "sources": { "a.sol": { - "content": "contract A { uint256 immutable x = 1; function f() public view returns (uint256) { return x; } }" + "content": "// SPDX-License-Identifier: GPL-3.0\ncontract A { uint256 immutable x = 1; function f() public view returns (uint256) { return x; } }" } }, "settings": { diff --git a/test/cmdlineTests/standard_immutable_references/output.json b/test/cmdlineTests/standard_immutable_references/output.json index 2788a8e73..edb5d74d0 100644 --- a/test/cmdlineTests/standard_immutable_references/output.json +++ b/test/cmdlineTests/standard_immutable_references/output.json @@ -1,2 +1,2 @@ -{"contracts":{"a.sol":{"A":{"evm":{"deployedBytecode":{"immutableReferences":{"3":[{"length":32,"start":77}]},"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"0:96:0:-:0;;;;5:9:-1;2:2;;;27:1;24;17:12;2:2;0:96:0;;;;;;;;;;;;;;;;12:1:-1;9;2:12;38:56:0;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;72:7;90:1;83:8;;38:56;:::o"}}}}},"errors":[{"component":"general","formattedMessage":"a.sol: Warning: Source file does not specify required compiler version! +{"contracts":{"a.sol":{"A":{"evm":{"deployedBytecode":{"immutableReferences":{"3":[{"length":32,"start":77}]},"linkReferences":{},"object":"bytecode removed","opcodes":"opcodes removed","sourceMap":"36:96:0:-:0;;;;5:9:-1;2:2;;;27:1;24;17:12;2:2;36:96:0;;;;;;;;;;;;;;;;12:1:-1;9;2:12;74:56:0;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;108:7;126:1;119:8;;74:56;:::o"}}}}},"errors":[{"component":"general","formattedMessage":"a.sol: Warning: Source file does not specify required compiler version! ","message":"Source file does not specify required compiler version!","severity":"warning","sourceLocation":{"end":-1,"file":"a.sol","start":-1},"type":"Warning"}],"sources":{"a.sol":{"id":0}}} diff --git a/test/cmdlineTests/standard_irOptimized_requested/input.json b/test/cmdlineTests/standard_irOptimized_requested/input.json index 96ea078bd..09aa37bae 100644 --- a/test/cmdlineTests/standard_irOptimized_requested/input.json +++ b/test/cmdlineTests/standard_irOptimized_requested/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } }, "settings": diff --git a/test/cmdlineTests/standard_ir_requested/input.json b/test/cmdlineTests/standard_ir_requested/input.json index 37404ddba..cc0a91df9 100644 --- a/test/cmdlineTests/standard_ir_requested/input.json +++ b/test/cmdlineTests/standard_ir_requested/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } }, "settings": diff --git a/test/cmdlineTests/standard_method_identifiers_requested/input.json b/test/cmdlineTests/standard_method_identifiers_requested/input.json index 79a3c75d2..c7a770fb4 100644 --- a/test/cmdlineTests/standard_method_identifiers_requested/input.json +++ b/test/cmdlineTests/standard_method_identifiers_requested/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } }, "settings": diff --git a/test/cmdlineTests/standard_missing_key_useLiteralContent/input.json b/test/cmdlineTests/standard_missing_key_useLiteralContent/input.json index 8627a282a..459f991b4 100644 --- a/test/cmdlineTests/standard_missing_key_useLiteralContent/input.json +++ b/test/cmdlineTests/standard_missing_key_useLiteralContent/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } }, "settings": diff --git a/test/cmdlineTests/standard_only_ast_requested/input.json b/test/cmdlineTests/standard_only_ast_requested/input.json index 7abd6da5f..56409a9a1 100644 --- a/test/cmdlineTests/standard_only_ast_requested/input.json +++ b/test/cmdlineTests/standard_only_ast_requested/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } }, "settings": diff --git a/test/cmdlineTests/standard_only_ast_requested/output.json b/test/cmdlineTests/standard_only_ast_requested/output.json index 6ba921abf..c1ffe5892 100644 --- a/test/cmdlineTests/standard_only_ast_requested/output.json +++ b/test/cmdlineTests/standard_only_ast_requested/output.json @@ -1 +1 @@ -{"sources":{"A":{"ast":{"absolutePath":"A","exportedSymbols":{"C":[6]},"id":7,"nodeType":"SourceUnit","nodes":[{"id":1,"literals":["solidity",">=","0.0"],"nodeType":"PragmaDirective","src":"0:22:0"},{"abstract":false,"baseContracts":[],"contractDependencies":[],"contractKind":"contract","documentation":null,"fullyImplemented":true,"id":6,"linearizedBaseContracts":[6],"name":"C","nodeType":"ContractDefinition","nodes":[{"body":{"id":4,"nodeType":"Block","src":"61:2:0","statements":[]},"documentation":null,"functionSelector":"26121ff0","id":5,"implemented":true,"kind":"function","modifiers":[],"name":"f","nodeType":"FunctionDefinition","overrides":null,"parameters":{"id":2,"nodeType":"ParameterList","parameters":[],"src":"46:2:0"},"returnParameters":{"id":3,"nodeType":"ParameterList","parameters":[],"src":"61:0:0"},"scope":6,"src":"36:27:0","stateMutability":"pure","virtual":false,"visibility":"public"}],"scope":7,"src":"23:42:0"}],"src":"0:65:0"},"id":0}}} +{"sources":{"A":{"ast":{"absolutePath":"A","exportedSymbols":{"C":[6]},"id":7,"license":"GPL-3.0","nodeType":"SourceUnit","nodes":[{"id":1,"literals":["solidity",">=","0.0"],"nodeType":"PragmaDirective","src":"36:22:0"},{"abstract":false,"baseContracts":[],"contractDependencies":[],"contractKind":"contract","documentation":null,"fullyImplemented":true,"id":6,"linearizedBaseContracts":[6],"name":"C","nodeType":"ContractDefinition","nodes":[{"body":{"id":4,"nodeType":"Block","src":"97:2:0","statements":[]},"documentation":null,"functionSelector":"26121ff0","id":5,"implemented":true,"kind":"function","modifiers":[],"name":"f","nodeType":"FunctionDefinition","overrides":null,"parameters":{"id":2,"nodeType":"ParameterList","parameters":[],"src":"82:2:0"},"returnParameters":{"id":3,"nodeType":"ParameterList","parameters":[],"src":"97:0:0"},"scope":6,"src":"72:27:0","stateMutability":"pure","virtual":false,"visibility":"public"}],"scope":7,"src":"59:42:0"}],"src":"36:65:0"},"id":0}}} diff --git a/test/cmdlineTests/standard_optimizer_invalid_detail_type/input.json b/test/cmdlineTests/standard_optimizer_invalid_detail_type/input.json index f0ce43e37..5e90f6d98 100644 --- a/test/cmdlineTests/standard_optimizer_invalid_detail_type/input.json +++ b/test/cmdlineTests/standard_optimizer_invalid_detail_type/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } }, "settings": diff --git a/test/cmdlineTests/standard_optimizer_invalid_details/input.json b/test/cmdlineTests/standard_optimizer_invalid_details/input.json index 850f6f77c..eecfbd5e5 100644 --- a/test/cmdlineTests/standard_optimizer_invalid_details/input.json +++ b/test/cmdlineTests/standard_optimizer_invalid_details/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } }, "settings": diff --git a/test/cmdlineTests/standard_optimizer_no_yul/input.json b/test/cmdlineTests/standard_optimizer_no_yul/input.json index 23f14b488..a42299fbe 100644 --- a/test/cmdlineTests/standard_optimizer_no_yul/input.json +++ b/test/cmdlineTests/standard_optimizer_no_yul/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } }, "settings": diff --git a/test/cmdlineTests/standard_optimizer_yul/input.json b/test/cmdlineTests/standard_optimizer_yul/input.json index 3cafae03a..5e81a6091 100644 --- a/test/cmdlineTests/standard_optimizer_yul/input.json +++ b/test/cmdlineTests/standard_optimizer_yul/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } }, "settings": diff --git a/test/cmdlineTests/standard_optimizer_yulDetails/input.json b/test/cmdlineTests/standard_optimizer_yulDetails/input.json index 5203e64bf..842468bca 100644 --- a/test/cmdlineTests/standard_optimizer_yulDetails/input.json +++ b/test/cmdlineTests/standard_optimizer_yulDetails/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } }, "settings": diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_no_object/input.json b/test/cmdlineTests/standard_optimizer_yulDetails_no_object/input.json index 18d3852db..2581aeb71 100644 --- a/test/cmdlineTests/standard_optimizer_yulDetails_no_object/input.json +++ b/test/cmdlineTests/standard_optimizer_yulDetails_no_object/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } }, "settings": diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps/input.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps/input.json index 00919a864..0dcdab6c2 100644 --- a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps/input.json +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } }, "settings": diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_invalid_abbreviation/input.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_invalid_abbreviation/input.json index 25b3c4bb4..427566764 100644 --- a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_invalid_abbreviation/input.json +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_invalid_abbreviation/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } }, "settings": diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_invalid_nesting/input.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_invalid_nesting/input.json index c322913d9..851e132e8 100644 --- a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_invalid_nesting/input.json +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_invalid_nesting/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } }, "settings": diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_type/input.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_type/input.json index c02aa6bb3..11bc9ca62 100644 --- a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_type/input.json +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_type/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } }, "settings": diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_unbalanced_bracket/input.json b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_unbalanced_bracket/input.json index d6e1e0dc7..79c52e6dd 100644 --- a/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_unbalanced_bracket/input.json +++ b/test/cmdlineTests/standard_optimizer_yulDetails_optimiserSteps_unbalanced_bracket/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } }, "settings": diff --git a/test/cmdlineTests/standard_optimizer_yulDetails_without_yul/input.json b/test/cmdlineTests/standard_optimizer_yulDetails_without_yul/input.json index 056aee91b..cac3c068b 100644 --- a/test/cmdlineTests/standard_optimizer_yulDetails_without_yul/input.json +++ b/test/cmdlineTests/standard_optimizer_yulDetails_without_yul/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } }, "settings": diff --git a/test/cmdlineTests/standard_secondary_source_location/input.json b/test/cmdlineTests/standard_secondary_source_location/input.json index f08069d9f..0cd6a6126 100644 --- a/test/cmdlineTests/standard_secondary_source_location/input.json +++ b/test/cmdlineTests/standard_secondary_source_location/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract A { constructor(uint) public {} } contract B is A(2) { } contract C is A(3) {} contract D is B, C {}" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract A { constructor(uint) public {} } contract B is A(2) { } contract C is A(3) {} contract D is B, C {}" } } } diff --git a/test/cmdlineTests/standard_secondary_source_location/output.json b/test/cmdlineTests/standard_secondary_source_location/output.json index 0330135e2..d9f56b80d 100644 --- a/test/cmdlineTests/standard_secondary_source_location/output.json +++ b/test/cmdlineTests/standard_secondary_source_location/output.json @@ -1,10 +1,10 @@ -{"errors":[{"component":"general","formattedMessage":"A:1:112: DeclarationError: Base constructor arguments given twice. +{"errors":[{"component":"general","formattedMessage":"A:2:112: DeclarationError: Base constructor arguments given twice. pragma solidity >=0.0; contract A { constructor(uint) public {} } contract B is A(2) { } contract C is A(3) {} contract D is B, C {} ^-------------------^ -A:1:81: First constructor call is here: +A:2:81: First constructor call is here: pragma solidity >=0.0; contract A { constructor(uint) public {} } contract B is A(2) { } contract C is A(3) {} contract D is B, C {} ^--^ -A:1:104: Second constructor call is here: +A:2:104: Second constructor call is here: pragma solidity >=0.0; contract A { constructor(uint) public {} } contract B is A(2) { } contract C is A(3) {} contract D is B, C {} ^--^ -","message":"Base constructor arguments given twice.","secondarySourceLocations":[{"end":84,"file":"A","message":"First constructor call is here:","start":80},{"end":107,"file":"A","message":"Second constructor call is here:","start":103}],"severity":"error","sourceLocation":{"end":132,"file":"A","start":111},"type":"DeclarationError"}],"sources":{}} +","message":"Base constructor arguments given twice.","secondarySourceLocations":[{"end":119,"file":"A","message":"First constructor call is here:","start":115},{"end":142,"file":"A","message":"Second constructor call is here:","start":138}],"severity":"error","sourceLocation":{"end":167,"file":"A","start":146},"type":"DeclarationError"}],"sources":{}} diff --git a/test/cmdlineTests/standard_wrong_key_auxiliary_input/input.json b/test/cmdlineTests/standard_wrong_key_auxiliary_input/input.json index 51dbce41a..0843460ed 100644 --- a/test/cmdlineTests/standard_wrong_key_auxiliary_input/input.json +++ b/test/cmdlineTests/standard_wrong_key_auxiliary_input/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } }, "auxiliaryInput": diff --git a/test/cmdlineTests/standard_wrong_key_metadata/input.json b/test/cmdlineTests/standard_wrong_key_metadata/input.json index 490e489a2..a52d45004 100644 --- a/test/cmdlineTests/standard_wrong_key_metadata/input.json +++ b/test/cmdlineTests/standard_wrong_key_metadata/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } }, "settings": diff --git a/test/cmdlineTests/standard_wrong_key_optimizer/input.json b/test/cmdlineTests/standard_wrong_key_optimizer/input.json index c28c3a92d..945c1e346 100644 --- a/test/cmdlineTests/standard_wrong_key_optimizer/input.json +++ b/test/cmdlineTests/standard_wrong_key_optimizer/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } }, "settings": diff --git a/test/cmdlineTests/standard_wrong_key_root/input.json b/test/cmdlineTests/standard_wrong_key_root/input.json index 4689c50c0..2fb1a656b 100644 --- a/test/cmdlineTests/standard_wrong_key_root/input.json +++ b/test/cmdlineTests/standard_wrong_key_root/input.json @@ -5,7 +5,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } } } diff --git a/test/cmdlineTests/standard_wrong_key_settings/input.json b/test/cmdlineTests/standard_wrong_key_settings/input.json index d7809b1c8..8f0e1d06b 100644 --- a/test/cmdlineTests/standard_wrong_key_settings/input.json +++ b/test/cmdlineTests/standard_wrong_key_settings/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } }, "settings": diff --git a/test/cmdlineTests/standard_wrong_key_source/input.json b/test/cmdlineTests/standard_wrong_key_source/input.json index d8a8aa16f..f4b0f560a 100644 --- a/test/cmdlineTests/standard_wrong_key_source/input.json +++ b/test/cmdlineTests/standard_wrong_key_source/input.json @@ -5,7 +5,7 @@ "A": { "key1": "test", - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } } } diff --git a/test/cmdlineTests/standard_wrong_type_auxiliary_input/input.json b/test/cmdlineTests/standard_wrong_type_auxiliary_input/input.json index 8d2c75931..895aa80ee 100644 --- a/test/cmdlineTests/standard_wrong_type_auxiliary_input/input.json +++ b/test/cmdlineTests/standard_wrong_type_auxiliary_input/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } }, "auxiliaryInput": [1, 2, 3] diff --git a/test/cmdlineTests/standard_wrong_type_auxiliary_input_smtlib2responses/input.json b/test/cmdlineTests/standard_wrong_type_auxiliary_input_smtlib2responses/input.json index 9175050fd..46090f7e3 100644 --- a/test/cmdlineTests/standard_wrong_type_auxiliary_input_smtlib2responses/input.json +++ b/test/cmdlineTests/standard_wrong_type_auxiliary_input_smtlib2responses/input.json @@ -2,7 +2,7 @@ "language": "Solidity", "sources": { "fileA": { - "content": "contract A { }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A { }" } }, "settings": { diff --git a/test/cmdlineTests/standard_wrong_type_auxiliary_input_smtlib2responses_member/input.json b/test/cmdlineTests/standard_wrong_type_auxiliary_input_smtlib2responses_member/input.json index aa7d451b1..96ca950b1 100644 --- a/test/cmdlineTests/standard_wrong_type_auxiliary_input_smtlib2responses_member/input.json +++ b/test/cmdlineTests/standard_wrong_type_auxiliary_input_smtlib2responses_member/input.json @@ -2,7 +2,7 @@ "language": "Solidity", "sources": { "fileA": { - "content": "contract A { }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A { }" } }, "settings": { diff --git a/test/cmdlineTests/standard_wrong_type_metadata/input.json b/test/cmdlineTests/standard_wrong_type_metadata/input.json index d4dd06a1f..0d459ef37 100644 --- a/test/cmdlineTests/standard_wrong_type_metadata/input.json +++ b/test/cmdlineTests/standard_wrong_type_metadata/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } }, "settings": diff --git a/test/cmdlineTests/standard_wrong_type_optimizer/input.json b/test/cmdlineTests/standard_wrong_type_optimizer/input.json index b42ca550a..f623628e9 100644 --- a/test/cmdlineTests/standard_wrong_type_optimizer/input.json +++ b/test/cmdlineTests/standard_wrong_type_optimizer/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } }, "settings": diff --git a/test/cmdlineTests/standard_wrong_type_output_selection/input.json b/test/cmdlineTests/standard_wrong_type_output_selection/input.json index a7b615d1c..5f03fbf7b 100644 --- a/test/cmdlineTests/standard_wrong_type_output_selection/input.json +++ b/test/cmdlineTests/standard_wrong_type_output_selection/input.json @@ -2,7 +2,7 @@ "language": "Solidity", "sources": { "fileA": { - "content": "contract A { }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A { }" } }, "settings": { diff --git a/test/cmdlineTests/standard_wrong_type_output_selection_contract/input.json b/test/cmdlineTests/standard_wrong_type_output_selection_contract/input.json index 9840a97e5..4004b2285 100644 --- a/test/cmdlineTests/standard_wrong_type_output_selection_contract/input.json +++ b/test/cmdlineTests/standard_wrong_type_output_selection_contract/input.json @@ -2,7 +2,7 @@ "language": "Solidity", "sources": { "fileA": { - "content": "contract A { }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A { }" } }, "settings": { diff --git a/test/cmdlineTests/standard_wrong_type_output_selection_file/input.json b/test/cmdlineTests/standard_wrong_type_output_selection_file/input.json index 7ab12ba8b..9bfdb99ad 100644 --- a/test/cmdlineTests/standard_wrong_type_output_selection_file/input.json +++ b/test/cmdlineTests/standard_wrong_type_output_selection_file/input.json @@ -2,7 +2,7 @@ "language": "Solidity", "sources": { "fileA": { - "content": "contract A { }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A { }" } }, "settings": { diff --git a/test/cmdlineTests/standard_wrong_type_output_selection_output/input.json b/test/cmdlineTests/standard_wrong_type_output_selection_output/input.json index 3e5cd6618..d5c51fa93 100644 --- a/test/cmdlineTests/standard_wrong_type_output_selection_output/input.json +++ b/test/cmdlineTests/standard_wrong_type_output_selection_output/input.json @@ -2,7 +2,7 @@ "language": "Solidity", "sources": { "fileA": { - "content": "contract A { }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A { }" } }, "settings": { diff --git a/test/cmdlineTests/standard_wrong_type_remappings/input.json b/test/cmdlineTests/standard_wrong_type_remappings/input.json index 1436e0147..4d64b9e47 100644 --- a/test/cmdlineTests/standard_wrong_type_remappings/input.json +++ b/test/cmdlineTests/standard_wrong_type_remappings/input.json @@ -2,7 +2,7 @@ "language": "Solidity", "sources": { "fileA": { - "content": "contract A { }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A { }" } }, "settings": { diff --git a/test/cmdlineTests/standard_wrong_type_remappings_entry/input.json b/test/cmdlineTests/standard_wrong_type_remappings_entry/input.json index c96611f3e..ee7fb52fa 100644 --- a/test/cmdlineTests/standard_wrong_type_remappings_entry/input.json +++ b/test/cmdlineTests/standard_wrong_type_remappings_entry/input.json @@ -2,7 +2,7 @@ "language": "Solidity", "sources": { "fileA": { - "content": "contract A { }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A { }" } }, "settings": { diff --git a/test/cmdlineTests/standard_wrong_type_settings/input.json b/test/cmdlineTests/standard_wrong_type_settings/input.json index 7cdb0881c..638f57a76 100644 --- a/test/cmdlineTests/standard_wrong_type_settings/input.json +++ b/test/cmdlineTests/standard_wrong_type_settings/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } }, "settings": diff --git a/test/cmdlineTests/standard_wrong_type_source/input.json b/test/cmdlineTests/standard_wrong_type_source/input.json index d58504fe0..f8c72996b 100644 --- a/test/cmdlineTests/standard_wrong_type_source/input.json +++ b/test/cmdlineTests/standard_wrong_type_source/input.json @@ -6,7 +6,7 @@ "B": [1, 2, 3], "C": { - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } } } diff --git a/test/cmdlineTests/standard_wrong_type_useLiteralContent/input.json b/test/cmdlineTests/standard_wrong_type_useLiteralContent/input.json index be4272b6c..b96a17564 100644 --- a/test/cmdlineTests/standard_wrong_type_useLiteralContent/input.json +++ b/test/cmdlineTests/standard_wrong_type_useLiteralContent/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() public pure {} }" } }, "settings": diff --git a/test/cmdlineTests/storage_layout_bytes/input.json b/test/cmdlineTests/storage_layout_bytes/input.json index fe1468c53..cd69dd0ed 100644 --- a/test/cmdlineTests/storage_layout_bytes/input.json +++ b/test/cmdlineTests/storage_layout_bytes/input.json @@ -2,7 +2,7 @@ "language": "Solidity", "sources": { "fileA": { - "content": "contract A { bytes s1 = \"test\"; bytes s2; }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A { bytes s1 = \"test\"; bytes s2; }" } }, "settings": { diff --git a/test/cmdlineTests/storage_layout_dyn_array/input.json b/test/cmdlineTests/storage_layout_dyn_array/input.json index 64ab3e20b..2904a9cef 100644 --- a/test/cmdlineTests/storage_layout_dyn_array/input.json +++ b/test/cmdlineTests/storage_layout_dyn_array/input.json @@ -2,7 +2,7 @@ "language": "Solidity", "sources": { "fileA": { - "content": "contract A { uint[] array1; bool[] array2; }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A { uint[] array1; bool[] array2; }" } }, "settings": { diff --git a/test/cmdlineTests/storage_layout_many/input.json b/test/cmdlineTests/storage_layout_many/input.json index 7ea41f211..90b4e25dd 100644 --- a/test/cmdlineTests/storage_layout_many/input.json +++ b/test/cmdlineTests/storage_layout_many/input.json @@ -2,7 +2,7 @@ "language": "Solidity", "sources": { "fileA": { - "content": "contract A { struct S { uint128 a; uint128 b; uint[2] staticArray; uint[] dynArray; } uint x; uint y; S s; address addr; mapping (uint => mapping (address => bool)) map; uint[] array; string s1; bytes b1; }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A { struct S { uint128 a; uint128 b; uint[2] staticArray; uint[] dynArray; } uint x; uint y; S s; address addr; mapping (uint => mapping (address => bool)) map; uint[] array; string s1; bytes b1; }" } }, "settings": { diff --git a/test/cmdlineTests/storage_layout_mapping/input.json b/test/cmdlineTests/storage_layout_mapping/input.json index 6292391d5..66ecff537 100644 --- a/test/cmdlineTests/storage_layout_mapping/input.json +++ b/test/cmdlineTests/storage_layout_mapping/input.json @@ -2,7 +2,7 @@ "language": "Solidity", "sources": { "fileA": { - "content": "contract A { uint x; uint y; mapping (uint => mapping (address => bool)) map; }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A { uint x; uint y; mapping (uint => mapping (address => bool)) map; }" } }, "settings": { diff --git a/test/cmdlineTests/storage_layout_smoke/input.json b/test/cmdlineTests/storage_layout_smoke/input.json index 47722e759..90fd18101 100644 --- a/test/cmdlineTests/storage_layout_smoke/input.json +++ b/test/cmdlineTests/storage_layout_smoke/input.json @@ -2,7 +2,7 @@ "language": "Solidity", "sources": { "fileA": { - "content": "contract A { }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A { }" } }, "settings": { diff --git a/test/cmdlineTests/storage_layout_smoke_two_contracts/input.json b/test/cmdlineTests/storage_layout_smoke_two_contracts/input.json index b31f3dd9d..15cb774f5 100644 --- a/test/cmdlineTests/storage_layout_smoke_two_contracts/input.json +++ b/test/cmdlineTests/storage_layout_smoke_two_contracts/input.json @@ -2,10 +2,10 @@ "language": "Solidity", "sources": { "fileA": { - "content": "contract A { }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A { }" }, "fileB": { - "content": "contract A { uint x; uint y; }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A { uint x; uint y; }" } }, "settings": { diff --git a/test/cmdlineTests/storage_layout_string/input.json b/test/cmdlineTests/storage_layout_string/input.json index 834617b3a..d069d3098 100644 --- a/test/cmdlineTests/storage_layout_string/input.json +++ b/test/cmdlineTests/storage_layout_string/input.json @@ -2,7 +2,7 @@ "language": "Solidity", "sources": { "fileA": { - "content": "contract A { string s1 = \"test\"; string s2; }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A { string s1 = \"test\"; string s2; }" } }, "settings": { diff --git a/test/cmdlineTests/storage_layout_struct/input.json b/test/cmdlineTests/storage_layout_struct/input.json index 31ab020cf..7353386df 100644 --- a/test/cmdlineTests/storage_layout_struct/input.json +++ b/test/cmdlineTests/storage_layout_struct/input.json @@ -2,7 +2,7 @@ "language": "Solidity", "sources": { "fileA": { - "content": "contract A { struct S { uint a; uint b; uint[2] staticArray; uint[] dynArray; } uint x; uint y; S s; address addr; }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A { struct S { uint a; uint b; uint[2] staticArray; uint[] dynArray; } uint x; uint y; S s; address addr; }" } }, "settings": { diff --git a/test/cmdlineTests/storage_layout_struct_packed/input.json b/test/cmdlineTests/storage_layout_struct_packed/input.json index 80c706c7b..e562a6a3a 100644 --- a/test/cmdlineTests/storage_layout_struct_packed/input.json +++ b/test/cmdlineTests/storage_layout_struct_packed/input.json @@ -2,7 +2,7 @@ "language": "Solidity", "sources": { "fileA": { - "content": "contract A { struct S { uint128 a; uint128 b; uint[2] staticArray; uint[] dynArray; } uint x; uint y; S s; address addr; }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A { struct S { uint128 a; uint128 b; uint[2] staticArray; uint[] dynArray; } uint x; uint y; S s; address addr; }" } }, "settings": { diff --git a/test/cmdlineTests/storage_layout_value_types/input.json b/test/cmdlineTests/storage_layout_value_types/input.json index 1477dde08..3f0dd709c 100644 --- a/test/cmdlineTests/storage_layout_value_types/input.json +++ b/test/cmdlineTests/storage_layout_value_types/input.json @@ -2,7 +2,7 @@ "language": "Solidity", "sources": { "fileA": { - "content": "contract A { uint x; uint y; address addr; uint[2] array; }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A { uint x; uint y; address addr; uint[2] array; }" } }, "settings": { diff --git a/test/cmdlineTests/storage_layout_value_types_packed/input.json b/test/cmdlineTests/storage_layout_value_types_packed/input.json index 04a7bd3bf..18af8f50f 100644 --- a/test/cmdlineTests/storage_layout_value_types_packed/input.json +++ b/test/cmdlineTests/storage_layout_value_types_packed/input.json @@ -2,7 +2,7 @@ "language": "Solidity", "sources": { "fileA": { - "content": "contract A { uint64 x; uint128 y; uint128 z; address addr; uint[2] array; }" + "content": "//SPDX-License-Identifier: GPL-3.0\ncontract A { uint64 x; uint128 y; uint128 z; address addr; uint[2] array; }" } }, "settings": { diff --git a/test/cmdlineTests/structured_documentation_source_location/err b/test/cmdlineTests/structured_documentation_source_location/err index 1081fdaa8..1f69adf4f 100644 --- a/test/cmdlineTests/structured_documentation_source_location/err +++ b/test/cmdlineTests/structured_documentation_source_location/err @@ -1,11 +1,11 @@ Error: Documentation tag "@return No value returned" does not contain the name of its return parameter. - --> structured_documentation_source_location/input.sol:3:5: + --> structured_documentation_source_location/input.sol:4:5: | -3 | /// @param id Some identifier +4 | /// @param id Some identifier | ^ (Relevant source part starts here and spans across multiple lines). Error: Documentation tag "@return No value returned" does not contain the name of its return parameter. - --> structured_documentation_source_location/input.sol:7:5: + --> structured_documentation_source_location/input.sol:8:5: | -7 | /// @return No value returned +8 | /// @return No value returned | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/test/cmdlineTests/structured_documentation_source_location/input.sol b/test/cmdlineTests/structured_documentation_source_location/input.sol index ceec13547..399c2b8b8 100644 --- a/test/cmdlineTests/structured_documentation_source_location/input.sol +++ b/test/cmdlineTests/structured_documentation_source_location/input.sol @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-3.0 pragma solidity >= 0.0; abstract contract C { /// @param id Some identifier diff --git a/test/cmdlineTests/too_long_line/err b/test/cmdlineTests/too_long_line/err index 6e5119037..802cac3cb 100644 --- a/test/cmdlineTests/too_long_line/err +++ b/test/cmdlineTests/too_long_line/err @@ -1,3 +1,6 @@ +Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information. +--> too_long_line/input.sol + Warning: Source file does not specify required compiler version! --> too_long_line/input.sol diff --git a/test/cmdlineTests/too_long_line_both_sides_short/err b/test/cmdlineTests/too_long_line_both_sides_short/err index 34bd25d28..131fab209 100644 --- a/test/cmdlineTests/too_long_line_both_sides_short/err +++ b/test/cmdlineTests/too_long_line_both_sides_short/err @@ -1,3 +1,6 @@ +Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information. +--> too_long_line_both_sides_short/input.sol + Warning: Source file does not specify required compiler version! --> too_long_line_both_sides_short/input.sol diff --git a/test/cmdlineTests/too_long_line_edge_in/err b/test/cmdlineTests/too_long_line_edge_in/err index 2988bc44e..83cd670e1 100644 --- a/test/cmdlineTests/too_long_line_edge_in/err +++ b/test/cmdlineTests/too_long_line_edge_in/err @@ -1,3 +1,6 @@ +Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information. +--> too_long_line_edge_in/input.sol + Warning: Source file does not specify required compiler version! --> too_long_line_edge_in/input.sol diff --git a/test/cmdlineTests/too_long_line_edge_out/err b/test/cmdlineTests/too_long_line_edge_out/err index a85faa44f..7d3b54f21 100644 --- a/test/cmdlineTests/too_long_line_edge_out/err +++ b/test/cmdlineTests/too_long_line_edge_out/err @@ -1,3 +1,6 @@ +Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information. +--> too_long_line_edge_out/input.sol + Warning: Source file does not specify required compiler version! --> too_long_line_edge_out/input.sol diff --git a/test/cmdlineTests/too_long_line_left_short/err b/test/cmdlineTests/too_long_line_left_short/err index aa36b1068..0f8c70e5a 100644 --- a/test/cmdlineTests/too_long_line_left_short/err +++ b/test/cmdlineTests/too_long_line_left_short/err @@ -1,3 +1,6 @@ +Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information. +--> too_long_line_left_short/input.sol + Warning: Source file does not specify required compiler version! --> too_long_line_left_short/input.sol diff --git a/test/cmdlineTests/too_long_line_multiline/err b/test/cmdlineTests/too_long_line_multiline/err index 2aa801623..6d8114ca8 100644 --- a/test/cmdlineTests/too_long_line_multiline/err +++ b/test/cmdlineTests/too_long_line_multiline/err @@ -1,3 +1,6 @@ +Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information. +--> too_long_line_multiline/input.sol + Error: No visibility specified. Did you intend to add "public"? --> too_long_line_multiline/input.sol:2:5: | diff --git a/test/cmdlineTests/too_long_line_right_short/err b/test/cmdlineTests/too_long_line_right_short/err index d2d8f3980..6837dd8ab 100644 --- a/test/cmdlineTests/too_long_line_right_short/err +++ b/test/cmdlineTests/too_long_line_right_short/err @@ -1,3 +1,6 @@ +Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information. +--> too_long_line_right_short/input.sol + Warning: Source file does not specify required compiler version! --> too_long_line_right_short/input.sol diff --git a/test/cmdlineTests/yul_optimizer_steps/input.sol b/test/cmdlineTests/yul_optimizer_steps/input.sol index f787d2fcf..a75662b25 100644 --- a/test/cmdlineTests/yul_optimizer_steps/input.sol +++ b/test/cmdlineTests/yul_optimizer_steps/input.sol @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.0; contract C diff --git a/test/cmdlineTests/yul_optimizer_steps_disabled/input.sol b/test/cmdlineTests/yul_optimizer_steps_disabled/input.sol index 363a4c721..6923ca702 100644 --- a/test/cmdlineTests/yul_optimizer_steps_disabled/input.sol +++ b/test/cmdlineTests/yul_optimizer_steps_disabled/input.sol @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.0; contract C diff --git a/test/cmdlineTests/yul_optimizer_steps_invalid_abbreviation/input.sol b/test/cmdlineTests/yul_optimizer_steps_invalid_abbreviation/input.sol index 363a4c721..6923ca702 100644 --- a/test/cmdlineTests/yul_optimizer_steps_invalid_abbreviation/input.sol +++ b/test/cmdlineTests/yul_optimizer_steps_invalid_abbreviation/input.sol @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.0; contract C diff --git a/test/cmdlineTests/yul_optimizer_steps_invalid_nesting/input.sol b/test/cmdlineTests/yul_optimizer_steps_invalid_nesting/input.sol index 363a4c721..6923ca702 100644 --- a/test/cmdlineTests/yul_optimizer_steps_invalid_nesting/input.sol +++ b/test/cmdlineTests/yul_optimizer_steps_invalid_nesting/input.sol @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.0; contract C diff --git a/test/cmdlineTests/yul_optimizer_steps_unbalanced_bracket/input.sol b/test/cmdlineTests/yul_optimizer_steps_unbalanced_bracket/input.sol index 363a4c721..6923ca702 100644 --- a/test/cmdlineTests/yul_optimizer_steps_unbalanced_bracket/input.sol +++ b/test/cmdlineTests/yul_optimizer_steps_unbalanced_bracket/input.sol @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.0; contract C diff --git a/test/cmdlineTests/yul_string_format_ascii/input.json b/test/cmdlineTests/yul_string_format_ascii/input.json index c23c65b5a..0eba555c9 100644 --- a/test/cmdlineTests/yul_string_format_ascii/input.json +++ b/test/cmdlineTests/yul_string_format_ascii/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() external pure returns (string memory) { return \"abcabc\"; } }" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() external pure returns (string memory) { return \"abcabc\"; } }" } }, "settings": diff --git a/test/cmdlineTests/yul_string_format_ascii_bytes32/input.json b/test/cmdlineTests/yul_string_format_ascii_bytes32/input.json index 247f665cb..3dbcdb819 100644 --- a/test/cmdlineTests/yul_string_format_ascii_bytes32/input.json +++ b/test/cmdlineTests/yul_string_format_ascii_bytes32/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() external pure returns (bytes32) { return \"abcabc\"; } }" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() external pure returns (bytes32) { return \"abcabc\"; } }" } }, "settings": diff --git a/test/cmdlineTests/yul_string_format_ascii_bytes32_from_number/input.json b/test/cmdlineTests/yul_string_format_ascii_bytes32_from_number/input.json index c7309f2af..003dddfa7 100644 --- a/test/cmdlineTests/yul_string_format_ascii_bytes32_from_number/input.json +++ b/test/cmdlineTests/yul_string_format_ascii_bytes32_from_number/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() external pure returns (bytes4) { return 0x61626364; } }" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() external pure returns (bytes4) { return 0x61626364; } }" } }, "settings": diff --git a/test/cmdlineTests/yul_string_format_ascii_long/input.json b/test/cmdlineTests/yul_string_format_ascii_long/input.json index cf3b2a854..5d91e402e 100644 --- a/test/cmdlineTests/yul_string_format_ascii_long/input.json +++ b/test/cmdlineTests/yul_string_format_ascii_long/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() external pure returns (string memory) { return \"abcdabcdcafecafeabcdabcdcafecafeffffzzzzoooo0123456789,.<,>.?:;'[{]}|`~!@#$%^&*()-_=+\"; } }" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() external pure returns (string memory) { return \"abcdabcdcafecafeabcdabcdcafecafeffffzzzzoooo0123456789,.<,>.?:;'[{]}|`~!@#$%^&*()-_=+\"; } }" } }, "settings": diff --git a/test/cmdlineTests/yul_string_format_hex/input.json b/test/cmdlineTests/yul_string_format_hex/input.json index 5ba723f56..9bb3fd138 100644 --- a/test/cmdlineTests/yul_string_format_hex/input.json +++ b/test/cmdlineTests/yul_string_format_hex/input.json @@ -4,7 +4,7 @@ { "A": { - "content": "pragma solidity >=0.0; contract C { function f() external pure returns (bytes4) { return 0xaabbccdd; } }" + "content": "//SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0; contract C { function f() external pure returns (bytes4) { return 0xaabbccdd; } }" } }, "settings": diff --git a/test/libsolidity/ASTJSON/abstract_contract.json b/test/libsolidity/ASTJSON/abstract_contract.json index da9fd1196..32b414e8a 100644 --- a/test/libsolidity/ASTJSON/abstract_contract.json +++ b/test/libsolidity/ASTJSON/abstract_contract.json @@ -8,6 +8,7 @@ ] }, "id": 6, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/abstract_contract_legacy.json b/test/libsolidity/ASTJSON/abstract_contract_legacy.json index 66d1c0e8b..13f046eec 100644 --- a/test/libsolidity/ASTJSON/abstract_contract_legacy.json +++ b/test/libsolidity/ASTJSON/abstract_contract_legacy.json @@ -8,7 +8,8 @@ [ 5 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/address_payable.json b/test/libsolidity/ASTJSON/address_payable.json index ef965ac79..a82fa0b82 100644 --- a/test/libsolidity/ASTJSON/address_payable.json +++ b/test/libsolidity/ASTJSON/address_payable.json @@ -8,6 +8,7 @@ ] }, "id": 40, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/address_payable_legacy.json b/test/libsolidity/ASTJSON/address_payable_legacy.json index dd33e6408..7fe404f3e 100644 --- a/test/libsolidity/ASTJSON/address_payable_legacy.json +++ b/test/libsolidity/ASTJSON/address_payable_legacy.json @@ -8,7 +8,8 @@ [ 39 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/array_type_name.json b/test/libsolidity/ASTJSON/array_type_name.json index e97518cb8..a09bc306a 100644 --- a/test/libsolidity/ASTJSON/array_type_name.json +++ b/test/libsolidity/ASTJSON/array_type_name.json @@ -8,6 +8,7 @@ ] }, "id": 5, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/array_type_name_legacy.json b/test/libsolidity/ASTJSON/array_type_name_legacy.json index 37175bb37..cc1c7a77a 100644 --- a/test/libsolidity/ASTJSON/array_type_name_legacy.json +++ b/test/libsolidity/ASTJSON/array_type_name_legacy.json @@ -8,7 +8,8 @@ [ 4 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/assembly/call.json b/test/libsolidity/ASTJSON/assembly/call.json index 1c2a4bf7e..ad81c1094 100644 --- a/test/libsolidity/ASTJSON/assembly/call.json +++ b/test/libsolidity/ASTJSON/assembly/call.json @@ -8,6 +8,7 @@ ] }, "id": 7, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/assembly/call_legacy.json b/test/libsolidity/ASTJSON/assembly/call_legacy.json index 619d132bc..93ad1b956 100644 --- a/test/libsolidity/ASTJSON/assembly/call_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/call_legacy.json @@ -8,7 +8,8 @@ [ 6 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/assembly/empty_block.json b/test/libsolidity/ASTJSON/assembly/empty_block.json index 575b1f7f4..847fd4085 100644 --- a/test/libsolidity/ASTJSON/assembly/empty_block.json +++ b/test/libsolidity/ASTJSON/assembly/empty_block.json @@ -8,6 +8,7 @@ ] }, "id": 7, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/assembly/empty_block_legacy.json b/test/libsolidity/ASTJSON/assembly/empty_block_legacy.json index 108a76a00..74d24d5e1 100644 --- a/test/libsolidity/ASTJSON/assembly/empty_block_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/empty_block_legacy.json @@ -8,7 +8,8 @@ [ 6 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/assembly/function.json b/test/libsolidity/ASTJSON/assembly/function.json index 7e9895261..6bd37162d 100644 --- a/test/libsolidity/ASTJSON/assembly/function.json +++ b/test/libsolidity/ASTJSON/assembly/function.json @@ -8,6 +8,7 @@ ] }, "id": 7, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/assembly/function_legacy.json b/test/libsolidity/ASTJSON/assembly/function_legacy.json index 163d8d05a..ee6918d25 100644 --- a/test/libsolidity/ASTJSON/assembly/function_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/function_legacy.json @@ -8,7 +8,8 @@ [ 6 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/assembly/leave.json b/test/libsolidity/ASTJSON/assembly/leave.json index c8ef5eaee..5868c1acb 100644 --- a/test/libsolidity/ASTJSON/assembly/leave.json +++ b/test/libsolidity/ASTJSON/assembly/leave.json @@ -8,6 +8,7 @@ ] }, "id": 7, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/assembly/leave_legacy.json b/test/libsolidity/ASTJSON/assembly/leave_legacy.json index 35ce02f55..2c39fba37 100644 --- a/test/libsolidity/ASTJSON/assembly/leave_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/leave_legacy.json @@ -8,7 +8,8 @@ [ 6 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/assembly/loop.json b/test/libsolidity/ASTJSON/assembly/loop.json index b815da447..263db400d 100644 --- a/test/libsolidity/ASTJSON/assembly/loop.json +++ b/test/libsolidity/ASTJSON/assembly/loop.json @@ -8,6 +8,7 @@ ] }, "id": 7, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/assembly/loop_legacy.json b/test/libsolidity/ASTJSON/assembly/loop_legacy.json index cf4095dd8..5085e4c50 100644 --- a/test/libsolidity/ASTJSON/assembly/loop_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/loop_legacy.json @@ -8,7 +8,8 @@ [ 6 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/assembly/nested_functions.json b/test/libsolidity/ASTJSON/assembly/nested_functions.json index f52cbfc08..5abb7fce4 100644 --- a/test/libsolidity/ASTJSON/assembly/nested_functions.json +++ b/test/libsolidity/ASTJSON/assembly/nested_functions.json @@ -8,6 +8,7 @@ ] }, "id": 9, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/assembly/nested_functions_legacy.json b/test/libsolidity/ASTJSON/assembly/nested_functions_legacy.json index c0164e3f7..0ccfcf85a 100644 --- a/test/libsolidity/ASTJSON/assembly/nested_functions_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/nested_functions_legacy.json @@ -8,7 +8,8 @@ [ 8 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/assembly/slot_offset.json b/test/libsolidity/ASTJSON/assembly/slot_offset.json index 75c22243c..7231747c4 100644 --- a/test/libsolidity/ASTJSON/assembly/slot_offset.json +++ b/test/libsolidity/ASTJSON/assembly/slot_offset.json @@ -8,6 +8,7 @@ ] }, "id": 12, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/assembly/slot_offset_legacy.json b/test/libsolidity/ASTJSON/assembly/slot_offset_legacy.json index 083f8dd52..574c7ad75 100644 --- a/test/libsolidity/ASTJSON/assembly/slot_offset_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/slot_offset_legacy.json @@ -8,7 +8,8 @@ [ 11 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/assembly/stringlit.json b/test/libsolidity/ASTJSON/assembly/stringlit.json index a7a596e0c..7fd0b9b84 100644 --- a/test/libsolidity/ASTJSON/assembly/stringlit.json +++ b/test/libsolidity/ASTJSON/assembly/stringlit.json @@ -8,6 +8,7 @@ ] }, "id": 7, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/assembly/stringlit_legacy.json b/test/libsolidity/ASTJSON/assembly/stringlit_legacy.json index bb7a5c5c3..76c503925 100644 --- a/test/libsolidity/ASTJSON/assembly/stringlit_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/stringlit_legacy.json @@ -8,7 +8,8 @@ [ 6 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/assembly/switch.json b/test/libsolidity/ASTJSON/assembly/switch.json index 854c5b6cd..61b462f1e 100644 --- a/test/libsolidity/ASTJSON/assembly/switch.json +++ b/test/libsolidity/ASTJSON/assembly/switch.json @@ -8,6 +8,7 @@ ] }, "id": 7, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/assembly/switch_default.json b/test/libsolidity/ASTJSON/assembly/switch_default.json index c0bf26438..2f15a82c5 100644 --- a/test/libsolidity/ASTJSON/assembly/switch_default.json +++ b/test/libsolidity/ASTJSON/assembly/switch_default.json @@ -8,6 +8,7 @@ ] }, "id": 7, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/assembly/switch_default_legacy.json b/test/libsolidity/ASTJSON/assembly/switch_default_legacy.json index 2d5caa0fa..18e7c860c 100644 --- a/test/libsolidity/ASTJSON/assembly/switch_default_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/switch_default_legacy.json @@ -8,7 +8,8 @@ [ 6 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/assembly/switch_legacy.json b/test/libsolidity/ASTJSON/assembly/switch_legacy.json index 5b9322f4c..dab33b305 100644 --- a/test/libsolidity/ASTJSON/assembly/switch_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/switch_legacy.json @@ -8,7 +8,8 @@ [ 6 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/assembly/var_access.json b/test/libsolidity/ASTJSON/assembly/var_access.json index 0ef180ced..c44940a28 100644 --- a/test/libsolidity/ASTJSON/assembly/var_access.json +++ b/test/libsolidity/ASTJSON/assembly/var_access.json @@ -8,6 +8,7 @@ ] }, "id": 10, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/assembly/var_access_legacy.json b/test/libsolidity/ASTJSON/assembly/var_access_legacy.json index 21cda71e8..a80a24613 100644 --- a/test/libsolidity/ASTJSON/assembly/var_access_legacy.json +++ b/test/libsolidity/ASTJSON/assembly/var_access_legacy.json @@ -8,7 +8,8 @@ [ 9 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/constructor.json b/test/libsolidity/ASTJSON/constructor.json index 5e6059b29..321d93471 100644 --- a/test/libsolidity/ASTJSON/constructor.json +++ b/test/libsolidity/ASTJSON/constructor.json @@ -8,6 +8,7 @@ ] }, "id": 6, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/constructor_legacy.json b/test/libsolidity/ASTJSON/constructor_legacy.json index 53265f711..9417561a7 100644 --- a/test/libsolidity/ASTJSON/constructor_legacy.json +++ b/test/libsolidity/ASTJSON/constructor_legacy.json @@ -8,7 +8,8 @@ [ 5 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/contract_dep_order.json b/test/libsolidity/ASTJSON/contract_dep_order.json index 6b269800f..b4a93ff75 100644 --- a/test/libsolidity/ASTJSON/contract_dep_order.json +++ b/test/libsolidity/ASTJSON/contract_dep_order.json @@ -24,6 +24,7 @@ ] }, "id": 14, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/contract_dep_order_legacy.json b/test/libsolidity/ASTJSON/contract_dep_order_legacy.json index 11ccbed7a..75ac151e8 100644 --- a/test/libsolidity/ASTJSON/contract_dep_order_legacy.json +++ b/test/libsolidity/ASTJSON/contract_dep_order_legacy.json @@ -24,7 +24,8 @@ [ 13 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/documentation.json b/test/libsolidity/ASTJSON/documentation.json index 8671978b0..782409abf 100644 --- a/test/libsolidity/ASTJSON/documentation.json +++ b/test/libsolidity/ASTJSON/documentation.json @@ -8,6 +8,7 @@ ] }, "id": 3, + "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -48,6 +49,7 @@ ] }, "id": 6, + "license": null, "nodeType": "SourceUnit", "nodes": [ @@ -88,6 +90,7 @@ ] }, "id": 21, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/documentation_legacy.json b/test/libsolidity/ASTJSON/documentation_legacy.json index 90866e7fb..70a4d8cf4 100644 --- a/test/libsolidity/ASTJSON/documentation_legacy.json +++ b/test/libsolidity/ASTJSON/documentation_legacy.json @@ -8,7 +8,8 @@ [ 20 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/enum_value.json b/test/libsolidity/ASTJSON/enum_value.json index 981b54210..bb8e1289b 100644 --- a/test/libsolidity/ASTJSON/enum_value.json +++ b/test/libsolidity/ASTJSON/enum_value.json @@ -8,6 +8,7 @@ ] }, "id": 5, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/enum_value_legacy.json b/test/libsolidity/ASTJSON/enum_value_legacy.json index 0c1c0b8e2..eeff347d7 100644 --- a/test/libsolidity/ASTJSON/enum_value_legacy.json +++ b/test/libsolidity/ASTJSON/enum_value_legacy.json @@ -8,7 +8,8 @@ [ 4 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/event_definition.json b/test/libsolidity/ASTJSON/event_definition.json index e58a6b843..e5c574973 100644 --- a/test/libsolidity/ASTJSON/event_definition.json +++ b/test/libsolidity/ASTJSON/event_definition.json @@ -8,6 +8,7 @@ ] }, "id": 4, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/event_definition_legacy.json b/test/libsolidity/ASTJSON/event_definition_legacy.json index 30dfb7069..330f586ae 100644 --- a/test/libsolidity/ASTJSON/event_definition_legacy.json +++ b/test/libsolidity/ASTJSON/event_definition_legacy.json @@ -8,7 +8,8 @@ [ 3 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/fallback.json b/test/libsolidity/ASTJSON/fallback.json index 128888701..7c83f871f 100644 --- a/test/libsolidity/ASTJSON/fallback.json +++ b/test/libsolidity/ASTJSON/fallback.json @@ -8,6 +8,7 @@ ] }, "id": 6, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/fallback_and_reveice_ether.json b/test/libsolidity/ASTJSON/fallback_and_reveice_ether.json index 353d512f7..801a4e148 100644 --- a/test/libsolidity/ASTJSON/fallback_and_reveice_ether.json +++ b/test/libsolidity/ASTJSON/fallback_and_reveice_ether.json @@ -8,6 +8,7 @@ ] }, "id": 10, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/fallback_and_reveice_ether_legacy.json b/test/libsolidity/ASTJSON/fallback_and_reveice_ether_legacy.json index 7d1aa7ae4..44e02c42d 100644 --- a/test/libsolidity/ASTJSON/fallback_and_reveice_ether_legacy.json +++ b/test/libsolidity/ASTJSON/fallback_and_reveice_ether_legacy.json @@ -8,7 +8,8 @@ [ 9 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/fallback_legacy.json b/test/libsolidity/ASTJSON/fallback_legacy.json index 8c84c57fc..8c81e87d8 100644 --- a/test/libsolidity/ASTJSON/fallback_legacy.json +++ b/test/libsolidity/ASTJSON/fallback_legacy.json @@ -8,7 +8,8 @@ [ 5 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/fallback_payable.json b/test/libsolidity/ASTJSON/fallback_payable.json index 8facda351..fb55b6077 100644 --- a/test/libsolidity/ASTJSON/fallback_payable.json +++ b/test/libsolidity/ASTJSON/fallback_payable.json @@ -8,6 +8,7 @@ ] }, "id": 6, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/fallback_payable_legacy.json b/test/libsolidity/ASTJSON/fallback_payable_legacy.json index 74e4242fd..2bc5a9659 100644 --- a/test/libsolidity/ASTJSON/fallback_payable_legacy.json +++ b/test/libsolidity/ASTJSON/fallback_payable_legacy.json @@ -8,7 +8,8 @@ [ 5 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/function_type.json b/test/libsolidity/ASTJSON/function_type.json index e1e83a316..57f061b39 100644 --- a/test/libsolidity/ASTJSON/function_type.json +++ b/test/libsolidity/ASTJSON/function_type.json @@ -8,6 +8,7 @@ ] }, "id": 18, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/function_type_legacy.json b/test/libsolidity/ASTJSON/function_type_legacy.json index e86eb16a6..799e94bf9 100644 --- a/test/libsolidity/ASTJSON/function_type_legacy.json +++ b/test/libsolidity/ASTJSON/function_type_legacy.json @@ -8,7 +8,8 @@ [ 17 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/global_enum.json b/test/libsolidity/ASTJSON/global_enum.json index 1b0ffe377..876b55ddf 100644 --- a/test/libsolidity/ASTJSON/global_enum.json +++ b/test/libsolidity/ASTJSON/global_enum.json @@ -8,6 +8,7 @@ ] }, "id": 3, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/global_enum_legacy.json b/test/libsolidity/ASTJSON/global_enum_legacy.json index f29649018..aea058345 100644 --- a/test/libsolidity/ASTJSON/global_enum_legacy.json +++ b/test/libsolidity/ASTJSON/global_enum_legacy.json @@ -8,7 +8,8 @@ [ 2 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/global_struct.json b/test/libsolidity/ASTJSON/global_struct.json index 64cf62a53..e1802e03b 100644 --- a/test/libsolidity/ASTJSON/global_struct.json +++ b/test/libsolidity/ASTJSON/global_struct.json @@ -8,6 +8,7 @@ ] }, "id": 4, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/global_struct_legacy.json b/test/libsolidity/ASTJSON/global_struct_legacy.json index ef0f71c37..2670ea5ea 100644 --- a/test/libsolidity/ASTJSON/global_struct_legacy.json +++ b/test/libsolidity/ASTJSON/global_struct_legacy.json @@ -8,7 +8,8 @@ [ 3 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/inheritance_specifier.json b/test/libsolidity/ASTJSON/inheritance_specifier.json index 2a235d1ed..20da9e31c 100644 --- a/test/libsolidity/ASTJSON/inheritance_specifier.json +++ b/test/libsolidity/ASTJSON/inheritance_specifier.json @@ -12,6 +12,7 @@ ] }, "id": 5, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/inheritance_specifier_legacy.json b/test/libsolidity/ASTJSON/inheritance_specifier_legacy.json index a387355b4..b8de3a97b 100644 --- a/test/libsolidity/ASTJSON/inheritance_specifier_legacy.json +++ b/test/libsolidity/ASTJSON/inheritance_specifier_legacy.json @@ -12,7 +12,8 @@ [ 4 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/long_type_name_binary_operation.json b/test/libsolidity/ASTJSON/long_type_name_binary_operation.json index 6e025f5f9..5e13c2bfb 100644 --- a/test/libsolidity/ASTJSON/long_type_name_binary_operation.json +++ b/test/libsolidity/ASTJSON/long_type_name_binary_operation.json @@ -8,6 +8,7 @@ ] }, "id": 12, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json b/test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json index 6ad38d194..c6f7662ea 100644 --- a/test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json +++ b/test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json @@ -8,7 +8,8 @@ [ 11 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/long_type_name_identifier.json b/test/libsolidity/ASTJSON/long_type_name_identifier.json index eddeacd04..417972b45 100644 --- a/test/libsolidity/ASTJSON/long_type_name_identifier.json +++ b/test/libsolidity/ASTJSON/long_type_name_identifier.json @@ -8,6 +8,7 @@ ] }, "id": 16, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json b/test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json index bc90e0d6a..537746abd 100644 --- a/test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json +++ b/test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json @@ -8,7 +8,8 @@ [ 15 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/mappings.json b/test/libsolidity/ASTJSON/mappings.json index 5c24e3a12..8df004d4b 100644 --- a/test/libsolidity/ASTJSON/mappings.json +++ b/test/libsolidity/ASTJSON/mappings.json @@ -8,6 +8,7 @@ ] }, "id": 18, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/mappings_legacy.json b/test/libsolidity/ASTJSON/mappings_legacy.json index 700097b66..49737edee 100644 --- a/test/libsolidity/ASTJSON/mappings_legacy.json +++ b/test/libsolidity/ASTJSON/mappings_legacy.json @@ -8,7 +8,8 @@ [ 17 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/modifier_definition.json b/test/libsolidity/ASTJSON/modifier_definition.json index a3c71159a..c5070f1da 100644 --- a/test/libsolidity/ASTJSON/modifier_definition.json +++ b/test/libsolidity/ASTJSON/modifier_definition.json @@ -8,6 +8,7 @@ ] }, "id": 15, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/modifier_definition_legacy.json b/test/libsolidity/ASTJSON/modifier_definition_legacy.json index 369562171..05876ae3e 100644 --- a/test/libsolidity/ASTJSON/modifier_definition_legacy.json +++ b/test/libsolidity/ASTJSON/modifier_definition_legacy.json @@ -8,7 +8,8 @@ [ 14 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/modifier_invocation.json b/test/libsolidity/ASTJSON/modifier_invocation.json index a3c71159a..c5070f1da 100644 --- a/test/libsolidity/ASTJSON/modifier_invocation.json +++ b/test/libsolidity/ASTJSON/modifier_invocation.json @@ -8,6 +8,7 @@ ] }, "id": 15, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/modifier_invocation_legacy.json b/test/libsolidity/ASTJSON/modifier_invocation_legacy.json index 369562171..05876ae3e 100644 --- a/test/libsolidity/ASTJSON/modifier_invocation_legacy.json +++ b/test/libsolidity/ASTJSON/modifier_invocation_legacy.json @@ -8,7 +8,8 @@ [ 14 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/mutability.json b/test/libsolidity/ASTJSON/mutability.json index 81d668702..3f5d610ed 100644 --- a/test/libsolidity/ASTJSON/mutability.json +++ b/test/libsolidity/ASTJSON/mutability.json @@ -8,6 +8,7 @@ ] }, "id": 11, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/mutability_legacy.json b/test/libsolidity/ASTJSON/mutability_legacy.json index 98f28f636..387ebc267 100644 --- a/test/libsolidity/ASTJSON/mutability_legacy.json +++ b/test/libsolidity/ASTJSON/mutability_legacy.json @@ -8,7 +8,8 @@ [ 10 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/non_utf8.json b/test/libsolidity/ASTJSON/non_utf8.json index c925389d7..d716d91c2 100644 --- a/test/libsolidity/ASTJSON/non_utf8.json +++ b/test/libsolidity/ASTJSON/non_utf8.json @@ -8,6 +8,7 @@ ] }, "id": 9, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/non_utf8_legacy.json b/test/libsolidity/ASTJSON/non_utf8_legacy.json index d3a212b0c..d49d2013d 100644 --- a/test/libsolidity/ASTJSON/non_utf8_legacy.json +++ b/test/libsolidity/ASTJSON/non_utf8_legacy.json @@ -8,7 +8,8 @@ [ 8 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/override.json b/test/libsolidity/ASTJSON/override.json index cb3d0268b..3e5a8c9da 100644 --- a/test/libsolidity/ASTJSON/override.json +++ b/test/libsolidity/ASTJSON/override.json @@ -16,6 +16,7 @@ ] }, "id": 32, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/override_legacy.json b/test/libsolidity/ASTJSON/override_legacy.json index a9bece4ac..23cf18b2b 100644 --- a/test/libsolidity/ASTJSON/override_legacy.json +++ b/test/libsolidity/ASTJSON/override_legacy.json @@ -16,7 +16,8 @@ [ 31 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/placeholder_statement.json b/test/libsolidity/ASTJSON/placeholder_statement.json index 4b37ba417..3be70c463 100644 --- a/test/libsolidity/ASTJSON/placeholder_statement.json +++ b/test/libsolidity/ASTJSON/placeholder_statement.json @@ -8,6 +8,7 @@ ] }, "id": 6, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/placeholder_statement_legacy.json b/test/libsolidity/ASTJSON/placeholder_statement_legacy.json index f478862f4..7ab1f4879 100644 --- a/test/libsolidity/ASTJSON/placeholder_statement_legacy.json +++ b/test/libsolidity/ASTJSON/placeholder_statement_legacy.json @@ -8,7 +8,8 @@ [ 5 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/receive_ether.json b/test/libsolidity/ASTJSON/receive_ether.json index f861e4271..a837dae15 100644 --- a/test/libsolidity/ASTJSON/receive_ether.json +++ b/test/libsolidity/ASTJSON/receive_ether.json @@ -8,6 +8,7 @@ ] }, "id": 6, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/receive_ether_legacy.json b/test/libsolidity/ASTJSON/receive_ether_legacy.json index e8f025234..964bd991b 100644 --- a/test/libsolidity/ASTJSON/receive_ether_legacy.json +++ b/test/libsolidity/ASTJSON/receive_ether_legacy.json @@ -8,7 +8,8 @@ [ 5 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/short_type_name.json b/test/libsolidity/ASTJSON/short_type_name.json index 75defa9ab..54c9b99ea 100644 --- a/test/libsolidity/ASTJSON/short_type_name.json +++ b/test/libsolidity/ASTJSON/short_type_name.json @@ -8,6 +8,7 @@ ] }, "id": 12, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/short_type_name_legacy.json b/test/libsolidity/ASTJSON/short_type_name_legacy.json index 0d428bcb1..c813bcdf4 100644 --- a/test/libsolidity/ASTJSON/short_type_name_legacy.json +++ b/test/libsolidity/ASTJSON/short_type_name_legacy.json @@ -8,7 +8,8 @@ [ 11 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/short_type_name_ref.json b/test/libsolidity/ASTJSON/short_type_name_ref.json index 46096a914..1a22f1f24 100644 --- a/test/libsolidity/ASTJSON/short_type_name_ref.json +++ b/test/libsolidity/ASTJSON/short_type_name_ref.json @@ -8,6 +8,7 @@ ] }, "id": 13, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/short_type_name_ref_legacy.json b/test/libsolidity/ASTJSON/short_type_name_ref_legacy.json index b1f4b88d2..086a21584 100644 --- a/test/libsolidity/ASTJSON/short_type_name_ref_legacy.json +++ b/test/libsolidity/ASTJSON/short_type_name_ref_legacy.json @@ -8,7 +8,8 @@ [ 12 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/smoke.json b/test/libsolidity/ASTJSON/smoke.json index 9aa2eda01..d72018e09 100644 --- a/test/libsolidity/ASTJSON/smoke.json +++ b/test/libsolidity/ASTJSON/smoke.json @@ -8,6 +8,7 @@ ] }, "id": 2, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/smoke_legacy.json b/test/libsolidity/ASTJSON/smoke_legacy.json index a3254c4e8..da56b0e77 100644 --- a/test/libsolidity/ASTJSON/smoke_legacy.json +++ b/test/libsolidity/ASTJSON/smoke_legacy.json @@ -8,7 +8,8 @@ [ 1 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/source_location.json b/test/libsolidity/ASTJSON/source_location.json index 54bffe378..b0b81d8f8 100644 --- a/test/libsolidity/ASTJSON/source_location.json +++ b/test/libsolidity/ASTJSON/source_location.json @@ -8,6 +8,7 @@ ] }, "id": 12, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/source_location_legacy.json b/test/libsolidity/ASTJSON/source_location_legacy.json index dbd578dd2..42f81ad16 100644 --- a/test/libsolidity/ASTJSON/source_location_legacy.json +++ b/test/libsolidity/ASTJSON/source_location_legacy.json @@ -8,7 +8,8 @@ [ 11 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/two_base_functions.json b/test/libsolidity/ASTJSON/two_base_functions.json index 7e6e15395..18412bbc7 100644 --- a/test/libsolidity/ASTJSON/two_base_functions.json +++ b/test/libsolidity/ASTJSON/two_base_functions.json @@ -16,6 +16,7 @@ ] }, "id": 23, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/two_base_functions_legacy.json b/test/libsolidity/ASTJSON/two_base_functions_legacy.json index bc9e4545c..b58008b75 100644 --- a/test/libsolidity/ASTJSON/two_base_functions_legacy.json +++ b/test/libsolidity/ASTJSON/two_base_functions_legacy.json @@ -16,7 +16,8 @@ [ 22 ] - } + }, + "license": null }, "children": [ diff --git a/test/libsolidity/ASTJSON/using_for_directive.json b/test/libsolidity/ASTJSON/using_for_directive.json index 9b973141c..66674f589 100644 --- a/test/libsolidity/ASTJSON/using_for_directive.json +++ b/test/libsolidity/ASTJSON/using_for_directive.json @@ -12,6 +12,7 @@ ] }, "id": 6, + "license": null, "nodeType": "SourceUnit", "nodes": [ diff --git a/test/libsolidity/ASTJSON/using_for_directive_legacy.json b/test/libsolidity/ASTJSON/using_for_directive_legacy.json index 13df0d5c2..280e9be4a 100644 --- a/test/libsolidity/ASTJSON/using_for_directive_legacy.json +++ b/test/libsolidity/ASTJSON/using_for_directive_legacy.json @@ -12,7 +12,8 @@ [ 1 ] - } + }, + "license": null }, "children": [ From af44c05f1abcad1c0c8a47a637e9286487c97690 Mon Sep 17 00:00:00 2001 From: Alexander Arlt Date: Tue, 12 May 2020 20:52:33 -0500 Subject: [PATCH 07/15] Add new test. --- test/libsolidity/ASTJSON/license.json | 35 +++++++++++++ test/libsolidity/ASTJSON/license.sol | 4 ++ test/libsolidity/ASTJSON/license_legacy.json | 50 +++++++++++++++++++ test/libsolidity/StandardCompiler.cpp | 40 +++++++++++++++ .../syntaxTests/license/license_double.sol | 5 ++ .../syntaxTests/license/license_missing.sol | 1 + 6 files changed, 135 insertions(+) create mode 100644 test/libsolidity/ASTJSON/license.json create mode 100644 test/libsolidity/ASTJSON/license.sol create mode 100644 test/libsolidity/ASTJSON/license_legacy.json create mode 100644 test/libsolidity/syntaxTests/license/license_double.sol create mode 100644 test/libsolidity/syntaxTests/license/license_missing.sol diff --git a/test/libsolidity/ASTJSON/license.json b/test/libsolidity/ASTJSON/license.json new file mode 100644 index 000000000..e8c6616a3 --- /dev/null +++ b/test/libsolidity/ASTJSON/license.json @@ -0,0 +1,35 @@ +{ + "absolutePath": "a", + "exportedSymbols": + { + "C": + [ + 1 + ] + }, + "id": 2, + "license": "GPL-3.0", + "nodeType": "SourceUnit", + "nodes": + [ + { + "abstract": false, + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 1, + "linearizedBaseContracts": + [ + 1 + ], + "name": "C", + "nodeType": "ContractDefinition", + "nodes": [], + "scope": 2, + "src": "36:13:1" + } + ], + "src": "36:14:1" +} diff --git a/test/libsolidity/ASTJSON/license.sol b/test/libsolidity/ASTJSON/license.sol new file mode 100644 index 000000000..92ffb8fa6 --- /dev/null +++ b/test/libsolidity/ASTJSON/license.sol @@ -0,0 +1,4 @@ +// SPDX-License-Identifier: GPL-3.0 +contract C {} + +// ---- diff --git a/test/libsolidity/ASTJSON/license_legacy.json b/test/libsolidity/ASTJSON/license_legacy.json new file mode 100644 index 000000000..2f1405b62 --- /dev/null +++ b/test/libsolidity/ASTJSON/license_legacy.json @@ -0,0 +1,50 @@ +{ + "attributes": + { + "absolutePath": "a", + "exportedSymbols": + { + "C": + [ + 1 + ] + }, + "license": "GPL-3.0" + }, + "children": + [ + { + "attributes": + { + "abstract": false, + "baseContracts": + [ + null + ], + "contractDependencies": + [ + null + ], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "linearizedBaseContracts": + [ + 1 + ], + "name": "C", + "nodes": + [ + null + ], + "scope": 2 + }, + "id": 1, + "name": "ContractDefinition", + "src": "36:13:1" + } + ], + "id": 2, + "name": "SourceUnit", + "src": "36:14:1" +} diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp index 288bba3fe..5f4a4e3d4 100644 --- a/test/libsolidity/StandardCompiler.cpp +++ b/test/libsolidity/StandardCompiler.cpp @@ -1105,6 +1105,46 @@ BOOST_AUTO_TEST_CASE(metadata_without_compilation) BOOST_CHECK(solidity::test::isValidMetadata(contract["metadata"].asString())); } + +BOOST_AUTO_TEST_CASE(license_in_metadata) +{ + string const input = R"( + { + "language": "Solidity", + "sources": { + "fileA": { "content": "import \"fileB\"; contract A { } // SPDX-License-Identifier: GPL-3.0 \n" }, + "fileB": { "content": "import \"fileC\"; /* SPDX-License-Identifier: MIT */ contract B { }" }, + "fileC": { "content": "import \"fileD\"; /* SPDX-License-Identifier: MIT AND GPL-3.0 */ contract C { }" }, + "fileD": { "content": "// SPDX-License-Identifier: (GPL-3.0+ OR MIT) AND MIT \n import \"fileE\"; contract D { }" }, + "fileE": { "content": "import \"fileF\"; /// SPDX-License-Identifier: MIT \n contract E { }" }, + "fileF": { "content": "/*\n * SPDX-License-Identifier: MIT\n */ contract F { }" } + }, + "settings": { + "outputSelection": { + "fileA": { + "*": [ "metadata" ] + } + } + } + } + )"; + Json::Value result = compile(input); + BOOST_CHECK(containsAtMostWarnings(result)); + Json::Value contract = getContractResult(result, "fileA", "A"); + BOOST_CHECK(contract.isObject()); + BOOST_CHECK(contract["metadata"].isString()); + Json::Value metadata; + BOOST_REQUIRE(util::jsonParseStrict(contract["metadata"].asString(), metadata)); + BOOST_CHECK_EQUAL(metadata["sources"]["fileA"]["license"], "GPL-3.0"); + BOOST_CHECK_EQUAL(metadata["sources"]["fileB"]["license"], "MIT"); + BOOST_CHECK_EQUAL(metadata["sources"]["fileC"]["license"], "MIT AND GPL-3.0"); + BOOST_CHECK_EQUAL(metadata["sources"]["fileD"]["license"], "(GPL-3.0+ OR MIT) AND MIT"); + // This is actually part of the docstring, but still picked up + // because the source location of the contract does not cover the docstring. + BOOST_CHECK_EQUAL(metadata["sources"]["fileE"]["license"], "MIT"); + BOOST_CHECK_EQUAL(metadata["sources"]["fileF"]["license"], "MIT"); +} + BOOST_AUTO_TEST_CASE(common_pattern) { char const* input = R"( diff --git a/test/libsolidity/syntaxTests/license/license_double.sol b/test/libsolidity/syntaxTests/license/license_double.sol new file mode 100644 index 000000000..47d7eae1b --- /dev/null +++ b/test/libsolidity/syntaxTests/license/license_double.sol @@ -0,0 +1,5 @@ +// SPDX-License-Identifier: GPL-3.0 +contract C {} +// SPDX-License-Identifier: MIT +// ---- +// ParserError: Multiple SPDX license identifiers found in source file. Use "AND" or "OR" to combine multiple licenses. Please see https://spdx.org for more information. diff --git a/test/libsolidity/syntaxTests/license/license_missing.sol b/test/libsolidity/syntaxTests/license/license_missing.sol new file mode 100644 index 000000000..2dde0d209 --- /dev/null +++ b/test/libsolidity/syntaxTests/license/license_missing.sol @@ -0,0 +1 @@ +contract C {} From 97296d86225ee9f1069a28616ce6869351e06fbf Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Wed, 13 May 2020 10:25:46 +0200 Subject: [PATCH 08/15] Allow ABI encoding for array slices without explicit casts. --- Changelog.md | 1 + libsolidity/ast/Types.cpp | 15 ++++- libsolidity/ast/Types.h | 1 + libsolidity/codegen/ABIFunctions.cpp | 46 +++++++++----- libsolidity/codegen/CompilerUtils.cpp | 41 +++++++++--- .../abi_encode_calldata_slice.sol | 62 ++++++++++++++++++ .../abi_encode_calldata_slice.sol | 63 +++++++++++++++++++ .../array/slice/assign_to_storage.sol | 8 +++ .../array/slice/calldata_dynamic_encode.sol | 1 - 9 files changed, 214 insertions(+), 24 deletions(-) create mode 100644 test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol create mode 100644 test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol create mode 100644 test/libsolidity/syntaxTests/array/slice/assign_to_storage.sol diff --git a/Changelog.md b/Changelog.md index 8d7ff006a..09f4acff3 100644 --- a/Changelog.md +++ b/Changelog.md @@ -11,6 +11,7 @@ Language Features: Compiler Features: * Commandline Interface: Don't ignore `--yul-optimizations` in assembly mode. + * Allow using abi encoding functions for calldata array slices without explicit casts. diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index c9d40a1ce..b19ab4c4b 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -330,7 +330,7 @@ TypePointer Type::fullEncodingType(bool _inLibraryCall, bool _encoderV2, bool) c // Structs are fine in the following circumstances: // - ABIv2 or, // - storage struct for a library - if (_inLibraryCall && encodingType->dataStoredIn(DataLocation::Storage)) + if (_inLibraryCall && encodingType && encodingType->dataStoredIn(DataLocation::Storage)) return encodingType; TypePointer baseType = encodingType; while (auto const* arrayType = dynamic_cast(baseType)) @@ -1971,6 +1971,19 @@ string ArraySliceType::toString(bool _short) const return m_arrayType.toString(_short) + " slice"; } +TypePointer ArraySliceType::mobileType() const +{ + if ( + m_arrayType.dataStoredIn(DataLocation::CallData) && + m_arrayType.isDynamicallySized() && + !m_arrayType.baseType()->isDynamicallyEncoded() + ) + return &m_arrayType; + else + return this; +} + + std::vector> ArraySliceType::makeStackItems() const { return {{"offset", TypeProvider::uint256()}, {"length", TypeProvider::uint256()}}; diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h index d549d4f24..11e948f26 100644 --- a/libsolidity/ast/Types.h +++ b/libsolidity/ast/Types.h @@ -831,6 +831,7 @@ public: bool isDynamicallyEncoded() const override { return true; } bool canLiveOutsideStorage() const override { return m_arrayType.canLiveOutsideStorage(); } std::string toString(bool _short) const override; + TypePointer mobileType() const override; BoolResult validForLocation(DataLocation _loc) const override { return m_arrayType.validForLocation(_loc); } diff --git a/libsolidity/codegen/ABIFunctions.cpp b/libsolidity/codegen/ABIFunctions.cpp index 5018346b4..189fba165 100644 --- a/libsolidity/codegen/ABIFunctions.cpp +++ b/libsolidity/codegen/ABIFunctions.cpp @@ -279,31 +279,47 @@ string ABIFunctions::abiEncodingFunction( return abiEncodingFunctionStringLiteral(_from, to, _options); else if (auto toArray = dynamic_cast(&to)) { - solAssert(_from.category() == Type::Category::Array, ""); - solAssert(to.dataStoredIn(DataLocation::Memory), ""); - ArrayType const& fromArray = dynamic_cast(_from); + ArrayType const* fromArray = nullptr; + switch (_from.category()) + { + case Type::Category::Array: + fromArray = dynamic_cast(&_from); + break; + case Type::Category::ArraySlice: + fromArray = &dynamic_cast(&_from)->arrayType(); + solAssert( + fromArray->dataStoredIn(DataLocation::CallData) && + fromArray->isDynamicallySized() && + !fromArray->baseType()->isDynamicallyEncoded(), + "" + ); + break; + default: + solAssert(false, ""); + break; + } - switch (fromArray.location()) + switch (fromArray->location()) { case DataLocation::CallData: if ( - fromArray.isByteArray() || - *fromArray.baseType() == *TypeProvider::uint256() || - *fromArray.baseType() == FixedBytesType(32) + fromArray->isByteArray() || + *fromArray->baseType() == *TypeProvider::uint256() || + *fromArray->baseType() == FixedBytesType(32) ) - return abiEncodingFunctionCalldataArrayWithoutCleanup(fromArray, *toArray, _options); + return abiEncodingFunctionCalldataArrayWithoutCleanup(*fromArray, *toArray, _options); else - return abiEncodingFunctionSimpleArray(fromArray, *toArray, _options); + return abiEncodingFunctionSimpleArray(*fromArray, *toArray, _options); case DataLocation::Memory: - if (fromArray.isByteArray()) - return abiEncodingFunctionMemoryByteArray(fromArray, *toArray, _options); + if (fromArray->isByteArray()) + return abiEncodingFunctionMemoryByteArray(*fromArray, *toArray, _options); else - return abiEncodingFunctionSimpleArray(fromArray, *toArray, _options); + return abiEncodingFunctionSimpleArray(*fromArray, *toArray, _options); case DataLocation::Storage: - if (fromArray.baseType()->storageBytes() <= 16) - return abiEncodingFunctionCompactStorageArray(fromArray, *toArray, _options); + if (fromArray->baseType()->storageBytes() <= 16) + return abiEncodingFunctionCompactStorageArray(*fromArray, *toArray, _options); else - return abiEncodingFunctionSimpleArray(fromArray, *toArray, _options); + return abiEncodingFunctionSimpleArray(*fromArray, *toArray, _options); default: solAssert(false, ""); } diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp index feae52caa..8bf0a21e2 100644 --- a/libsolidity/codegen/CompilerUtils.cpp +++ b/libsolidity/codegen/CompilerUtils.cpp @@ -480,6 +480,16 @@ void CompilerUtils::encodeToMemory( convertType(*_givenTypes[i], *targetType, true); if (auto arrayType = dynamic_cast(type)) ArrayUtils(m_context).copyArrayToMemory(*arrayType, _padToWordBoundaries); + else if (auto arraySliceType = dynamic_cast(type)) + { + solAssert( + arraySliceType->dataStoredIn(DataLocation::CallData) && + arraySliceType->isDynamicallySized() && + !arraySliceType->arrayType().baseType()->isDynamicallyEncoded(), + "" + ); + ArrayUtils(m_context).copyArrayToMemory(arraySliceType->arrayType(), _padToWordBoundaries); + } else storeInMemoryDynamic(*type, _padToWordBoundaries); } @@ -516,22 +526,39 @@ void CompilerUtils::encodeToMemory( } else { - solAssert(_givenTypes[i]->category() == Type::Category::Array, "Unknown dynamic type."); - auto const& arrayType = dynamic_cast(*_givenTypes[i]); + ArrayType const* arrayType = nullptr; + switch (_givenTypes[i]->category()) + { + case Type::Category::Array: + arrayType = dynamic_cast(_givenTypes[i]); + break; + case Type::Category::ArraySlice: + arrayType = &dynamic_cast(_givenTypes[i])->arrayType(); + solAssert( + arrayType->isDynamicallySized() && + arrayType->dataStoredIn(DataLocation::CallData) && + !arrayType->baseType()->isDynamicallyEncoded(), + "" + ); + break; + default: + solAssert(false, "Unknown dynamic type."); + break; + } // now copy the array - copyToStackTop(argSize - stackPos + dynPointers + 2, arrayType.sizeOnStack()); + copyToStackTop(argSize - stackPos + dynPointers + 2, arrayType->sizeOnStack()); // stack: ... // copy length to memory - m_context << dupInstruction(1 + arrayType.sizeOnStack()); - ArrayUtils(m_context).retrieveLength(arrayType, 1); + m_context << dupInstruction(1 + arrayType->sizeOnStack()); + ArrayUtils(m_context).retrieveLength(*arrayType, 1); // stack: ... storeInMemoryDynamic(*TypeProvider::uint256(), true); // stack: ... // copy the new memory pointer - m_context << swapInstruction(arrayType.sizeOnStack() + 1) << Instruction::POP; + m_context << swapInstruction(arrayType->sizeOnStack() + 1) << Instruction::POP; // stack: ... // copy data part - ArrayUtils(m_context).copyArrayToMemory(arrayType, _padToWordBoundaries); + ArrayUtils(m_context).copyArrayToMemory(*arrayType, _padToWordBoundaries); // stack: ... } diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol new file mode 100644 index 000000000..917704e53 --- /dev/null +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol @@ -0,0 +1,62 @@ +contract C { + function enc_packed_bytes(bytes calldata data, uint256 start, uint256 end) external returns (bytes memory) { + return abi.encodePacked(data[start:end]); + } + function enc_packed_bytes_reference(bytes calldata data, uint256 start, uint256 end) external returns (bytes memory) { + return abi.encodePacked(bytes(data[start:end])); + } + + function enc_bytes(bytes calldata data, uint256 start, uint256 end) external returns (bytes memory) { + return abi.encode(data[start:end]); + } + function enc_bytes_reference(bytes calldata data, uint256 start, uint256 end) external returns (bytes memory) { + return abi.encode(bytes(data[start:end])); + } + + function enc_uint256(uint256[] calldata x, uint256 start, uint256 end) external returns (bytes memory) { + return abi.encode(x[start:end]); + } + function enc_uint256_reference(uint256[] calldata x, uint256 start, uint256 end) external returns (bytes memory) { + return abi.encode(x[start:end]); + } + + function enc_packed_uint256(uint256[] calldata x, uint256 start, uint256 end) external returns (bytes memory) { + return abi.encodePacked(x[start:end]); + } + function enc_packed_uint256_reference(uint256[] calldata x, uint256 start, uint256 end) external returns (bytes memory) { + return abi.encodePacked(x[start:end]); + } + + function compare(bytes memory x, bytes memory y) internal { + assert(x.length == y.length); + for (uint i = 0; i < x.length; ++i) + assert(x[i] == y[i]); + } + + function test_bytes() public { + bytes memory test = new bytes(3); + test[0] = 0x41; test[1] = 0x42; test[2] = 0x42; + for (uint i = 0; i < test.length; i++) + for (uint j = i; j <= test.length; j++) + { + compare(this.enc_packed_bytes(test, i, j), this.enc_packed_bytes_reference(test, i, j)); + compare(this.enc_bytes(test, i, j), this.enc_bytes_reference(test, i, j)); + } + } + + function test_uint256() public { + uint256[] memory test = new uint256[](3); + test[0] = 0x41; test[1] = 0x42; test[2] = 0x42; + for (uint i = 0; i < test.length; i++) + for (uint j = i; j <= test.length; j++) + { + compare(this.enc_packed_uint256(test, i, j), this.enc_packed_uint256_reference(test, i, j)); + compare(this.enc_uint256(test, i, j), this.enc_uint256_reference(test, i, j)); + } + } +} +// ==== +// EVMVersion: >homestead +// ---- +// test_bytes() -> +// test_uint256() -> diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol new file mode 100644 index 000000000..1f1444672 --- /dev/null +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol @@ -0,0 +1,63 @@ +pragma experimental ABIEncoderV2; +contract C { + function enc_packed_bytes(bytes calldata data, uint256 start, uint256 end) external returns (bytes memory) { + return abi.encodePacked(data[start:end]); + } + function enc_packed_bytes_reference(bytes calldata data, uint256 start, uint256 end) external returns (bytes memory) { + return abi.encodePacked(bytes(data[start:end])); + } + + function enc_bytes(bytes calldata data, uint256 start, uint256 end) external returns (bytes memory) { + return abi.encode(data[start:end]); + } + function enc_bytes_reference(bytes calldata data, uint256 start, uint256 end) external returns (bytes memory) { + return abi.encode(bytes(data[start:end])); + } + + function enc_uint256(uint256[] calldata x, uint256 start, uint256 end) external returns (bytes memory) { + return abi.encode(x[start:end]); + } + function enc_uint256_reference(uint256[] calldata x, uint256 start, uint256 end) external returns (bytes memory) { + return abi.encode(x[start:end]); + } + + function enc_packed_uint256(uint256[] calldata x, uint256 start, uint256 end) external returns (bytes memory) { + return abi.encodePacked(x[start:end]); + } + function enc_packed_uint256_reference(uint256[] calldata x, uint256 start, uint256 end) external returns (bytes memory) { + return abi.encodePacked(x[start:end]); + } + + function compare(bytes memory x, bytes memory y) internal { + assert(x.length == y.length); + for (uint i = 0; i < x.length; ++i) + assert(x[i] == y[i]); + } + + function test_bytes() public { + bytes memory test = new bytes(3); + test[0] = 0x41; test[1] = 0x42; test[2] = 0x42; + for (uint i = 0; i < test.length; i++) + for (uint j = i; j <= test.length; j++) + { + compare(this.enc_packed_bytes(test, i, j), this.enc_packed_bytes_reference(test, i, j)); + compare(this.enc_bytes(test, i, j), this.enc_bytes_reference(test, i, j)); + } + } + + function test_uint256() public { + uint256[] memory test = new uint256[](3); + test[0] = 0x41; test[1] = 0x42; test[2] = 0x42; + for (uint i = 0; i < test.length; i++) + for (uint j = i; j <= test.length; j++) + { + compare(this.enc_packed_uint256(test, i, j), this.enc_packed_uint256_reference(test, i, j)); + compare(this.enc_uint256(test, i, j), this.enc_uint256_reference(test, i, j)); + } + } +} +// ==== +// EVMVersion: >homestead +// ---- +// test_bytes() -> +// test_uint256() -> diff --git a/test/libsolidity/syntaxTests/array/slice/assign_to_storage.sol b/test/libsolidity/syntaxTests/array/slice/assign_to_storage.sol new file mode 100644 index 000000000..7b443949a --- /dev/null +++ b/test/libsolidity/syntaxTests/array/slice/assign_to_storage.sol @@ -0,0 +1,8 @@ +contract c { + bytes public b; + function f() public { + b = msg.data[:]; + } +} +// ---- +// TypeError: (63-74): Type bytes calldata slice is not implicitly convertible to expected type bytes storage ref. diff --git a/test/libsolidity/syntaxTests/array/slice/calldata_dynamic_encode.sol b/test/libsolidity/syntaxTests/array/slice/calldata_dynamic_encode.sol index a31e5ab85..de90b0f75 100644 --- a/test/libsolidity/syntaxTests/array/slice/calldata_dynamic_encode.sol +++ b/test/libsolidity/syntaxTests/array/slice/calldata_dynamic_encode.sol @@ -4,4 +4,3 @@ contract C { } } // ---- -// TypeError: (85-91): This type cannot be encoded. From 0148525aeece160d2898bf185ba1fc136d3b04f9 Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 13 May 2020 16:53:54 +0200 Subject: [PATCH 09/15] Documentation changes. --- docs/introduction-to-smart-contracts.rst | 8 ++++-- docs/layout-of-source-files.rst | 32 ++++++++++++++++++++++++ docs/metadata.rst | 6 ++++- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/docs/introduction-to-smart-contracts.rst b/docs/introduction-to-smart-contracts.rst index e3e38b92c..9bba24c2f 100644 --- a/docs/introduction-to-smart-contracts.rst +++ b/docs/introduction-to-smart-contracts.rst @@ -31,8 +31,12 @@ Storage Example } } -The first line tells you that the source code is written for -Solidity version 0.4.0, or a newer version of the language up to, but not including version 0.7.0. +The first line tells you that the source code is licensed under the +GPL version 3.0. Machine-readable license specifiers are important +in a setting where publishing the source code is the default. + +The next line specifies that the source code is written for +Solidity version 0.4.16, or a newer version of the language up to, but not including version 0.7.0. This is to ensure that the contract is not compilable with a new (breaking) compiler version, where it could behave differently. :ref:`Pragmas` are common instructions for compilers about how to treat the source code (e.g. `pragma once `_). diff --git a/docs/layout-of-source-files.rst b/docs/layout-of-source-files.rst index a2629319b..f817f04ff 100644 --- a/docs/layout-of-source-files.rst +++ b/docs/layout-of-source-files.rst @@ -7,6 +7,38 @@ Source files can contain an arbitrary number of :ref:`pragma directives` and :ref:`struct` and :ref:`enum` definitions. +.. index:: ! license, spdx + +SPDX License Identifier +======================= + +Trust in smart contract can be better established if their source code +is available. Since making source code available always touches on legal problems +with regards to copyright, the Solidity compiler encouranges the use +of machine-readable `SPDX license identifiers `_. +Every source file should start with a comment indicating its license: + +``// SPDX-License-Identifier: MIT`` + +The compiler does not validate that the license is part of the +`list allowed by SPDX `_, but +it does include the supplied string in the `bytecode metadata `_. + +If you do not want to specify a license or if the source code is +not open-source, please use the special value ``UNLICENSED``. + +Supplying this comment of course does not free you from other +obligations related to licensing like having to mention +a specific license header in each source file or the +original copyright holder. + +The comment is recognized by the compiler anywhere in the file at the +file level, but it is recommended to put it at the top of the file. + +More information about how to use SPDX license identifiers +can be found at the `SPDX website `_. + + .. index:: ! pragma .. _pragma: diff --git a/docs/metadata.rst b/docs/metadata.rst index 96a02c43a..240814adc 100644 --- a/docs/metadata.rst +++ b/docs/metadata.rst @@ -1,3 +1,5 @@ +.. _metadata: + ################# Contract Metadata ################# @@ -54,7 +56,9 @@ explanatory purposes. // Required (unless "content" is used, see below): Sorted URL(s) // to the source file, protocol is more or less arbitrary, but a // Swarm URL is recommended - "urls": [ "bzzr://56ab..." ] + "urls": [ "bzzr://56ab..." ], + // Optional: SPDX license identifier as given in the source file + "license": "MIT" }, "destructible": { // Required: keccak256 hash of the source file From bcc4bbcad77aee74936652ebb565b332dc94d5e7 Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 13 May 2020 17:41:56 +0200 Subject: [PATCH 10/15] Update test extraction script to recognize license identifier. --- scripts/isolate_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/isolate_tests.py b/scripts/isolate_tests.py index 9dea81aa5..768f94801 100755 --- a/scripts/isolate_tests.py +++ b/scripts/isolate_tests.py @@ -52,7 +52,7 @@ def extract_docs_cases(path): if inside: extractedLines[-1] += l + '\n' - codeStart = "(pragma solidity|contract.*{|library.*{|interface.*{)" + codeStart = "(// SPDX-License-Identifier:|pragma solidity|contract.*{|library.*{|interface.*{)" # Filter all tests that do not contain Solidity or are intended incorrectly. for lines in extractedLines: From d33b67b3c29108e4375afbc07a9b59e1d92c71f5 Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 13 May 2020 17:45:58 +0200 Subject: [PATCH 11/15] Add license tags to documentation snippets. --- docs/050-breaking-changes.rst | 6 ++++++ docs/abi-spec.rst | 3 +++ docs/assembly.rst | 3 +++ docs/common-patterns.rst | 4 ++++ docs/contracts/abstract-contracts.rst | 2 ++ docs/contracts/constant-state-variables.rst | 1 + docs/contracts/creating-contracts.rst | 1 + docs/contracts/events.rst | 2 ++ docs/contracts/function-modifiers.rst | 1 + docs/contracts/functions.rst | 10 ++++++++++ docs/contracts/inheritance.rst | 13 +++++++++++++ docs/contracts/interfaces.rst | 2 ++ docs/contracts/libraries.rst | 3 +++ docs/contracts/using-for.rst | 2 ++ docs/contracts/visibility-and-getters.rst | 6 ++++++ docs/control-structures.rst | 14 ++++++++++++++ docs/examples/blind-auction.rst | 2 ++ docs/examples/micropayment.rst | 2 ++ docs/examples/modular.rst | 1 + docs/examples/safe-remote.rst | 1 + docs/examples/voting.rst | 1 + docs/internals/layout_in_storage.rst | 2 ++ docs/introduction-to-smart-contracts.rst | 2 ++ docs/layout-of-source-files.rst | 1 + docs/natspec-format.rst | 1 + docs/security-considerations.rst | 8 ++++++++ docs/structure-of-a-contract.rst | 6 ++++++ docs/style-guide.rst | 16 ++++++++++++++++ docs/types/mapping-types.rst | 3 +++ docs/types/operators.rst | 1 + docs/types/reference-types.rst | 7 +++++++ docs/types/value-types.rst | 4 ++++ docs/using-the-compiler.rst | 2 ++ 33 files changed, 133 insertions(+) diff --git a/docs/050-breaking-changes.rst b/docs/050-breaking-changes.rst index 9461cb6bd..68d917f9f 100644 --- a/docs/050-breaking-changes.rst +++ b/docs/050-breaking-changes.rst @@ -292,6 +292,7 @@ Consider you have the following pre-0.5.0 contract already deployed: :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.4.25; // This will report a warning until version 0.4.25 of the compiler // This will not compile after 0.5.0 @@ -309,6 +310,7 @@ This will no longer compile with Solidity v0.5.0. However, you can define a comp :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; interface OldContract { function someOldFunction(uint8 a) external; @@ -326,6 +328,7 @@ Given the interface defined above, you can now easily use the already deployed p :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; interface OldContract { @@ -347,6 +350,7 @@ commandline compiler for linking): :: // This will not compile after 0.6.0 + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.5.99; library OldLibrary { @@ -370,6 +374,7 @@ Old version: :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.4.25; // This will not compile after 0.5.0 @@ -432,6 +437,7 @@ New version: :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.5.99; // This will not compile after 0.6.0 diff --git a/docs/abi-spec.rst b/docs/abi-spec.rst index ec31654dd..1d3e8efd0 100644 --- a/docs/abi-spec.rst +++ b/docs/abi-spec.rst @@ -232,6 +232,7 @@ Given the contract: :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.16 <0.7.0; contract Foo { @@ -535,6 +536,7 @@ For example, :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; @@ -583,6 +585,7 @@ As an example, the code :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.19 <0.7.0; pragma experimental ABIEncoderV2; diff --git a/docs/assembly.rst b/docs/assembly.rst index 19e4449e6..c42e9d70d 100644 --- a/docs/assembly.rst +++ b/docs/assembly.rst @@ -41,6 +41,7 @@ without a compiler change. .. code:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.16 <0.7.0; library GetCode { @@ -66,6 +67,7 @@ efficient code, for example: .. code:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.16 <0.7.0; @@ -136,6 +138,7 @@ Local Solidity variables are available for assignments, for example: .. code:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.16 <0.7.0; contract C { diff --git a/docs/common-patterns.rst b/docs/common-patterns.rst index ab25cb4b9..ad33c52fc 100644 --- a/docs/common-patterns.rst +++ b/docs/common-patterns.rst @@ -27,6 +27,7 @@ you receive the funds of the person who is now the richest. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; contract WithdrawalContract { @@ -60,6 +61,7 @@ This is as opposed to the more intuitive sending pattern: :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; contract SendContract { @@ -121,6 +123,7 @@ restrictions highly readable. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.22 <0.7.0; contract AccessRestriction { @@ -273,6 +276,7 @@ function finishes. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.22 <0.7.0; contract StateMachine { diff --git a/docs/contracts/abstract-contracts.rst b/docs/contracts/abstract-contracts.rst index 4571f45b2..908fa5072 100644 --- a/docs/contracts/abstract-contracts.rst +++ b/docs/contracts/abstract-contracts.rst @@ -13,6 +13,7 @@ This can be done by using the ``abstract`` keyword as shown in the following exa defined as abstract, because the function ``utterance()`` was defined, but no implementation was provided (no implementation body ``{ }`` was given).:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; abstract contract Feline { @@ -22,6 +23,7 @@ provided (no implementation body ``{ }`` was given).:: Such abstract contracts can not be instantiated directly. This is also true, if an abstract contract itself does implement all defined functions. The usage of an abstract contract as a base class is shown in the following example:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.0; abstract contract Feline { diff --git a/docs/contracts/constant-state-variables.rst b/docs/contracts/constant-state-variables.rst index 7a0a7380a..7424cd66a 100644 --- a/docs/contracts/constant-state-variables.rst +++ b/docs/contracts/constant-state-variables.rst @@ -17,6 +17,7 @@ Not all types for constants and immutables are implemented at this time. The onl :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >0.6.4 <0.7.0; contract C { diff --git a/docs/contracts/creating-contracts.rst b/docs/contracts/creating-contracts.rst index 90578f784..a2a628237 100644 --- a/docs/contracts/creating-contracts.rst +++ b/docs/contracts/creating-contracts.rst @@ -34,6 +34,7 @@ This means that cyclic creation dependencies are impossible. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.22 <0.7.0; diff --git a/docs/contracts/events.rst b/docs/contracts/events.rst index 46b426d8e..e4e74bde4 100644 --- a/docs/contracts/events.rst +++ b/docs/contracts/events.rst @@ -65,6 +65,7 @@ is that they are cheaper to deploy and call. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.21 <0.7.0; contract ClientReceipt { @@ -138,6 +139,7 @@ as topics. The event call above can be performed in the same way as :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.10 <0.7.0; contract C { diff --git a/docs/contracts/function-modifiers.rst b/docs/contracts/function-modifiers.rst index 758ba74ea..b64143d90 100644 --- a/docs/contracts/function-modifiers.rst +++ b/docs/contracts/function-modifiers.rst @@ -17,6 +17,7 @@ if they are marked ``virtual``. For details, please see :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; contract owned { diff --git a/docs/contracts/functions.rst b/docs/contracts/functions.rst index 7a0ec2e08..f33258fe1 100644 --- a/docs/contracts/functions.rst +++ b/docs/contracts/functions.rst @@ -23,6 +23,7 @@ unused parameters can be omitted. For example, if you want your contract to accept one kind of external call with two integers, you would use something like the following:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.16 <0.7.0; contract Simple { @@ -55,6 +56,7 @@ Function return variables are declared with the same syntax after the For example, suppose you want to return two results: the sum and the product of two integers passed as function parameters, then you use something like:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.16 <0.7.0; contract Simple { @@ -79,6 +81,7 @@ or you can provide return values (either a single or :ref:`multiple ones`) directly with the ``return`` statement:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.16 <0.7.0; contract Simple { @@ -142,6 +145,7 @@ The following statements are considered modifying the state: :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; contract C { @@ -187,6 +191,7 @@ In addition to the list of state modifying statements explained above, the follo :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; contract C { @@ -280,6 +285,7 @@ Below you can see an example of a Sink contract that uses function ``receive``. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.0; // This contract keeps all Ether sent to it with no way @@ -335,6 +341,7 @@ operations as long as there is enough gas passed on to it. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.2 <0.7.0; contract Test { @@ -407,6 +414,7 @@ The following example shows overloading of the function :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.16 <0.7.0; contract A { @@ -425,6 +433,7 @@ externally visible functions differ by their Solidity types but not by their ext :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.16 <0.7.0; // This will not compile @@ -458,6 +467,7 @@ candidate, resolution fails. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.16 <0.7.0; contract A { diff --git a/docs/contracts/inheritance.rst b/docs/contracts/inheritance.rst index d3dd0f164..83ccdf773 100644 --- a/docs/contracts/inheritance.rst +++ b/docs/contracts/inheritance.rst @@ -38,6 +38,7 @@ Details are given in the following example. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.0; @@ -125,6 +126,7 @@ Note that above, we call ``Destructible.destroy()`` to "forward" the destruction request. The way this is done is problematic, as seen in the following example:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.0; contract owned { @@ -154,6 +156,7 @@ A call to ``Final.destroy()`` will call ``Base2.destroy`` because we specify it explicitly in the final override, but this function will bypass ``Base1.destroy``. The way around this is to use ``super``:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; contract owned { @@ -204,6 +207,7 @@ use the ``override`` keyword in the function header as shown in this example: :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; contract Base @@ -227,6 +231,7 @@ bases, it has to explicitly override it: :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; contract Base1 @@ -253,6 +258,7 @@ that already overrides all other functions. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; contract A { function f() public pure{} } @@ -293,6 +299,7 @@ of the variable: :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; contract A @@ -324,6 +331,7 @@ and the ``override`` keyword must be used in the overriding modifier: :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; contract Base @@ -342,6 +350,7 @@ explicitly: :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; contract Base1 @@ -389,6 +398,7 @@ equivalent to ``constructor() public {}``. For example: :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; contract A { @@ -419,6 +429,7 @@ The constructors of all the base contracts will be called following the linearization rules explained below. If the base constructors have arguments, derived contracts need to specify all of them. This can be done in two ways:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.22 <0.7.0; contract Base { @@ -478,6 +489,7 @@ error "Linearization of inheritance graph impossible". :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.0 <0.7.0; contract X {} @@ -498,6 +510,7 @@ One area where inheritance linearization is especially important and perhaps not :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.22 <0.7.0; contract Base1 { diff --git a/docs/contracts/interfaces.rst b/docs/contracts/interfaces.rst index bce974502..7b1421791 100644 --- a/docs/contracts/interfaces.rst +++ b/docs/contracts/interfaces.rst @@ -22,6 +22,7 @@ Interfaces are denoted by their own keyword: :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.2 <0.7.0; interface Token { @@ -42,6 +43,7 @@ inheritance. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.2 <0.7.0; interface ParentA { diff --git a/docs/contracts/libraries.rst b/docs/contracts/libraries.rst index 86561ea7b..f58bf0f4e 100644 --- a/docs/contracts/libraries.rst +++ b/docs/contracts/libraries.rst @@ -47,6 +47,7 @@ more advanced example to implement a set). :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; @@ -125,6 +126,7 @@ custom types without the overhead of external function calls: :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; struct bigint { @@ -239,6 +241,7 @@ Its value can be obtained from Solidity using the ``.selector`` member as follow :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.14 <0.7.0; library L { diff --git a/docs/contracts/using-for.rst b/docs/contracts/using-for.rst index 9e63abcf4..8853bad24 100644 --- a/docs/contracts/using-for.rst +++ b/docs/contracts/using-for.rst @@ -29,6 +29,7 @@ may only be used inside a contract, not inside any of its functions. Let us rewrite the set example from the :ref:`libraries` in this way:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; @@ -81,6 +82,7 @@ Let us rewrite the set example from the It is also possible to extend elementary types in that way:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.16 <0.7.0; library Search { diff --git a/docs/contracts/visibility-and-getters.rst b/docs/contracts/visibility-and-getters.rst index 04af8a26f..7e7785f3a 100644 --- a/docs/contracts/visibility-and-getters.rst +++ b/docs/contracts/visibility-and-getters.rst @@ -54,6 +54,7 @@ return parameter list for functions. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.16 <0.7.0; contract C { @@ -68,6 +69,7 @@ In the following example, ``D``, can call ``c.getData()`` to retrieve the value :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.16 <0.7.0; contract C { @@ -112,6 +114,7 @@ when they are declared. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.16 <0.7.0; contract C { @@ -132,6 +135,7 @@ it evaluates to a state variable. If it is accessed externally :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.0 <0.7.0; contract C { @@ -151,6 +155,7 @@ to write a function, for example: :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.16 <0.7.0; contract arrayExample { @@ -177,6 +182,7 @@ The next example is more complex: :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.0 <0.7.0; contract Complex { diff --git a/docs/control-structures.rst b/docs/control-structures.rst index 7bbe290ba..9ecaa838b 100644 --- a/docs/control-structures.rst +++ b/docs/control-structures.rst @@ -41,6 +41,7 @@ Internal Function Calls Functions of the current contract can be called directly ("internally"), also recursively, as seen in this nonsensical example:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.22 <0.7.0; contract C { @@ -82,6 +83,7 @@ to the total balance of that contract: :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.2 <0.7.0; contract InfoFeed { @@ -137,6 +139,7 @@ parameters from the function declaration, but can be in arbitrary order. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.0 <0.7.0; contract C { @@ -160,6 +163,7 @@ Those parameters will still be present on the stack, but they are inaccessible. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.22 <0.7.0; contract C { @@ -183,6 +187,7 @@ is compiled so recursive creation-dependencies are not possible. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.2 <0.7.0; contract D { @@ -238,6 +243,7 @@ which only need to be created if there is a dispute. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.2 <0.7.0; contract D { @@ -307,6 +313,7 @@ groupings of expressions. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; contract C { @@ -352,6 +359,7 @@ because only a reference and not a copy is passed. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.22 <0.7.0; contract C { @@ -410,6 +418,7 @@ the two variables have the same name but disjoint scopes. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; contract C { function minimalScoping() pure public { @@ -431,6 +440,7 @@ In any case, you will get a warning about the outer variable being shadowed. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; // This will report a warning contract C { @@ -452,6 +462,7 @@ In any case, you will get a warning about the outer variable being shadowed. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; // This will not compile contract C { @@ -540,6 +551,7 @@ and ``assert`` for internal error checking. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; contract Sharer { @@ -584,6 +596,7 @@ The following example shows how to use an error string together with ``revert`` :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; contract VendingMachine { @@ -627,6 +640,7 @@ A failure in an external call can be caught using a try/catch statement, as foll :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.0; interface DataFeed { function getData(address token) external returns (uint value); } diff --git a/docs/examples/blind-auction.rst b/docs/examples/blind-auction.rst index f2034272a..30c177baa 100644 --- a/docs/examples/blind-auction.rst +++ b/docs/examples/blind-auction.rst @@ -24,6 +24,7 @@ to receive their money - contracts cannot activate themselves. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; contract SimpleAuction { @@ -184,6 +185,7 @@ invalid bids. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; contract BlindAuction { diff --git a/docs/examples/micropayment.rst b/docs/examples/micropayment.rst index ab69fd296..93dcd26f0 100644 --- a/docs/examples/micropayment.rst +++ b/docs/examples/micropayment.rst @@ -142,6 +142,7 @@ The full contract :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.24 <0.7.0; contract ReceiverPays { @@ -338,6 +339,7 @@ The full contract :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; contract SimplePaymentChannel { diff --git a/docs/examples/modular.rst b/docs/examples/modular.rst index a95a675c6..ff6a64077 100644 --- a/docs/examples/modular.rst +++ b/docs/examples/modular.rst @@ -19,6 +19,7 @@ and the sum of all balances is an invariant across the lifetime of the contract. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; library Balances { diff --git a/docs/examples/safe-remote.rst b/docs/examples/safe-remote.rst index caafaa7ed..c8e0eecc1 100644 --- a/docs/examples/safe-remote.rst +++ b/docs/examples/safe-remote.rst @@ -25,6 +25,7 @@ you can use state machine-like constructs inside a contract. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; contract Purchase { diff --git a/docs/examples/voting.rst b/docs/examples/voting.rst index e4b6da200..8d97a57ee 100644 --- a/docs/examples/voting.rst +++ b/docs/examples/voting.rst @@ -32,6 +32,7 @@ of votes. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.22 <0.7.0; /// @title Voting with delegation. diff --git a/docs/internals/layout_in_storage.rst b/docs/internals/layout_in_storage.rst index 0101556ef..5e102a38a 100644 --- a/docs/internals/layout_in_storage.rst +++ b/docs/internals/layout_in_storage.rst @@ -71,6 +71,7 @@ So for the following contract snippet the position of ``data[4][9].b`` is at ``keccak256(uint256(9) . keccak256(uint256(4) . uint256(1))) + 1``:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.0 <0.7.0; @@ -171,6 +172,7 @@ value and reference types, types that are encoded packed, and nested types. .. code:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.0 <0.7.0; contract A { struct S { diff --git a/docs/introduction-to-smart-contracts.rst b/docs/introduction-to-smart-contracts.rst index 9bba24c2f..6a59f1373 100644 --- a/docs/introduction-to-smart-contracts.rst +++ b/docs/introduction-to-smart-contracts.rst @@ -17,6 +17,7 @@ Storage Example :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.16 <0.7.0; contract SimpleStorage { @@ -81,6 +82,7 @@ registering with a username and password, all you need is an Ethereum keypair. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; contract Coin { diff --git a/docs/layout-of-source-files.rst b/docs/layout-of-source-files.rst index f817f04ff..f01e23ac5 100644 --- a/docs/layout-of-source-files.rst +++ b/docs/layout-of-source-files.rst @@ -316,6 +316,7 @@ for the two function parameters and two return variables. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.21 <0.7.0; /** @title Shape calculator. */ diff --git a/docs/natspec-format.rst b/docs/natspec-format.rst index 1776925ee..fa1d0c665 100644 --- a/docs/natspec-format.rst +++ b/docs/natspec-format.rst @@ -49,6 +49,7 @@ The following example shows a contract and a function using all available tags. .. code:: solidity + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; /// @title A simulator for trees diff --git a/docs/security-considerations.rst b/docs/security-considerations.rst index cf706fb7b..f899736aa 100644 --- a/docs/security-considerations.rst +++ b/docs/security-considerations.rst @@ -58,6 +58,7 @@ complete contract): :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.0 <0.7.0; // THIS CONTRACT CONTAINS A BUG - DO NOT USE @@ -81,6 +82,7 @@ as it uses ``call`` which forwards all remaining gas by default: :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.2 <0.7.0; // THIS CONTRACT CONTAINS A BUG - DO NOT USE @@ -100,6 +102,7 @@ outlined further below: :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.11 <0.7.0; contract Fund { @@ -197,6 +200,7 @@ Never use tx.origin for authorization. Let's say you have a wallet contract like :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; // THIS CONTRACT CONTAINS A BUG - DO NOT USE @@ -217,6 +221,7 @@ Now someone tricks you into sending Ether to the address of this attack wallet: :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.0; interface TxUserWallet { @@ -277,6 +282,7 @@ field of a ``struct`` that is the base type of a dynamic storage array. The :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; contract Map { @@ -555,6 +561,7 @@ not mean loss of proving power. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0; pragma experimental SMTChecker; // This may report a warning if no SMT solver available. @@ -609,6 +616,7 @@ types. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0; pragma experimental SMTChecker; // This will report a warning diff --git a/docs/structure-of-a-contract.rst b/docs/structure-of-a-contract.rst index b6d70c5a3..8e744bef2 100644 --- a/docs/structure-of-a-contract.rst +++ b/docs/structure-of-a-contract.rst @@ -26,6 +26,7 @@ storage. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.0 <0.7.0; contract SimpleStorage { @@ -46,6 +47,7 @@ Functions are the executable units of code within a contract. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.0 <0.7.0; contract SimpleAuction { @@ -74,6 +76,7 @@ Like functions, modifiers can be :ref:`overridden `. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.22 <0.7.0; contract Purchase { @@ -101,6 +104,7 @@ Events are convenience interfaces with the EVM logging facilities. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.21 <0.7.0; contract SimpleAuction { @@ -125,6 +129,7 @@ Structs are custom defined types that can group several variables (see :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.0 <0.7.0; contract Ballot { @@ -146,6 +151,7 @@ Enums can be used to create custom types with a finite set of 'constant values' :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.0 <0.7.0; contract Purchase { diff --git a/docs/style-guide.rst b/docs/style-guide.rst index c2990824d..9d51bb224 100644 --- a/docs/style-guide.rst +++ b/docs/style-guide.rst @@ -55,6 +55,7 @@ Surround top level declarations in solidity source with two blank lines. Yes:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.0 <0.7.0; contract A { @@ -73,6 +74,7 @@ Yes:: No:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.0 <0.7.0; contract A { @@ -92,6 +94,7 @@ Blank lines may be omitted between groups of related one-liners (such as stub fu Yes:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.0; abstract contract A { @@ -112,6 +115,7 @@ Yes:: No:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; abstract contract A { @@ -246,6 +250,7 @@ Import statements should always be placed at the top of the file. Yes:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.0 <0.7.0; import "./Owned.sol"; @@ -260,6 +265,7 @@ Yes:: No:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.0 <0.7.0; contract A { @@ -293,6 +299,7 @@ Within a grouping, place the ``view`` and ``pure`` functions last. Yes:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.0; contract A { @@ -329,6 +336,7 @@ Yes:: No:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.0; contract A { @@ -436,6 +444,7 @@ should: Yes:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.0 <0.7.0; contract Coin { @@ -447,6 +456,7 @@ Yes:: No:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.0 <0.7.0; contract Coin @@ -747,6 +757,7 @@ manner as modifiers if the function declaration is long or hard to read. Yes:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.22 <0.7.0; // Base contracts just to make this compile @@ -779,6 +790,7 @@ Yes:: No:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.22 <0.7.0; @@ -1002,6 +1014,7 @@ As shown in the example below, if the contract name is ``Congress`` and the libr Yes:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.22 <0.7.0; @@ -1025,6 +1038,7 @@ Yes:: and in ``Congress.sol``:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.0 <0.7.0; import "./Owned.sol"; @@ -1036,6 +1050,7 @@ and in ``Congress.sol``:: No:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.22 <0.7.0; @@ -1140,6 +1155,7 @@ multiline comment starting with ``/**`` and ending with ``*/``. For example, the contract from `a simple smart contract `_ with the comments added looks like the one below:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.16 <0.7.0; diff --git a/docs/types/mapping-types.rst b/docs/types/mapping-types.rst index d84da8ec5..5226f36a3 100644 --- a/docs/types/mapping-types.rst +++ b/docs/types/mapping-types.rst @@ -41,6 +41,7 @@ contract that returns the value at the specified address. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.0 <0.7.0; contract MappingExample { @@ -66,6 +67,7 @@ The example below uses ``_allowances`` to record the amount someone else is allo :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.22 <0.7.0; contract MappingExample { @@ -120,6 +122,7 @@ the ``sum`` function iterates over to sum all the values. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; struct IndexValue { uint keyIndex; uint value; } diff --git a/docs/types/operators.rst b/docs/types/operators.rst index c65e545c5..76726ec6f 100644 --- a/docs/types/operators.rst +++ b/docs/types/operators.rst @@ -42,6 +42,7 @@ value it referred to previously. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.0 <0.7.0; contract DeleteExample { diff --git a/docs/types/reference-types.rst b/docs/types/reference-types.rst index f7aca7190..5a59997c4 100644 --- a/docs/types/reference-types.rst +++ b/docs/types/reference-types.rst @@ -57,6 +57,7 @@ Data locations are not only relevant for persistency of data, but also for the s :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; contract C { @@ -167,6 +168,7 @@ or create a new memory array and copy every element. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.16 <0.7.0; contract C { @@ -198,6 +200,7 @@ the first element to ``uint``. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.16 <0.7.0; contract C { @@ -214,6 +217,7 @@ memory arrays, i.e. the following is not possible: :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.0 <0.7.0; // This will not compile. @@ -274,6 +278,7 @@ Array Members :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; contract ArrayContract { @@ -406,6 +411,7 @@ Array slices are useful to ABI-decode secondary data passed in function paramete :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; contract Proxy { @@ -443,6 +449,7 @@ shown in the following example: :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; // Defines a new type with two fields. diff --git a/docs/types/value-types.rst b/docs/types/value-types.rst index 65cbd5504..29a91c836 100644 --- a/docs/types/value-types.rst +++ b/docs/types/value-types.rst @@ -543,6 +543,7 @@ subsequent unsigned integer values starting from ``0``. :: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.16 <0.7.0; contract test { @@ -653,6 +654,7 @@ External (or public) functions have the following members: Example that shows how to use the members:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; // This will report a warning @@ -671,6 +673,7 @@ Example that shows how to use the members:: Example that shows how to use internal function types:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.16 <0.7.0; library ArrayUtils { @@ -728,6 +731,7 @@ Example that shows how to use internal function types:: Another example that uses external function types:: + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.22 <0.7.0; diff --git a/docs/using-the-compiler.rst b/docs/using-the-compiler.rst index 84b4ef9d7..9009fac01 100644 --- a/docs/using-the-compiler.rst +++ b/docs/using-the-compiler.rst @@ -617,6 +617,7 @@ Assume you have the following contracts you want to update declared in ``Source. .. code-block:: none // This will not compile after 0.5.0 + // SPDX-License-Identifier: GPL-3.0 pragma solidity >0.4.23 <0.5.0; contract Updateable { @@ -698,6 +699,7 @@ The command above applies all changes as shown below. Please review them careful .. code-block:: solidity + // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; abstract contract Updateable { From 098cfd333f322212458e37dbe1f679c187a8671d Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 13 May 2020 22:29:35 +0100 Subject: [PATCH 12/15] Update EVMC to 7.2.0 --- test/evmc/README.md | 2 +- test/evmc/evmc.h | 4 +- test/evmc/evmc.hpp | 252 ++++++++++++++++++++++++-------------- test/evmc/mocked_host.hpp | 3 +- 4 files changed, 167 insertions(+), 94 deletions(-) diff --git a/test/evmc/README.md b/test/evmc/README.md index 436a47e68..1d5d55422 100644 --- a/test/evmc/README.md +++ b/test/evmc/README.md @@ -1,3 +1,3 @@ # EVMC -This is an import of [EVMC](https://github.com/ethereum/evmc) version [7.1.0](https://github.com/ethereum/evmc/releases/tag/v7.1.0). +This is an import of [EVMC](https://github.com/ethereum/evmc) version [7.2.0](https://github.com/ethereum/evmc/releases/tag/v7.2.0). diff --git a/test/evmc/evmc.h b/test/evmc/evmc.h index 3fc3ca610..51d9f842a 100644 --- a/test/evmc/evmc.h +++ b/test/evmc/evmc.h @@ -345,8 +345,8 @@ struct evmc_result /** * The amount of gas left after the execution. * - * If evmc_result::code is not ::EVMC_SUCCESS nor ::EVMC_REVERT - * the value MUST be 0. + * If evmc_result::status_code is neither ::EVMC_SUCCESS nor ::EVMC_REVERT + * the value MUST be 0. */ int64_t gas_left; diff --git a/test/evmc/evmc.hpp b/test/evmc/evmc.hpp index 0b44cd12c..36f9063b3 100644 --- a/test/evmc/evmc.hpp +++ b/test/evmc/evmc.hpp @@ -25,6 +25,33 @@ struct address : evmc_address /// Initializes bytes to zeros if not other @p init value provided. constexpr address(evmc_address init = {}) noexcept : evmc_address{init} {} + /// Converting constructor from unsigned integer value. + /// + /// This constructor assigns the @p v value to the last 8 bytes [12:19] + /// in big-endian order. + constexpr explicit address(uint64_t v) noexcept + : evmc_address{{0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + static_cast(v >> 56), + static_cast(v >> 48), + static_cast(v >> 40), + static_cast(v >> 32), + static_cast(v >> 24), + static_cast(v >> 16), + static_cast(v >> 8), + static_cast(v >> 0)}} + {} + /// Explicit operator converting to bool. constexpr inline explicit operator bool() const noexcept; }; @@ -39,6 +66,45 @@ struct bytes32 : evmc_bytes32 /// Initializes bytes to zeros if not other @p init value provided. constexpr bytes32(evmc_bytes32 init = {}) noexcept : evmc_bytes32{init} {} + /// Converting constructor from unsigned integer value. + /// + /// This constructor assigns the @p v value to the last 8 bytes [24:31] + /// in big-endian order. + constexpr explicit bytes32(uint64_t v) noexcept + : evmc_bytes32{{0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + static_cast(v >> 56), + static_cast(v >> 48), + static_cast(v >> 40), + static_cast(v >> 32), + static_cast(v >> 24), + static_cast(v >> 16), + static_cast(v >> 8), + static_cast(v >> 0)}} + {} + /// Explicit operator converting to bool. constexpr inline explicit operator bool() const noexcept; }; @@ -50,7 +116,6 @@ using uint256be = bytes32; /// Loads 64 bits / 8 bytes of data from the given @p bytes array in big-endian order. constexpr inline uint64_t load64be(const uint8_t* bytes) noexcept { - // TODO: Report bug in clang incorrectly optimizing this with AVX2 enabled. return (uint64_t{bytes[0]} << 56) | (uint64_t{bytes[1]} << 48) | (uint64_t{bytes[2]} << 40) | (uint64_t{bytes[3]} << 32) | (uint64_t{bytes[4]} << 24) | (uint64_t{bytes[5]} << 16) | (uint64_t{bytes[6]} << 8) | uint64_t{bytes[7]}; @@ -76,7 +141,7 @@ constexpr inline uint64_t fnv1a_by64(uint64_t h, uint64_t x) noexcept } // namespace fnv -/// The "equal" comparison operator for the evmc::address type. +/// The "equal to" comparison operator for the evmc::address type. constexpr bool operator==(const address& a, const address& b) noexcept { // TODO: Report bug in clang keeping unnecessary bswap. @@ -85,23 +150,41 @@ constexpr bool operator==(const address& a, const address& b) noexcept load32be(&a.bytes[16]) == load32be(&b.bytes[16]); } -/// The "not equal" comparison operator for the evmc::address type. +/// The "not equal to" comparison operator for the evmc::address type. constexpr bool operator!=(const address& a, const address& b) noexcept { return !(a == b); } -/// The "less" comparison operator for the evmc::address type. +/// The "less than" comparison operator for the evmc::address type. constexpr bool operator<(const address& a, const address& b) noexcept { return load64be(&a.bytes[0]) < load64be(&b.bytes[0]) || (load64be(&a.bytes[0]) == load64be(&b.bytes[0]) && - load64be(&a.bytes[8]) < load64be(&b.bytes[8])) || - (load64be(&a.bytes[8]) == load64be(&b.bytes[8]) && - load32be(&a.bytes[16]) < load32be(&b.bytes[16])); + (load64be(&a.bytes[8]) < load64be(&b.bytes[8]) || + (load64be(&a.bytes[8]) == load64be(&b.bytes[8]) && + load32be(&a.bytes[16]) < load32be(&b.bytes[16])))); } -/// The "equal" comparison operator for the evmc::bytes32 type. +/// The "greater than" comparison operator for the evmc::address type. +constexpr bool operator>(const address& a, const address& b) noexcept +{ + return b < a; +} + +/// The "less than or equal to" comparison operator for the evmc::address type. +constexpr bool operator<=(const address& a, const address& b) noexcept +{ + return !(b < a); +} + +/// The "greater than or equal to" comparison operator for the evmc::address type. +constexpr bool operator>=(const address& a, const address& b) noexcept +{ + return !(a < b); +} + +/// The "equal to" comparison operator for the evmc::bytes32 type. constexpr bool operator==(const bytes32& a, const bytes32& b) noexcept { return load64be(&a.bytes[0]) == load64be(&b.bytes[0]) && @@ -110,22 +193,40 @@ constexpr bool operator==(const bytes32& a, const bytes32& b) noexcept load64be(&a.bytes[24]) == load64be(&b.bytes[24]); } -/// The "not equal" comparison operator for the evmc::bytes32 type. +/// The "not equal to" comparison operator for the evmc::bytes32 type. constexpr bool operator!=(const bytes32& a, const bytes32& b) noexcept { return !(a == b); } -/// The "less" comparison operator for the evmc::bytes32 type. +/// The "less than" comparison operator for the evmc::bytes32 type. constexpr bool operator<(const bytes32& a, const bytes32& b) noexcept { return load64be(&a.bytes[0]) < load64be(&b.bytes[0]) || (load64be(&a.bytes[0]) == load64be(&b.bytes[0]) && - load64be(&a.bytes[8]) < load64be(&b.bytes[8])) || - (load64be(&a.bytes[8]) == load64be(&b.bytes[8]) && - load64be(&a.bytes[16]) < load64be(&b.bytes[16])) || - (load64be(&a.bytes[16]) == load64be(&b.bytes[16]) && - load64be(&a.bytes[24]) < load64be(&b.bytes[24])); + (load64be(&a.bytes[8]) < load64be(&b.bytes[8]) || + (load64be(&a.bytes[8]) == load64be(&b.bytes[8]) && + (load64be(&a.bytes[16]) < load64be(&b.bytes[16]) || + (load64be(&a.bytes[16]) == load64be(&b.bytes[16]) && + load64be(&a.bytes[24]) < load64be(&b.bytes[24])))))); +} + +/// The "greater than" comparison operator for the evmc::bytes32 type. +constexpr bool operator>(const bytes32& a, const bytes32& b) noexcept +{ + return b < a; +} + +/// The "less than or equal to" comparison operator for the evmc::bytes32 type. +constexpr bool operator<=(const bytes32& a, const bytes32& b) noexcept +{ + return !(b < a); +} + +/// The "greater than or equal to" comparison operator for the evmc::bytes32 type. +constexpr bool operator>=(const bytes32& a, const bytes32& b) noexcept +{ + return !(a < b); } /// Checks if the given address is the zero address. @@ -154,108 +255,72 @@ namespace literals { namespace internal { -template -struct integer_sequence +constexpr size_t length(const char* s) noexcept { -}; - -template -using byte_sequence = integer_sequence; - -template -using char_sequence = integer_sequence; - - -template -struct concatenate; - -template -struct concatenate, byte_sequence> -{ - using type = byte_sequence; -}; - -template -constexpr uint8_t parse_hex_digit() noexcept -{ - static_assert((D >= '0' && D <= '9') || (D >= 'a' && D <= 'f') || (D >= 'A' && D <= 'F'), - "literal must be hexadecimal integer"); - return static_cast( - (D >= '0' && D <= '9') ? D - '0' : (D >= 'a' && D <= 'f') ? D - 'a' + 10 : D - 'A' + 10); + return (*s != '\0') ? length(s + 1) + 1 : 0; } - -template -struct parse_digits; - -template -struct parse_digits> +constexpr int from_hex(char c) noexcept { - using type = byte_sequence(parse_hex_digit() << 4) | - parse_hex_digit()>; -}; + return (c >= 'a' && c <= 'f') ? c - ('a' - 10) : + (c >= 'A' && c <= 'F') ? c - ('A' - 10) : c - '0'; +} -template -struct parse_digits> +constexpr uint8_t byte(const char* s, size_t i) noexcept { - using type = typename concatenate>::type, - typename parse_digits>::type>::type; -}; + return static_cast((from_hex(s[2 * i]) << 4) | from_hex(s[2 * i + 1])); +} +template +T from_hex(const char*) noexcept; -template -struct parse_literal; - -template -struct parse_literal> +template <> +constexpr bytes32 from_hex(const char* s) noexcept { - static_assert(Prefix1 == '0' && Prefix2 == 'x', "literal must be in hexadecimal notation"); - static_assert(sizeof...(Literal) == sizeof(T) * 2, "literal must match the result type size"); + return { + {{byte(s, 0), byte(s, 1), byte(s, 2), byte(s, 3), byte(s, 4), byte(s, 5), byte(s, 6), + byte(s, 7), byte(s, 8), byte(s, 9), byte(s, 10), byte(s, 11), byte(s, 12), byte(s, 13), + byte(s, 14), byte(s, 15), byte(s, 16), byte(s, 17), byte(s, 18), byte(s, 19), byte(s, 20), + byte(s, 21), byte(s, 22), byte(s, 23), byte(s, 24), byte(s, 25), byte(s, 26), byte(s, 27), + byte(s, 28), byte(s, 29), byte(s, 30), byte(s, 31)}}}; +} - template - static constexpr T create_from(byte_sequence) noexcept - { - return T{{{Bytes...}}}; - } - - static constexpr T get() noexcept - { - return create_from(typename parse_digits>::type{}); - } -}; - -template -struct parse_literal> +template <> +constexpr address from_hex
(const char* s) noexcept { - static_assert(Digit == '0', "only 0 is allowed as a single digit literal"); - static constexpr T get() noexcept { return {}; } -}; + return { + {{byte(s, 0), byte(s, 1), byte(s, 2), byte(s, 3), byte(s, 4), byte(s, 5), byte(s, 6), + byte(s, 7), byte(s, 8), byte(s, 9), byte(s, 10), byte(s, 11), byte(s, 12), byte(s, 13), + byte(s, 14), byte(s, 15), byte(s, 16), byte(s, 17), byte(s, 18), byte(s, 19)}}}; +} -template -constexpr T parse() noexcept +template +constexpr T from_literal(const char* s) { - return parse_literal>::get(); + return (s[0] == '0' && s[1] == '\0') ? + T{} : + !(s[0] == '0' && s[1] == 'x') ? + throw "literal must be in hexadecimal notation" : + (length(s + 2) != sizeof(T) * 2) ? throw "literal must match the result type size" : + from_hex(s + 2); } } // namespace internal /// Literal for evmc::address. -template -constexpr address operator"" _address() noexcept +constexpr address operator""_address(const char* s) noexcept { - return internal::parse(); + return internal::from_literal
(s); } /// Literal for evmc::bytes32. -template -constexpr bytes32 operator"" _bytes32() noexcept +constexpr bytes32 operator""_bytes32(const char* s) noexcept { - return internal::parse(); + return internal::from_literal(s); } } // namespace literals using namespace literals; - /// Alias for evmc_make_result(). constexpr auto make_result = evmc_make_result; @@ -626,6 +691,13 @@ public: m_instance->execute(m_instance, nullptr, nullptr, rev, &msg, code, code_size)}; } + /// Returns the pointer to C EVMC struct representing the VM. + /// + /// Gives access to the C EVMC VM struct to allow advanced interaction with the VM not supported + /// by the C++ interface. Use as the last resort. + /// This object still owns the VM after returning the pointer. The returned pointer MAY be null. + evmc_vm* get_raw_pointer() const noexcept { return m_instance; } + private: evmc_vm* m_instance = nullptr; }; diff --git a/test/evmc/mocked_host.hpp b/test/evmc/mocked_host.hpp index 2ff1701a4..57f0cb79b 100644 --- a/test/evmc/mocked_host.hpp +++ b/test/evmc/mocked_host.hpp @@ -133,10 +133,11 @@ public: /// The record of all SELFDESTRUCTs from the selfdestruct() method. std::vector recorded_selfdestructs; -protected: +private: /// The copy of call inputs for the recorded_calls record. std::vector m_recorded_calls_inputs; +public: /// Record an account access. /// @param addr The address of the accessed account. void record_account_access(const address& addr) const From 7353804252b56d97bd5075d75feb569f9a737916 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 13 May 2020 22:37:07 +0100 Subject: [PATCH 13/15] EVMHost: simplify code using new evmc features --- test/EVMHost.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/EVMHost.cpp b/test/EVMHost.cpp index 3c9e6449e..505964aa0 100644 --- a/test/EVMHost.cpp +++ b/test/EVMHost.cpp @@ -99,17 +99,16 @@ EVMHost::EVMHost(langutil::EVMVersion _evmVersion, evmc::VM& _vm): evmc::address address{}; address.bytes[19] = precompiledAddress; // 1wei - accounts[address].balance.bytes[31] = 1; + accounts[address].balance = evmc::uint256be{1}; } - // TODO: support short literals in EVMC and use them here - tx_context.block_difficulty = convertToEVMC(u256("200000000")); + tx_context.block_difficulty = evmc::uint256be{200000000}; tx_context.block_gas_limit = 20000000; tx_context.block_coinbase = 0x7878787878787878787878787878787878787878_address; - tx_context.tx_gas_price = convertToEVMC(u256("3000000000")); + tx_context.tx_gas_price = evmc::uint256be{3000000000}; tx_context.tx_origin = 0x9292929292929292929292929292929292929292_address; // Mainnet according to EIP-155 - tx_context.chain_id = convertToEVMC(u256(1)); + tx_context.chain_id = evmc::uint256be{1}; } void EVMHost::selfdestruct(const evmc::address& _addr, const evmc::address& _beneficiary) noexcept From c9745ea10132cd7a04c0685ac72629d4e5145767 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 13 May 2020 22:38:50 +0100 Subject: [PATCH 14/15] EVMHost: enable support for Berlin --- test/EVMHost.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/EVMHost.cpp b/test/EVMHost.cpp index 505964aa0..836d61057 100644 --- a/test/EVMHost.cpp +++ b/test/EVMHost.cpp @@ -81,12 +81,14 @@ EVMHost::EVMHost(langutil::EVMVersion _evmVersion, evmc::VM& _vm): m_evmRevision = EVMC_BYZANTIUM; else if (_evmVersion == langutil::EVMVersion::constantinople()) m_evmRevision = EVMC_CONSTANTINOPLE; + else if (_evmVersion == langutil::EVMVersion::petersburg()) + m_evmRevision = EVMC_PETERSBURG; else if (_evmVersion == langutil::EVMVersion::istanbul()) m_evmRevision = EVMC_ISTANBUL; else if (_evmVersion == langutil::EVMVersion::berlin()) - assertThrow(false, Exception, "Berlin is not supported yet."); - else //if (_evmVersion == langutil::EVMVersion::petersburg()) - m_evmRevision = EVMC_PETERSBURG; + m_evmRevision = EVMC_BERLIN; + else + assertThrow(false, Exception, "Unsupported EVM version"); // Mark all precompiled contracts as existing. Existing here means to have a balance (as per EIP-161). // NOTE: keep this in sync with `EVMHost::call` below. From 6308ca4a228e38f3b93d70337297e9bbd4bfc8dc Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 12 May 2020 21:01:39 +0200 Subject: [PATCH 15/15] Binary transform for br and br_if. --- Changelog.md | 1 + libyul/backends/wasm/BinaryTransform.cpp | 43 +- libyul/backends/wasm/BinaryTransform.h | 4 +- libyul/backends/wasm/TextTransform.cpp | 2 +- test/cmdlineTests/evm_to_wasm_break/args | 1 + test/cmdlineTests/evm_to_wasm_break/err | 1 + test/cmdlineTests/evm_to_wasm_break/input.sol | 8 + test/cmdlineTests/evm_to_wasm_break/output | 551 ++++++++++++++++++ .../ewasmTranslationTests/loop_break.yul | 13 + .../ewasmTranslationTests/loop_continue.yul | 22 + 10 files changed, 631 insertions(+), 15 deletions(-) create mode 100644 test/cmdlineTests/evm_to_wasm_break/args create mode 100644 test/cmdlineTests/evm_to_wasm_break/err create mode 100644 test/cmdlineTests/evm_to_wasm_break/input.sol create mode 100644 test/cmdlineTests/evm_to_wasm_break/output create mode 100644 test/libyul/ewasmTranslationTests/loop_break.yul create mode 100644 test/libyul/ewasmTranslationTests/loop_continue.yul diff --git a/Changelog.md b/Changelog.md index 1faf29393..53c77ce9c 100644 --- a/Changelog.md +++ b/Changelog.md @@ -13,6 +13,7 @@ Language Features: Compiler Features: * Commandline Interface: Don't ignore `--yul-optimizations` in assembly mode. * Allow using abi encoding functions for calldata array slices without explicit casts. + * Wasm binary output: Implement ``br`` and ``br_if``. diff --git a/libyul/backends/wasm/BinaryTransform.cpp b/libyul/backends/wasm/BinaryTransform.cpp index ad2628695..249d87a33 100644 --- a/libyul/backends/wasm/BinaryTransform.cpp +++ b/libyul/backends/wasm/BinaryTransform.cpp @@ -358,13 +358,13 @@ bytes BinaryTransform::operator()(If const& _if) toBytes(Opcode::If) + toBytes(ValueType::Void); - m_labels.push({}); + m_labels.emplace_back(); result += visit(_if.statements); if (_if.elseStatements) result += toBytes(Opcode::Else) + visit(*_if.elseStatements); - m_labels.pop(); + m_labels.pop_back(); result += toBytes(Opcode::End); return result; @@ -374,26 +374,24 @@ bytes BinaryTransform::operator()(Loop const& _loop) { bytes result = toBytes(Opcode::Loop) + toBytes(ValueType::Void); - m_labels.push(_loop.labelName); + m_labels.emplace_back(_loop.labelName); result += visit(_loop.statements); - m_labels.pop(); + m_labels.pop_back(); result += toBytes(Opcode::End); return result; } -bytes BinaryTransform::operator()(Break const&) +bytes BinaryTransform::operator()(Break const& _break) { - yulAssert(false, "br not yet implemented."); - // TODO the index is just the nesting depth. - return {}; + return toBytes(Opcode::Br) + encodeLabelIdx(_break.label.name); } -bytes BinaryTransform::operator()(BreakIf const&) +bytes BinaryTransform::operator()(BreakIf const& _breakIf) { - yulAssert(false, "br_if not yet implemented."); - // TODO the index is just the nesting depth. - return {}; + bytes result = std::visit(*this, *_breakIf.condition); + result += toBytes(Opcode::BrIf) + encodeLabelIdx(_breakIf.label.name); + return result; } bytes BinaryTransform::operator()(Return const&) @@ -403,11 +401,14 @@ bytes BinaryTransform::operator()(Return const&) bytes BinaryTransform::operator()(Block const& _block) { - return + m_labels.emplace_back(_block.labelName); + bytes result = toBytes(Opcode::Block) + toBytes(ValueType::Void) + visit(_block.statements) + toBytes(Opcode::End); + m_labels.pop_back(); + return result; } bytes BinaryTransform::operator()(FunctionDefinition const& _function) @@ -427,9 +428,13 @@ bytes BinaryTransform::operator()(FunctionDefinition const& _function) for (size_t i = 0; i < _function.locals.size(); ++i) m_locals[_function.locals[i].variableName] = varIdx++; + yulAssert(m_labels.empty(), "Stray labels."); + ret += visit(_function.body); ret += toBytes(Opcode::End); + yulAssert(m_labels.empty(), "Stray labels."); + return prefixSize(std::move(ret)); } @@ -581,6 +586,18 @@ bytes BinaryTransform::visitReversed(vector const& _expressions) return result; } +bytes BinaryTransform::encodeLabelIdx(string const& _label) const +{ + yulAssert(!_label.empty(), "Empty label."); + size_t depth = 0; + for (string const& label: m_labels | boost::adaptors::reversed) + if (label == _label) + return lebEncode(depth); + else + ++depth; + yulAssert(false, "Label not found."); +} + bytes BinaryTransform::encodeName(std::string const& _name) { // UTF-8 is allowed here by the Wasm spec, but since all names here should stem from diff --git a/libyul/backends/wasm/BinaryTransform.h b/libyul/backends/wasm/BinaryTransform.h index d4e4375c2..e11c92bf6 100644 --- a/libyul/backends/wasm/BinaryTransform.h +++ b/libyul/backends/wasm/BinaryTransform.h @@ -77,13 +77,15 @@ private: bytes visit(std::vector const& _expressions); bytes visitReversed(std::vector const& _expressions); + bytes encodeLabelIdx(std::string const& _label) const; + static bytes encodeName(std::string const& _name); std::map m_locals; std::map m_globals; std::map m_functions; std::map m_functionTypes; - std::stack m_labels; + std::vector m_labels; std::map> m_subModulePosAndSize; }; diff --git a/libyul/backends/wasm/TextTransform.cpp b/libyul/backends/wasm/TextTransform.cpp index 3edeb9365..2a2499b61 100644 --- a/libyul/backends/wasm/TextTransform.cpp +++ b/libyul/backends/wasm/TextTransform.cpp @@ -123,7 +123,7 @@ string TextTransform::operator()(wasm::Loop const& _loop) string TextTransform::operator()(wasm::Break const& _break) { - return "(break $" + _break.label.name + ")\n"; + return "(br $" + _break.label.name + ")\n"; } string TextTransform::operator()(wasm::BreakIf const& _break) diff --git a/test/cmdlineTests/evm_to_wasm_break/args b/test/cmdlineTests/evm_to_wasm_break/args new file mode 100644 index 000000000..099ebdc3a --- /dev/null +++ b/test/cmdlineTests/evm_to_wasm_break/args @@ -0,0 +1 @@ +--assemble --optimize --yul-dialect evm --machine ewasm diff --git a/test/cmdlineTests/evm_to_wasm_break/err b/test/cmdlineTests/evm_to_wasm_break/err new file mode 100644 index 000000000..014a1178f --- /dev/null +++ b/test/cmdlineTests/evm_to_wasm_break/err @@ -0,0 +1 @@ +Warning: Yul is still experimental. Please use the output with care. diff --git a/test/cmdlineTests/evm_to_wasm_break/input.sol b/test/cmdlineTests/evm_to_wasm_break/input.sol new file mode 100644 index 000000000..a625eea08 --- /dev/null +++ b/test/cmdlineTests/evm_to_wasm_break/input.sol @@ -0,0 +1,8 @@ +{ + let x := calldataload(0) + for { } lt(x, 10) { x := add(x, 1) } { + if eq(x, 2) { break } + if eq(x, 4) { continue } + } + sstore(0, x) +} diff --git a/test/cmdlineTests/evm_to_wasm_break/output b/test/cmdlineTests/evm_to_wasm_break/output new file mode 100644 index 000000000..3ed2a2dd0 --- /dev/null +++ b/test/cmdlineTests/evm_to_wasm_break/output @@ -0,0 +1,551 @@ + +======= evm_to_wasm_break/input.sol (Ewasm) ======= + +Pretty printed source: +object "object" { + code { + { + let x := calldataload(0) + for { } lt(x, 10) { x := add(x, 1) } + { + if eq(x, 2) { break } + if eq(x, 4) { continue } + } + sstore(0, x) + } + } +} + + +========================== + +Translated source: +object "object" { + code { + function main() + { + let _1 := 0 + let x, x_1, x_2, x_3 := calldataload(_1, _1, _1, _1) + let x_4 := x + let x_5 := x_1 + let x_6 := x_2 + let x_7 := x_3 + let _2 := 1 + let _3:i32 := i32.eqz(i32.eqz(i64.eqz(i64.or(i64.or(_1, _1), i64.or(_1, _2))))) + for { } + i32.eqz(_3) + { + let x_8, x_9, x_10, x_11 := add(x_4, x_5, x_6, x_7, _1, _1, _1, _2) + x_4 := x_8 + x_5 := x_9 + x_6 := x_10 + x_7 := x_11 + } + { + let _4, _5, _6, _7 := lt(x_4, x_5, x_6, x_7, _1, _1, _1, 10) + let _8, _9, _10, _11 := iszero(_4, _5, _6, _7) + if i32.eqz(i64.eqz(i64.or(i64.or(_8, _9), i64.or(_10, _11)))) { break } + let _12, _13, _14, _15 := eq(x_4, x_5, x_6, x_7, _1, _1, _1, 2) + if i32.eqz(i64.eqz(i64.or(i64.or(_12, _13), i64.or(_14, _15)))) { break } + let _16, _17, _18, _19 := eq(x_4, x_5, x_6, x_7, _1, _1, _1, 4) + if i32.eqz(i64.eqz(i64.or(i64.or(_16, _17), i64.or(_18, _19)))) { continue } + } + sstore(_1, _1, _1, _1, x_4, x_5, x_6, x_7) + } + function add_carry(x, y, c) -> r, r_c + { + let t := i64.add(x, y) + r := i64.add(t, c) + r_c := i64.extend_i32_u(i32.or(i64.lt_u(t, x), i64.lt_u(r, t))) + } + function add(x1, x2, x3, x4, y1, y2, y3, y4) -> r1, r2, r3, r4 + { + let t := i64.add(x4, y4) + r4 := i64.add(t, 0) + let r3_1, carry := add_carry(x3, y3, i64.extend_i32_u(i32.or(i64.lt_u(t, x4), i64.lt_u(r4, t)))) + r3 := r3_1 + let r2_1, carry_1 := add_carry(x2, y2, carry) + r2 := r2_1 + let r1_1, carry_2 := add_carry(x1, y1, carry_1) + r1 := r1_1 + } + function iszero(x1, x2, x3, x4) -> r1, r2, r3, r4 + { + r4 := i64.extend_i32_u(i64.eqz(i64.or(i64.or(x1, x2), i64.or(x3, x4)))) + } + function eq(x1, x2, x3, x4, y1, y2, y3, y4) -> r1, r2, r3, r4 + { + if i64.eq(x1, y1) + { + if i64.eq(x2, y2) + { + if i64.eq(x3, y3) { if i64.eq(x4, y4) { r4 := 1 } } + } + } + } + function cmp(a, b) -> r:i32 + { + switch i64.lt_u(a, b) + case 1:i32 { r := 0xffffffff:i32 } + default { r := i64.ne(a, b) } + } + function lt(x1, x2, x3, x4, y1, y2, y3, y4) -> z1, z2, z3, z4 + { + let z:i32 := false + switch cmp(x1, y1) + case 0:i32 { + switch cmp(x2, y2) + case 0:i32 { + switch cmp(x3, y3) + case 0:i32 { z := i64.lt_u(x4, y4) } + case 1:i32 { z := 0:i32 } + default { z := 1:i32 } + } + case 1:i32 { z := 0:i32 } + default { z := 1:i32 } + } + case 1:i32 { z := 0:i32 } + default { z := 1:i32 } + z4 := i64.extend_i32_u(z) + } + function calldataload(x1, x2, x3, x4) -> z1, z2, z3, z4 + { + if i64.ne(0, i64.or(i64.or(x1, x2), x3)) { unreachable() } + if i64.ne(0, i64.shr_u(x4, 32)) { unreachable() } + eth.callDataCopy(0:i32, i32.wrap_i64(x4), 32:i32) + let z1_1 := endian_swap(i64.load(0:i32)) + let z2_1 := endian_swap(i64.load(i32.add(0:i32, 8:i32))) + let z3_1 := endian_swap(i64.load(i32.add(0:i32, 16:i32))) + let z4_1 := endian_swap(i64.load(i32.add(0:i32, 24:i32))) + z1 := z1_1 + z2 := z2_1 + z3 := z3_1 + z4 := z4_1 + } + function endian_swap_16(x) -> y + { + y := i64.or(i64.and(i64.shl(x, 8), 0xff00), i64.and(i64.shr_u(x, 8), 0xff)) + } + function endian_swap_32(x) -> y + { + let hi := i64.shl(endian_swap_16(x), 16) + y := i64.or(hi, endian_swap_16(i64.shr_u(x, 16))) + } + function endian_swap(x) -> y + { + let hi := i64.shl(endian_swap_32(x), 32) + y := i64.or(hi, endian_swap_32(i64.shr_u(x, 32))) + } + function mstore_internal(pos:i32, y1, y2, y3, y4) + { + i64.store(pos, endian_swap(y1)) + i64.store(i32.add(pos, 8:i32), endian_swap(y2)) + i64.store(i32.add(pos, 16:i32), endian_swap(y3)) + i64.store(i32.add(pos, 24:i32), endian_swap(y4)) + } + function sstore(x1, x2, x3, x4, y1, y2, y3, y4) + { + mstore_internal(0:i32, x1, x2, x3, x4) + mstore_internal(32:i32, y1, y2, y3, y4) + eth.storageStore(0:i32, 32:i32) + } + } +} + + +Binary representation: +0061736d0100000001480a60000060017e017e60027e7e017e60037e7e7e017e60047e7e7e7e017e60057e7e7e7e7e0060087e7e7e7e7e7e7e7e0060087e7e7e7e7e7e7e7e017e60027f7f0060037f7f7f0002310208657468657265756d0c73746f7261676553746f7265000808657468657265756d0c63616c6c44617461436f70790009030e0d0003070407020704010101050605030100010610037e0142000b7e0142000b7e0142000b071102066d656d6f72790200046d61696e00020a80090dee02011f7e4200210002402000200020002000100921012300210223012103230221040b2001210520022106200321072004210842012109200020008420002009848450ada745ada745ad210a02400340200aa745ad500d01024002402005200620072008200020002000420a1008210b2300210c2301210d2302210e0b0240200b200c200d200e1005210f2300211023012111230221120b200f20108420112012848450ada745ad42005204400c030b024020052006200720082000200020004202100621132300211423012115230221160b201320148420152016848450ada745ad42005204400c030b0240200520062007200820002000200042041006211723002118230121192302211a0b20172018842019201a848450ada745ad42005204400c010b0b0240200520062007200820002000200020091004211b2300211c2301211d2302211e0b201b2105201c2106201d2107201e21080b0b20002000200020002005200620072008100e0b2c01037e200020017c2105200520027c21032005200054ada72003200554ada772ada7ad21042004240020030b6f010b7e200320077c210c200c42007c210b024020022006200c200354ada7200b200c54ada772ada7ad1003210d2300210e0b200d210a024020012005200e1003210f230021100b200f2109024020002004201010032111230021120b2011210820092400200a2401200b240220080b2301047e200020018420022003848450ada7ad210720052400200624012007240220040b4601047e2000200451ad42005204402001200551ad42005204402002200651ad42005204402003200751ad42005204404201210b0b0b0b0b20092400200a2401200b240220080b2a01027e02402000200154ad21032003420151044042ffffffff0f2102052000200152ad21020b0b20020b930101087e4200210c0240200020041007210d200d42005104400240200120051007210e200e42005104400240200220061007210f200f42005104402003200754ad210c05200f42015104404200210c054201210c0b0b0b05200e42015104404200210c054201210c0b0b0b05200d42015104404200210c054201210c0b0b0b200ca7ad210b20092400200a2401200b240220080b8c0101087e4200200020018420028452ad4200520440000b4200200342208852ad4200520440000b4200a72003a7ada74220a710014200a7290300100c21084200a74208a76aada7290300100c21094200a74210a76aada7290300100c210a4200a74218a76aada7290300100c210b2008210420092105200a2106200b210720052400200624012007240220040b1c01017e20004208864280fe0383200042088842ff018384210120010b1b01027e2000100a421086210220022000421088100a84210120010b1b01027e2000100b422086210220022000422088100b84210120010b3e01007e2000a72001100c3703002000a74208a76aada72002100c3703002000a74210a76aada72003100c3703002000a74218a76aada72004100c3703000b2401007e42002000200120022003100d42202004200520062007100d4200a74220a710000b + +Text representation: +(module + (import "ethereum" "storageStore" (func $eth.storageStore (param i32 i32))) + (import "ethereum" "callDataCopy" (func $eth.callDataCopy (param i32 i32 i32))) + (memory $memory (export "memory") 1) + (export "main" (func $main)) + (global $global_ (mut i64) (i64.const 0)) + (global $global__1 (mut i64) (i64.const 0)) + (global $global__2 (mut i64) (i64.const 0)) + +(func $main + (local $_1 i64) + (local $x i64) + (local $x_1 i64) + (local $x_2 i64) + (local $x_3 i64) + (local $x_4 i64) + (local $x_5 i64) + (local $x_6 i64) + (local $x_7 i64) + (local $_2 i64) + (local $_3 i64) + (local $_4 i64) + (local $_5 i64) + (local $_6 i64) + (local $_7 i64) + (local $_8 i64) + (local $_9 i64) + (local $_10 i64) + (local $_11 i64) + (local $_12 i64) + (local $_13 i64) + (local $_14 i64) + (local $_15 i64) + (local $_16 i64) + (local $_17 i64) + (local $_18 i64) + (local $_19 i64) + (local $x_8 i64) + (local $x_9 i64) + (local $x_10 i64) + (local $x_11 i64) + (local.set $_1 (i64.const 0)) + (block + (local.set $x (call $calldataload (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1))) + (local.set $x_1 (global.get $global_)) + (local.set $x_2 (global.get $global__1)) + (local.set $x_3 (global.get $global__2)) + + ) + (local.set $x_4 (local.get $x)) + (local.set $x_5 (local.get $x_1)) + (local.set $x_6 (local.get $x_2)) + (local.set $x_7 (local.get $x_3)) + (local.set $_2 (i64.const 1)) + (local.set $_3 (i64.extend_i32_u (i32.eqz (i32.wrap_i64 (i64.extend_i32_u (i32.eqz (i32.wrap_i64 (i64.extend_i32_u (i64.eqz (i64.or (i64.or (local.get $_1) (local.get $_1)) (i64.or (local.get $_1) (local.get $_2)))))))))))) + (block $label_ + (loop + (br_if $label_ (i64.eqz (i64.extend_i32_u (i32.eqz (i32.wrap_i64 (local.get $_3)))))) + (block $label__3 + (block + (local.set $_4 (call $lt (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7) (local.get $_1) (local.get $_1) (local.get $_1) (i64.const 10))) + (local.set $_5 (global.get $global_)) + (local.set $_6 (global.get $global__1)) + (local.set $_7 (global.get $global__2)) + + ) + (block + (local.set $_8 (call $iszero (local.get $_4) (local.get $_5) (local.get $_6) (local.get $_7))) + (local.set $_9 (global.get $global_)) + (local.set $_10 (global.get $global__1)) + (local.set $_11 (global.get $global__2)) + + ) + (if (i64.ne (i64.extend_i32_u (i32.eqz (i32.wrap_i64 (i64.extend_i32_u (i64.eqz (i64.or (i64.or (local.get $_8) (local.get $_9)) (i64.or (local.get $_10) (local.get $_11)))))))) (i64.const 0)) (then + (br $label_) + )) + (block + (local.set $_12 (call $eq (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7) (local.get $_1) (local.get $_1) (local.get $_1) (i64.const 2))) + (local.set $_13 (global.get $global_)) + (local.set $_14 (global.get $global__1)) + (local.set $_15 (global.get $global__2)) + + ) + (if (i64.ne (i64.extend_i32_u (i32.eqz (i32.wrap_i64 (i64.extend_i32_u (i64.eqz (i64.or (i64.or (local.get $_12) (local.get $_13)) (i64.or (local.get $_14) (local.get $_15)))))))) (i64.const 0)) (then + (br $label_) + )) + (block + (local.set $_16 (call $eq (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7) (local.get $_1) (local.get $_1) (local.get $_1) (i64.const 4))) + (local.set $_17 (global.get $global_)) + (local.set $_18 (global.get $global__1)) + (local.set $_19 (global.get $global__2)) + + ) + (if (i64.ne (i64.extend_i32_u (i32.eqz (i32.wrap_i64 (i64.extend_i32_u (i64.eqz (i64.or (i64.or (local.get $_16) (local.get $_17)) (i64.or (local.get $_18) (local.get $_19)))))))) (i64.const 0)) (then + (br $label__3) + )) + + ) + (block + (local.set $x_8 (call $add (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_2))) + (local.set $x_9 (global.get $global_)) + (local.set $x_10 (global.get $global__1)) + (local.set $x_11 (global.get $global__2)) + + ) + (local.set $x_4 (local.get $x_8)) + (local.set $x_5 (local.get $x_9)) + (local.set $x_6 (local.get $x_10)) + (local.set $x_7 (local.get $x_11)) + ) + + ) + (call $sstore (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1) (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7)) +) + +(func $add_carry + (param $x i64) + (param $y i64) + (param $c i64) + (result i64) + (local $r i64) + (local $r_c i64) + (local $t i64) + (local.set $t (i64.add (local.get $x) (local.get $y))) + (local.set $r (i64.add (local.get $t) (local.get $c))) + (local.set $r_c (i64.extend_i32_u (i32.wrap_i64 (i64.extend_i32_u (i32.or (i32.wrap_i64 (i64.extend_i32_u (i64.lt_u (local.get $t) (local.get $x)))) (i32.wrap_i64 (i64.extend_i32_u (i64.lt_u (local.get $r) (local.get $t))))))))) + (global.set $global_ (local.get $r_c)) + (local.get $r) +) + +(func $add + (param $x1 i64) + (param $x2 i64) + (param $x3 i64) + (param $x4 i64) + (param $y1 i64) + (param $y2 i64) + (param $y3 i64) + (param $y4 i64) + (result i64) + (local $r1 i64) + (local $r2 i64) + (local $r3 i64) + (local $r4 i64) + (local $t i64) + (local $r3_1 i64) + (local $carry i64) + (local $r2_1 i64) + (local $carry_1 i64) + (local $r1_1 i64) + (local $carry_2 i64) + (local.set $t (i64.add (local.get $x4) (local.get $y4))) + (local.set $r4 (i64.add (local.get $t) (i64.const 0))) + (block + (local.set $r3_1 (call $add_carry (local.get $x3) (local.get $y3) (i64.extend_i32_u (i32.wrap_i64 (i64.extend_i32_u (i32.or (i32.wrap_i64 (i64.extend_i32_u (i64.lt_u (local.get $t) (local.get $x4)))) (i32.wrap_i64 (i64.extend_i32_u (i64.lt_u (local.get $r4) (local.get $t)))))))))) + (local.set $carry (global.get $global_)) + + ) + (local.set $r3 (local.get $r3_1)) + (block + (local.set $r2_1 (call $add_carry (local.get $x2) (local.get $y2) (local.get $carry))) + (local.set $carry_1 (global.get $global_)) + + ) + (local.set $r2 (local.get $r2_1)) + (block + (local.set $r1_1 (call $add_carry (local.get $x1) (local.get $y1) (local.get $carry_1))) + (local.set $carry_2 (global.get $global_)) + + ) + (local.set $r1 (local.get $r1_1)) + (global.set $global_ (local.get $r2)) + (global.set $global__1 (local.get $r3)) + (global.set $global__2 (local.get $r4)) + (local.get $r1) +) + +(func $iszero + (param $x1 i64) + (param $x2 i64) + (param $x3 i64) + (param $x4 i64) + (result i64) + (local $r1 i64) + (local $r2 i64) + (local $r3 i64) + (local $r4 i64) + (local.set $r4 (i64.extend_i32_u (i32.wrap_i64 (i64.extend_i32_u (i64.eqz (i64.or (i64.or (local.get $x1) (local.get $x2)) (i64.or (local.get $x3) (local.get $x4)))))))) + (global.set $global_ (local.get $r2)) + (global.set $global__1 (local.get $r3)) + (global.set $global__2 (local.get $r4)) + (local.get $r1) +) + +(func $eq + (param $x1 i64) + (param $x2 i64) + (param $x3 i64) + (param $x4 i64) + (param $y1 i64) + (param $y2 i64) + (param $y3 i64) + (param $y4 i64) + (result i64) + (local $r1 i64) + (local $r2 i64) + (local $r3 i64) + (local $r4 i64) + (if (i64.ne (i64.extend_i32_u (i64.eq (local.get $x1) (local.get $y1))) (i64.const 0)) (then + (if (i64.ne (i64.extend_i32_u (i64.eq (local.get $x2) (local.get $y2))) (i64.const 0)) (then + (if (i64.ne (i64.extend_i32_u (i64.eq (local.get $x3) (local.get $y3))) (i64.const 0)) (then + (if (i64.ne (i64.extend_i32_u (i64.eq (local.get $x4) (local.get $y4))) (i64.const 0)) (then + (local.set $r4 (i64.const 1)) + )) + )) + )) + )) + (global.set $global_ (local.get $r2)) + (global.set $global__1 (local.get $r3)) + (global.set $global__2 (local.get $r4)) + (local.get $r1) +) + +(func $cmp + (param $a i64) + (param $b i64) + (result i64) + (local $r i64) + (local $condition i64) + (block + (local.set $condition (i64.extend_i32_u (i64.lt_u (local.get $a) (local.get $b)))) + (if (i64.eq (local.get $condition) (i64.const 1)) (then + (local.set $r (i64.const 4294967295)) + )(else + (local.set $r (i64.extend_i32_u (i64.ne (local.get $a) (local.get $b)))) + )) + + ) + (local.get $r) +) + +(func $lt + (param $x1 i64) + (param $x2 i64) + (param $x3 i64) + (param $x4 i64) + (param $y1 i64) + (param $y2 i64) + (param $y3 i64) + (param $y4 i64) + (result i64) + (local $z1 i64) + (local $z2 i64) + (local $z3 i64) + (local $z4 i64) + (local $z i64) + (local $condition_4 i64) + (local $condition_5 i64) + (local $condition_6 i64) + (local.set $z (i64.const 0)) + (block + (local.set $condition_4 (call $cmp (local.get $x1) (local.get $y1))) + (if (i64.eq (local.get $condition_4) (i64.const 0)) (then + (block + (local.set $condition_5 (call $cmp (local.get $x2) (local.get $y2))) + (if (i64.eq (local.get $condition_5) (i64.const 0)) (then + (block + (local.set $condition_6 (call $cmp (local.get $x3) (local.get $y3))) + (if (i64.eq (local.get $condition_6) (i64.const 0)) (then + (local.set $z (i64.extend_i32_u (i64.lt_u (local.get $x4) (local.get $y4)))) + )(else + (if (i64.eq (local.get $condition_6) (i64.const 1)) (then + (local.set $z (i64.const 0)) + )(else + (local.set $z (i64.const 1)) + )) + )) + + ) + )(else + (if (i64.eq (local.get $condition_5) (i64.const 1)) (then + (local.set $z (i64.const 0)) + )(else + (local.set $z (i64.const 1)) + )) + )) + + ) + )(else + (if (i64.eq (local.get $condition_4) (i64.const 1)) (then + (local.set $z (i64.const 0)) + )(else + (local.set $z (i64.const 1)) + )) + )) + + ) + (local.set $z4 (i64.extend_i32_u (i32.wrap_i64 (local.get $z)))) + (global.set $global_ (local.get $z2)) + (global.set $global__1 (local.get $z3)) + (global.set $global__2 (local.get $z4)) + (local.get $z1) +) + +(func $calldataload + (param $x1 i64) + (param $x2 i64) + (param $x3 i64) + (param $x4 i64) + (result i64) + (local $z1 i64) + (local $z2 i64) + (local $z3 i64) + (local $z4 i64) + (local $z1_1 i64) + (local $z2_1 i64) + (local $z3_1 i64) + (local $z4_1 i64) + (if (i64.ne (i64.extend_i32_u (i64.ne (i64.const 0) (i64.or (i64.or (local.get $x1) (local.get $x2)) (local.get $x3)))) (i64.const 0)) (then + (unreachable))) + (if (i64.ne (i64.extend_i32_u (i64.ne (i64.const 0) (i64.shr_u (local.get $x4) (i64.const 32)))) (i64.const 0)) (then + (unreachable))) + (call $eth.callDataCopy (i32.wrap_i64 (i64.const 0)) (i32.wrap_i64 (i64.extend_i32_u (i32.wrap_i64 (local.get $x4)))) (i32.wrap_i64 (i64.const 32))) + (local.set $z1_1 (call $endian_swap (i64.load (i32.wrap_i64 (i64.const 0))))) + (local.set $z2_1 (call $endian_swap (i64.load (i32.wrap_i64 (i64.extend_i32_u (i32.add (i32.wrap_i64 (i64.const 0)) (i32.wrap_i64 (i64.const 8)))))))) + (local.set $z3_1 (call $endian_swap (i64.load (i32.wrap_i64 (i64.extend_i32_u (i32.add (i32.wrap_i64 (i64.const 0)) (i32.wrap_i64 (i64.const 16)))))))) + (local.set $z4_1 (call $endian_swap (i64.load (i32.wrap_i64 (i64.extend_i32_u (i32.add (i32.wrap_i64 (i64.const 0)) (i32.wrap_i64 (i64.const 24)))))))) + (local.set $z1 (local.get $z1_1)) + (local.set $z2 (local.get $z2_1)) + (local.set $z3 (local.get $z3_1)) + (local.set $z4 (local.get $z4_1)) + (global.set $global_ (local.get $z2)) + (global.set $global__1 (local.get $z3)) + (global.set $global__2 (local.get $z4)) + (local.get $z1) +) + +(func $endian_swap_16 + (param $x i64) + (result i64) + (local $y i64) + (local.set $y (i64.or (i64.and (i64.shl (local.get $x) (i64.const 8)) (i64.const 65280)) (i64.and (i64.shr_u (local.get $x) (i64.const 8)) (i64.const 255)))) + (local.get $y) +) + +(func $endian_swap_32 + (param $x i64) + (result i64) + (local $y i64) + (local $hi i64) + (local.set $hi (i64.shl (call $endian_swap_16 (local.get $x)) (i64.const 16))) + (local.set $y (i64.or (local.get $hi) (call $endian_swap_16 (i64.shr_u (local.get $x) (i64.const 16))))) + (local.get $y) +) + +(func $endian_swap + (param $x i64) + (result i64) + (local $y i64) + (local $hi i64) + (local.set $hi (i64.shl (call $endian_swap_32 (local.get $x)) (i64.const 32))) + (local.set $y (i64.or (local.get $hi) (call $endian_swap_32 (i64.shr_u (local.get $x) (i64.const 32))))) + (local.get $y) +) + +(func $mstore_internal + (param $pos i64) + (param $y1 i64) + (param $y2 i64) + (param $y3 i64) + (param $y4 i64) + (i64.store (i32.wrap_i64 (local.get $pos)) (call $endian_swap (local.get $y1))) + (i64.store (i32.wrap_i64 (i64.extend_i32_u (i32.add (i32.wrap_i64 (local.get $pos)) (i32.wrap_i64 (i64.const 8))))) (call $endian_swap (local.get $y2))) + (i64.store (i32.wrap_i64 (i64.extend_i32_u (i32.add (i32.wrap_i64 (local.get $pos)) (i32.wrap_i64 (i64.const 16))))) (call $endian_swap (local.get $y3))) + (i64.store (i32.wrap_i64 (i64.extend_i32_u (i32.add (i32.wrap_i64 (local.get $pos)) (i32.wrap_i64 (i64.const 24))))) (call $endian_swap (local.get $y4))) +) + +(func $sstore + (param $x1 i64) + (param $x2 i64) + (param $x3 i64) + (param $x4 i64) + (param $y1 i64) + (param $y2 i64) + (param $y3 i64) + (param $y4 i64) + (call $mstore_internal (i64.const 0) (local.get $x1) (local.get $x2) (local.get $x3) (local.get $x4)) + (call $mstore_internal (i64.const 32) (local.get $y1) (local.get $y2) (local.get $y3) (local.get $y4)) + (call $eth.storageStore (i32.wrap_i64 (i64.const 0)) (i32.wrap_i64 (i64.const 32))) +) + +) diff --git a/test/libyul/ewasmTranslationTests/loop_break.yul b/test/libyul/ewasmTranslationTests/loop_break.yul new file mode 100644 index 000000000..b473988d5 --- /dev/null +++ b/test/libyul/ewasmTranslationTests/loop_break.yul @@ -0,0 +1,13 @@ +{ + let i := 0 + for { } lt(i, 10) { i := add(i, 1) } { + if eq(i, 3) { break } + } + sstore(0, i) +} +// ---- +// Trace: +// Memory dump: +// 20: 0000000000000000000000000000000000000000000000000000000000000003 +// Storage dump: +// 0000000000000000000000000000000000000000000000000000000000000000: 0000000000000000000000000000000000000000000000000000000000000003 diff --git a/test/libyul/ewasmTranslationTests/loop_continue.yul b/test/libyul/ewasmTranslationTests/loop_continue.yul new file mode 100644 index 000000000..31200c2fe --- /dev/null +++ b/test/libyul/ewasmTranslationTests/loop_continue.yul @@ -0,0 +1,22 @@ +{ + let i := 0 + for { } lt(i, 10) { i := add(i, 1) } { + if eq(i, 3) { continue } + sstore(add(i, 0x10), i) + } + sstore(0, i) +} +// ---- +// Trace: +// Memory dump: +// 20: 000000000000000000000000000000000000000000000000000000000000000a +// Storage dump: +// 0000000000000000000000000000000000000000000000000000000000000000: 000000000000000000000000000000000000000000000000000000000000000a +// 0000000000000000000000000000000000000000000000000000000000000011: 0000000000000000000000000000000000000000000000000000000000000001 +// 0000000000000000000000000000000000000000000000000000000000000012: 0000000000000000000000000000000000000000000000000000000000000002 +// 0000000000000000000000000000000000000000000000000000000000000014: 0000000000000000000000000000000000000000000000000000000000000004 +// 0000000000000000000000000000000000000000000000000000000000000015: 0000000000000000000000000000000000000000000000000000000000000005 +// 0000000000000000000000000000000000000000000000000000000000000016: 0000000000000000000000000000000000000000000000000000000000000006 +// 0000000000000000000000000000000000000000000000000000000000000017: 0000000000000000000000000000000000000000000000000000000000000007 +// 0000000000000000000000000000000000000000000000000000000000000018: 0000000000000000000000000000000000000000000000000000000000000008 +// 0000000000000000000000000000000000000000000000000000000000000019: 0000000000000000000000000000000000000000000000000000000000000009