aboutsummaryrefslogtreecommitdiffstats
path: root/DeclarationContainer.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-04-15 23:40:50 +0800
committerchriseth <c@ethdev.com>2015-04-15 23:40:50 +0800
commit0c69d5fdcd3286f47c81dbcbcfb8802861eab8b5 (patch)
treef78c665e6084300b939cc4cfcebb97d3bd44d9f5 /DeclarationContainer.cpp
parent158795e48f4285d713b11f78cdd04de8c6d1f667 (diff)
downloaddexon-solidity-0c69d5fdcd3286f47c81dbcbcfb8802861eab8b5.tar
dexon-solidity-0c69d5fdcd3286f47c81dbcbcfb8802861eab8b5.tar.gz
dexon-solidity-0c69d5fdcd3286f47c81dbcbcfb8802861eab8b5.tar.bz2
dexon-solidity-0c69d5fdcd3286f47c81dbcbcfb8802861eab8b5.tar.lz
dexon-solidity-0c69d5fdcd3286f47c81dbcbcfb8802861eab8b5.tar.xz
dexon-solidity-0c69d5fdcd3286f47c81dbcbcfb8802861eab8b5.tar.zst
dexon-solidity-0c69d5fdcd3286f47c81dbcbcfb8802861eab8b5.zip
Fixed function overloads.
Added tests, disallowed non-calling usage of non-unique function references.
Diffstat (limited to 'DeclarationContainer.cpp')
-rw-r--r--DeclarationContainer.cpp29
1 files changed, 14 insertions, 15 deletions
diff --git a/DeclarationContainer.cpp b/DeclarationContainer.cpp
index 226b9d68..565f71df 100644
--- a/DeclarationContainer.cpp
+++ b/DeclarationContainer.cpp
@@ -35,30 +35,29 @@ bool DeclarationContainer::registerDeclaration(Declaration const& _declaration,
if (name.empty())
return true;
- if (!_update)
+ if (_update)
+ {
+ solAssert(!dynamic_cast<FunctionDefinition const*>(&_declaration), "Attempt to update function definition.");
+ m_declarations[name].clear();
+ m_invisibleDeclarations[name].clear();
+ }
+ else
{
if (dynamic_cast<FunctionDefinition const*>(&_declaration))
{
- // other declarations must be FunctionDefinition, otherwise clash with other declarations.
- for (auto&& declaration: m_declarations[_declaration.getName()])
- if (dynamic_cast<FunctionDefinition const*>(declaration) == nullptr)
+ // check that all other declarations with the same name are functions
+ for (auto&& declaration: m_invisibleDeclarations[name] + m_declarations[name])
+ if (!dynamic_cast<FunctionDefinition const*>(declaration))
return false;
}
- else if (m_declarations.count(_declaration.getName()) != 0)
- return false;
- }
- else
- {
- // update declaration
- solAssert(dynamic_cast<FunctionDefinition const*>(&_declaration) == nullptr, "cannot be FunctionDefinition");
-
- m_declarations[_declaration.getName()].clear();
+ else if (m_declarations.count(name) > 0 || m_invisibleDeclarations.count(name) > 0)
+ return false;
}
if (_invisible)
- m_invisibleDeclarations.insert(name);
+ m_invisibleDeclarations[name].insert(&_declaration);
else
- m_declarations[_declaration.getName()].insert(&_declaration);
+ m_declarations[name].insert(&_declaration);
return true;
}