aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis
diff options
context:
space:
mode:
authorFederico Bond <federicobond@gmail.com>2017-07-20 06:22:36 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-08-12 05:45:25 +0800
commitd4997dd9a3ec10767d8ee289207fdf0ea6b45f0a (patch)
tree4db636a244f5577586fc69e10a9adb79e8b39015 /libsolidity/analysis
parenta6949851f332df8d05bef3cb2cd45105a02100a5 (diff)
downloaddexon-solidity-d4997dd9a3ec10767d8ee289207fdf0ea6b45f0a.tar
dexon-solidity-d4997dd9a3ec10767d8ee289207fdf0ea6b45f0a.tar.gz
dexon-solidity-d4997dd9a3ec10767d8ee289207fdf0ea6b45f0a.tar.bz2
dexon-solidity-d4997dd9a3ec10767d8ee289207fdf0ea6b45f0a.tar.lz
dexon-solidity-d4997dd9a3ec10767d8ee289207fdf0ea6b45f0a.tar.xz
dexon-solidity-d4997dd9a3ec10767d8ee289207fdf0ea6b45f0a.tar.zst
dexon-solidity-d4997dd9a3ec10767d8ee289207fdf0ea6b45f0a.zip
Use a secondary location for function override errors
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp39
-rw-r--r--libsolidity/analysis/TypeChecker.h1
2 files changed, 16 insertions, 24 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index df791be9..2a9ca5a8 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -306,40 +306,31 @@ void TypeChecker::checkFunctionOverride(FunctionDefinition const& function, Func
return;
if (function.visibility() != super.visibility())
- m_errorReporter.typeError(
- function.location(),
- "Overriding function visibility differs from " + super.fullyQualifiedName() + "."
- );
+ overrideError(function, super, "Overriding function visibility differs.");
if (function.isDeclaredConst() && !super.isDeclaredConst())
- m_errorReporter.typeError(
- function.location(),
- "Overriding function should not be declared constant."
- );
+ overrideError(function, super, "Overriding function should not be declared constant.");
if (!function.isDeclaredConst() && super.isDeclaredConst())
- m_errorReporter.typeError(
- function.location(),
- "Overriding function should be declared constant."
- );
+ overrideError(function, super, "Overriding function should be declared constant.");
if (function.isPayable() && !super.isPayable())
- m_errorReporter.typeError(
- function.location(),
- "Overriding function should not be declared payable."
- );
+ overrideError(function, super, "Overriding function should not be declared payable.");
if (!function.isPayable() && super.isPayable())
- m_errorReporter.typeError(
- function.location(),
- "Overriding function should be declared payable."
- );
+ overrideError(function, super, "Overriding function should be declared payable.");
if (functionType != superType)
- m_errorReporter.typeError(
- function.location(),
- "Overriding function return types differ from " + super.fullyQualifiedName() + "."
- );
+ overrideError(function, super, "Overriding function return types differ.");
+}
+
+void TypeChecker::overrideError(FunctionDefinition const& function, FunctionDefinition const& super, string message)
+{
+ m_errorReporter.typeError(
+ function.location(),
+ SecondarySourceLocation().append("Overriden function is here:", super.location()),
+ message
+ );
}
void TypeChecker::checkContractExternalTypeClashes(ContractDefinition const& _contract)
diff --git a/libsolidity/analysis/TypeChecker.h b/libsolidity/analysis/TypeChecker.h
index f1004e92..f2e13765 100644
--- a/libsolidity/analysis/TypeChecker.h
+++ b/libsolidity/analysis/TypeChecker.h
@@ -64,6 +64,7 @@ private:
void checkContractIllegalOverrides(ContractDefinition const& _contract);
/// Reports a type error with an appropiate message if overriden function signature differs.
void checkFunctionOverride(FunctionDefinition const& function, FunctionDefinition const& super);
+ void overrideError(FunctionDefinition const& function, FunctionDefinition const& super, std::string message);
void checkContractAbstractFunctions(ContractDefinition const& _contract);
void checkContractAbstractConstructors(ContractDefinition const& _contract);
/// Checks that different functions with external visibility end up having different