aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis
diff options
context:
space:
mode:
authorDaniel Kirchner <daniel@ekpyron.org>2018-03-06 06:13:51 +0800
committerDaniel Kirchner <daniel@ekpyron.org>2018-03-06 06:16:26 +0800
commit91b13b734d34e6bb5a76fb53624588d035946237 (patch)
treec0fe84429572c32cffda17009d350f7ddd6cbda7 /libsolidity/analysis
parent2213f9946b34a6e8f5604a6b821d31788dcee08b (diff)
downloaddexon-solidity-91b13b734d34e6bb5a76fb53624588d035946237.tar.gz
dexon-solidity-91b13b734d34e6bb5a76fb53624588d035946237.tar.zst
dexon-solidity-91b13b734d34e6bb5a76fb53624588d035946237.zip
Use StaticAnalyzer to deprecate msg.gas instead of conditionally removing it in MagicType.
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r--libsolidity/analysis/StaticAnalyzer.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/libsolidity/analysis/StaticAnalyzer.cpp b/libsolidity/analysis/StaticAnalyzer.cpp
index bd8ee597..d4de219a 100644
--- a/libsolidity/analysis/StaticAnalyzer.cpp
+++ b/libsolidity/analysis/StaticAnalyzer.cpp
@@ -139,6 +139,23 @@ bool StaticAnalyzer::visit(ExpressionStatement const& _statement)
bool StaticAnalyzer::visit(MemberAccess const& _memberAccess)
{
+ bool const v050 = m_currentContract->sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050);
+
+ if (MagicType const* type = dynamic_cast<MagicType const*>(_memberAccess.expression().annotation().type.get()))
+ if (type->kind() == MagicType::Kind::Message && _memberAccess.memberName() == "gas")
+ {
+ if (v050)
+ m_errorReporter.typeError(
+ _memberAccess.location(),
+ "\"msg.gas\" has been deprecated in favor of \"gasleft()\""
+ );
+ else
+ m_errorReporter.warning(
+ _memberAccess.location(),
+ "\"msg.gas\" has been deprecated in favor of \"gasleft()\""
+ );
+ }
+
if (m_nonPayablePublic && !m_library)
if (MagicType const* type = dynamic_cast<MagicType const*>(_memberAccess.expression().annotation().type.get()))
if (type->kind() == MagicType::Kind::Message && _memberAccess.memberName() == "value")
@@ -151,7 +168,7 @@ bool StaticAnalyzer::visit(MemberAccess const& _memberAccess)
if (auto const* type = dynamic_cast<FunctionType const*>(_memberAccess.annotation().type.get()))
if (type->kind() == FunctionType::Kind::BareCallCode)
{
- if (m_currentContract->sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050))
+ if (v050)
m_errorReporter.typeError(
_memberAccess.location(),
"\"callcode\" has been deprecated in favour of \"delegatecall\"."