mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Warn if no visibility is specified on contract functions.
This commit is contained in:
parent
1c85ba10e1
commit
5b5367dc12
@ -4,6 +4,7 @@ Features:
|
|||||||
* Support ``pragma experimental v0.5.0;`` to turn on upcoming breaking changes.
|
* Support ``pragma experimental v0.5.0;`` to turn on upcoming breaking changes.
|
||||||
* Code Generator: Added ``.selector`` member on external function types to retrieve their signature.
|
* Code Generator: Added ``.selector`` member on external function types to retrieve their signature.
|
||||||
* Optimizer: Add new optimization step to remove unused ``JUMPDEST``s.
|
* Optimizer: Add new optimization step to remove unused ``JUMPDEST``s.
|
||||||
|
* Syntax Checker: Warn if no visibility is specified on contract functions.
|
||||||
* Type Checker: Display helpful warning for unused function arguments/return parameters.
|
* Type Checker: Display helpful warning for unused function arguments/return parameters.
|
||||||
* Type Checker: Do not show the same error multiple times for events.
|
* Type Checker: Do not show the same error multiple times for events.
|
||||||
* Type Checker: Greatly reduce the number of duplicate errors shown for duplicate constructors and functions.
|
* Type Checker: Greatly reduce the number of duplicate errors shown for duplicate constructors and functions.
|
||||||
|
@ -138,7 +138,7 @@ bool SyntaxChecker::visit(WhileStatement const&)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SyntaxChecker::endVisit(WhileStatement const& )
|
void SyntaxChecker::endVisit(WhileStatement const&)
|
||||||
{
|
{
|
||||||
m_inLoopDepth--;
|
m_inLoopDepth--;
|
||||||
}
|
}
|
||||||
@ -193,6 +193,18 @@ bool SyntaxChecker::visit(PlaceholderStatement const&)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SyntaxChecker::visit(FunctionDefinition const& _function)
|
||||||
|
{
|
||||||
|
if (_function.noVisibilitySpecified())
|
||||||
|
m_errorReporter.warning(
|
||||||
|
_function.location(),
|
||||||
|
"No visibility specified. Defaulting to \"" +
|
||||||
|
Declaration::visibilityToString(_function.visibility()) +
|
||||||
|
"\"."
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool SyntaxChecker::visit(FunctionTypeName const& _node)
|
bool SyntaxChecker::visit(FunctionTypeName const& _node)
|
||||||
{
|
{
|
||||||
for (auto const& decl: _node.parameterTypeList()->parameters())
|
for (auto const& decl: _node.parameterTypeList()->parameters())
|
||||||
|
@ -66,6 +66,7 @@ private:
|
|||||||
|
|
||||||
virtual bool visit(PlaceholderStatement const& _placeholderStatement) override;
|
virtual bool visit(PlaceholderStatement const& _placeholderStatement) override;
|
||||||
|
|
||||||
|
virtual bool visit(FunctionDefinition const& _function) override;
|
||||||
virtual bool visit(FunctionTypeName const& _node) override;
|
virtual bool visit(FunctionTypeName const& _node) override;
|
||||||
|
|
||||||
ErrorReporter& m_errorReporter;
|
ErrorReporter& m_errorReporter;
|
||||||
|
@ -180,6 +180,7 @@ public:
|
|||||||
|
|
||||||
/// @returns the declared name.
|
/// @returns the declared name.
|
||||||
ASTString const& name() const { return *m_name; }
|
ASTString const& name() const { return *m_name; }
|
||||||
|
bool noVisibilitySpecified() const { return m_visibility == Visibility::Default; }
|
||||||
Visibility visibility() const { return m_visibility == Visibility::Default ? defaultVisibility() : m_visibility; }
|
Visibility visibility() const { return m_visibility == Visibility::Default ? defaultVisibility() : m_visibility; }
|
||||||
bool isPublic() const { return visibility() >= Visibility::Public; }
|
bool isPublic() const { return visibility() >= Visibility::Public; }
|
||||||
virtual bool isVisibleInContract() const { return visibility() != Visibility::External; }
|
virtual bool isVisibleInContract() const { return visibility() != Visibility::External; }
|
||||||
|
Loading…
Reference in New Issue
Block a user