From fe2b9a3b3c73b77069a0d6d36578f60e1f8d4203 Mon Sep 17 00:00:00 2001 From: LianaHus Date: Tue, 29 Sep 2015 18:22:02 +0200 Subject: added warning for noninitialized references in storage. --- test/libsolidity/SolidityNameAndTypeResolution.cpp | 32 ++++++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'test') diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index fd908955..ad7b59ce 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -45,7 +45,7 @@ namespace { pair, shared_ptr> -parseAnalyseAndReturnError(string const& _source) +parseAnalyseAndReturnError(string const& _source, bool _warning = false) { Parser parser; ASTPointer sourceUnit; @@ -74,7 +74,19 @@ parseAnalyseAndReturnError(string const& _source) TypeChecker typeChecker; if (!typeChecker.checkTypeRequirements(*contract)) { - err = typeChecker.errors().front(); + for (auto const& firstError: typeChecker.errors()) + { + if (!dynamic_pointer_cast(firstError)) + { + err = firstError; + break; + } + else if (_warning) + { + err = firstError; + break; + } + } break; } } @@ -101,9 +113,9 @@ ASTPointer parseAndAnalyse(string const& _source) return sourceAndError.first; } -shared_ptr parseAndAnalyseReturnError(std::string const& _source) +shared_ptr parseAndAnalyseReturnError(std::string const& _source, bool _warning = false) { - auto sourceAndError = parseAnalyseAndReturnError(_source); + auto sourceAndError = parseAnalyseAndReturnError(_source, _warning); BOOST_REQUIRE(!!sourceAndError.second); return sourceAndError.second; } @@ -119,8 +131,10 @@ static ContractDefinition const* retrieveContract(ASTPointer _source return nullptr; } -static FunctionTypePointer const& retrieveFunctionBySignature(ContractDefinition const* _contract, - std::string const& _signature) +static FunctionTypePointer const& retrieveFunctionBySignature( + ContractDefinition const* _contract, + std::string const& _signature +) { FixedHash<4> hash(dev::sha3(_signature)); return _contract->interfaceFunctions()[hash]; @@ -155,8 +169,8 @@ BOOST_AUTO_TEST_CASE(double_stateVariable_declaration) BOOST_AUTO_TEST_CASE(double_function_declaration) { char const* text = "contract test {\n" - " function fun() { var x; }\n" - " function fun() { var x; }\n" + " function fun() { uint x; }\n" + " function fun() { uint x; }\n" "}\n"; SOLIDITY_CHECK_ERROR_TYPE(parseAndAnalyseReturnError(text), DeclarationError); } @@ -2333,7 +2347,7 @@ BOOST_AUTO_TEST_CASE(non_initialized_references) } } )"; - SOLIDITY_CHECK_ERROR_TYPE(parseAndAnalyseReturnError(text), TypeError); + SOLIDITY_CHECK_ERROR_TYPE(parseAndAnalyseReturnError(text, true), Warning); } BOOST_AUTO_TEST_SUITE_END() -- cgit v1.2.3