diff options
-rw-r--r-- | libevmasm/RuleList.h | 2 | ||||
-rw-r--r-- | libsolidity/formal/SMTChecker.cpp | 10 | ||||
-rw-r--r-- | solc/CommandLineInterface.cpp | 8 | ||||
-rwxr-xr-x | test/cmdlineTests.sh | 50 |
4 files changed, 63 insertions, 7 deletions
diff --git a/libevmasm/RuleList.h b/libevmasm/RuleList.h index 7a2bc484..0573856b 100644 --- a/libevmasm/RuleList.h +++ b/libevmasm/RuleList.h @@ -46,7 +46,7 @@ template <class S> S modWorkaround(S const& _a, S const& _b) /// @returns a list of simplification rules given certain match placeholders. /// A, B and C should represent constants, X and Y arbitrary expressions. -/// The simplifications should neven change the order of evaluation of +/// The simplifications should never change the order of evaluation of /// arbitrary operations. template <class Pattern> std::vector<SimplificationRule<Pattern>> simplificationRuleList( diff --git a/libsolidity/formal/SMTChecker.cpp b/libsolidity/formal/SMTChecker.cpp index 17b50a38..88c1e56a 100644 --- a/libsolidity/formal/SMTChecker.cpp +++ b/libsolidity/formal/SMTChecker.cpp @@ -375,8 +375,14 @@ void SMTChecker::endVisit(Identifier const& _identifier) } else if (SSAVariable::isSupportedType(_identifier.annotation().type->category())) { - VariableDeclaration const& decl = dynamic_cast<VariableDeclaration const&>(*(_identifier.annotation().referencedDeclaration)); - defineExpr(_identifier, currentValue(decl)); + if (VariableDeclaration const* decl = dynamic_cast<VariableDeclaration const*>(_identifier.annotation().referencedDeclaration)) + defineExpr(_identifier, currentValue(*decl)); + else + // TODO: handle MagicVariableDeclaration here + m_errorReporter.warning( + _identifier.location(), + "Assertion checker does not yet support the type of this variable." + ); } else if (FunctionType const* fun = dynamic_cast<FunctionType const*>(_identifier.annotation().type.get())) { diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 14793759..429bd637 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -402,11 +402,11 @@ bool CommandLineInterface::readInputFilesAndConfigureRemappings() { if (!ignoreMissing) { - cerr << "\"" << infile << "\" is not found" << endl; + cerr << infile << " is not found." << endl; return false; } else - cerr << "\"" << infile << "\" is not found. Skipping." << endl; + cerr << infile << " is not found. Skipping." << endl; continue; } @@ -415,11 +415,11 @@ bool CommandLineInterface::readInputFilesAndConfigureRemappings() { if (!ignoreMissing) { - cerr << "\"" << infile << "\" is not a valid file" << endl; + cerr << infile << " is not a valid file." << endl; return false; } else - cerr << "\"" << infile << "\" is not a valid file. Skipping." << endl; + cerr << infile << " is not a valid file. Skipping." << endl; continue; } diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh index d0296515..7256386d 100755 --- a/test/cmdlineTests.sh +++ b/test/cmdlineTests.sh @@ -94,6 +94,56 @@ printTask "Testing unknown options..." fi ) +# General helper function for testing SOLC behaviour, based on file name, compile opts, exit code, stdout and stderr. +# An failure is expected. +test_solc_file_input_failures() { + local filename="${1}" + local solc_args="${2}" + local stdout_expected="${3}" + local stderr_expected="${4}" + local stdout_path=`mktemp` + local stderr_path=`mktemp` + + set +e + "$SOLC" "${filename}" ${solc_args} 1>$stdout_path 2>$stderr_path + exitCode=$? + set -e + + if [[ $exitCode -eq 0 ]]; then + printError "Incorrect exit code. Expected failure (non-zero) but got success (0)." + rm -f $stdout_path $stderr_path + exit 1 + fi + + if [[ "$(cat $stdout_path)" != "${stdout_expected}" ]]; then + printError "Incorrect output on stderr received. Expected:" + echo -e "${stdout_expected}" + + printError "But got:" + cat $stdout_path + rm -f $stdout_path $stderr_path + exit 1 + fi + + if [[ "$(cat $stderr_path)" != "${stderr_expected}" ]]; then + printError "Incorrect output on stderr received. Expected:" + echo -e "${stderr_expected}" + + printError "But got:" + cat $stderr_path + rm -f $stdout_path $stderr_path + exit 1 + fi + + rm -f $stdout_path $stderr_path +} + +printTask "Testing passing files that are not found..." +test_solc_file_input_failures "file_not_found.sol" "" "" "\"file_not_found.sol\" is not found." + +printTask "Testing passing files that are not files..." +test_solc_file_input_failures "." "" "" "\".\" is not a valid file." + printTask "Compiling various other contracts and libraries..." ( cd "$REPO_ROOT"/test/compilationTests/ |